summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2000-09-18 14:29:57 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2000-09-18 14:29:57 +0000
commitb525a3115f54576017a576ff842dede5e2e3545d (patch)
treec534b95a9e572b63896467624293a5ca1887d3a3
parent9399c662f36c385b0c705eb34e636a9aec450282 (diff)
initial import
-rw-r--r--bridges/inc/bridges/cpp_uno/bridge.hxx528
-rw-r--r--bridges/inc/bridges/cpp_uno/type_misc.hxx155
-rw-r--r--bridges/inc/bridges/remote/bridgeimpl.hxx129
-rw-r--r--bridges/inc/bridges/remote/connection.h99
-rw-r--r--bridges/inc/bridges/remote/context.h263
-rw-r--r--bridges/inc/bridges/remote/counter.hxx90
-rw-r--r--bridges/inc/bridges/remote/helper.hxx81
-rw-r--r--bridges/inc/bridges/remote/mapping.hxx106
-rw-r--r--bridges/inc/bridges/remote/proxy.hxx107
-rw-r--r--bridges/inc/bridges/remote/remote.h118
-rw-r--r--bridges/inc/bridges/remote/remote.hxx109
-rw-r--r--bridges/inc/bridges/remote/stub.hxx100
-rw-r--r--bridges/prj/d.lst26
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_intel/call.s212
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_intel/cc50_solaris_intel.hxx105
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_intel/cpp2uno.cxx637
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_intel/except.cxx453
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_intel/makefile.mk110
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_intel/uno2cpp.cxx444
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_sparc/call.s165
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_sparc/cc50_solaris_sparc.hxx118
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_sparc/cpp2uno.cxx696
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx421
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_sparc/makefile.mk111
-rw-r--r--bridges/source/cpp_uno/cc50_solaris_sparc/uno2cpp.cxx423
-rw-r--r--bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx563
-rw-r--r--bridges/source/cpp_uno/msvc_win32_intel/except.cxx538
-rw-r--r--bridges/source/cpp_uno/msvc_win32_intel/makefile.mk119
-rw-r--r--bridges/source/cpp_uno/msvc_win32_intel/msci.hxx90
-rw-r--r--bridges/source/cpp_uno/msvc_win32_intel/uno2cpp.cxx494
-rw-r--r--bridges/source/remote/context/context.cxx552
-rw-r--r--bridges/source/remote/context/exports.dxp5
-rw-r--r--bridges/source/remote/context/makefile.mk107
-rw-r--r--bridges/source/remote/idl/corba.idl122
-rw-r--r--bridges/source/remote/static/helper.cxx232
-rw-r--r--bridges/source/remote/static/makefile.mk107
-rw-r--r--bridges/source/remote/static/mapping.cxx250
-rw-r--r--bridges/source/remote/static/proxy.cxx372
-rw-r--r--bridges/source/remote/static/remote.cxx172
-rw-r--r--bridges/source/remote/static/remote_types.cxx123
-rw-r--r--bridges/source/remote/static/remote_types.hxx134
-rw-r--r--bridges/source/remote/static/stub.cxx370
-rw-r--r--bridges/source/remote/urp/makefile.mk130
-rw-r--r--bridges/source/remote/urp/urp_bridgeimpl.cxx92
-rw-r--r--bridges/source/remote/urp/urp_bridgeimpl.hxx142
-rw-r--r--bridges/source/remote/urp/urp_cache.h86
-rw-r--r--bridges/source/remote/urp/urp_cache.hxx132
-rw-r--r--bridges/source/remote/urp/urp_dispatch.cxx370
-rw-r--r--bridges/source/remote/urp/urp_dispatch.hxx98
-rw-r--r--bridges/source/remote/urp/urp_environment.cxx431
-rw-r--r--bridges/source/remote/urp/urp_job.cxx540
-rw-r--r--bridges/source/remote/urp/urp_job.hxx276
-rw-r--r--bridges/source/remote/urp/urp_log.cxx127
-rw-r--r--bridges/source/remote/urp/urp_log.hxx84
-rw-r--r--bridges/source/remote/urp/urp_marshal.cxx240
-rw-r--r--bridges/source/remote/urp/urp_marshal.hxx378
-rw-r--r--bridges/source/remote/urp/urp_marshal_decl.hxx103
-rw-r--r--bridges/source/remote/urp/urp_reader.cxx578
-rw-r--r--bridges/source/remote/urp/urp_reader.hxx102
-rw-r--r--bridges/source/remote/urp/urp_replycontainer.hxx110
-rw-r--r--bridges/source/remote/urp/urp_threadid.hxx90
-rw-r--r--bridges/source/remote/urp/urp_unmarshal.cxx529
-rw-r--r--bridges/source/remote/urp/urp_unmarshal.hxx392
-rw-r--r--bridges/source/remote/urp/urp_writer.cxx201
-rw-r--r--bridges/source/remote/urp/urp_writer.hxx97
-rw-r--r--bridges/test/makefile.mk279
-rw-r--r--bridges/test/test_bridge.idl119
-rw-r--r--bridges/test/testclient.cxx293
-rw-r--r--bridges/test/testclient.java190
-rw-r--r--bridges/test/testcomp.cxx875
-rw-r--r--bridges/test/testcomp.h214
-rw-r--r--bridges/test/testoffice.cxx314
-rw-r--r--bridges/test/testsameprocess.cxx252
-rw-r--r--bridges/test/testserver.cxx293
-rw-r--r--bridges/version.mk75
-rw-r--r--codemaker/inc/codemaker/global.hxx152
-rw-r--r--codemaker/inc/codemaker/options.hxx141
-rw-r--r--codemaker/inc/codemaker/typemanager.hxx212
-rw-r--r--codemaker/prj/d.lst8
-rw-r--r--codemaker/source/codemaker/global.cxx377
-rw-r--r--codemaker/source/codemaker/makefile.mk92
-rw-r--r--codemaker/source/codemaker/options.cxx138
-rw-r--r--codemaker/source/codemaker/typemanager.cxx322
-rw-r--r--codemaker/source/cppumaker/cppumaker.cxx222
-rw-r--r--codemaker/source/cppumaker/cppuoptions.cxx340
-rw-r--r--codemaker/source/cppumaker/cppuoptions.hxx85
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx3838
-rw-r--r--codemaker/source/cppumaker/cpputype.hxx325
-rw-r--r--codemaker/source/cppumaker/makefile.mk104
-rw-r--r--codemaker/source/javamaker/javamaker.cxx222
-rw-r--r--codemaker/source/javamaker/javaoptions.cxx246
-rw-r--r--codemaker/source/javamaker/javaoptions.hxx85
-rw-r--r--codemaker/source/javamaker/javatype.cxx1977
-rw-r--r--codemaker/source/javamaker/javatype.hxx342
-rw-r--r--codemaker/source/javamaker/makefile.mk104
-rw-r--r--cppu/inc/com/sun/star/uno/Any.h376
-rw-r--r--cppu/inc/com/sun/star/uno/Any.hxx487
-rw-r--r--cppu/inc/com/sun/star/uno/Reference.h342
-rw-r--r--cppu/inc/com/sun/star/uno/Reference.hxx170
-rw-r--r--cppu/inc/com/sun/star/uno/Sequence.h291
-rw-r--r--cppu/inc/com/sun/star/uno/Sequence.hxx236
-rw-r--r--cppu/inc/com/sun/star/uno/Type.h364
-rw-r--r--cppu/inc/com/sun/star/uno/Type.hxx238
-rw-r--r--cppu/inc/com/sun/star/uno/genfunc.h105
-rw-r--r--cppu/inc/com/sun/star/uno/genfunc.hxx120
-rw-r--r--cppu/inc/cppu/macros.hxx160
-rw-r--r--cppu/inc/typelib/typeclass.h133
-rw-r--r--cppu/inc/typelib/typedescription.h910
-rw-r--r--cppu/inc/typelib/typedescription.hxx256
-rw-r--r--cppu/inc/typelib/uik.h92
-rw-r--r--cppu/inc/uno/any2.h162
-rw-r--r--cppu/inc/uno/data.h245
-rw-r--r--cppu/inc/uno/dispatcher.h134
-rw-r--r--cppu/inc/uno/environment.h344
-rw-r--r--cppu/inc/uno/environment.hxx205
-rw-r--r--cppu/inc/uno/lbnames.h86
-rw-r--r--cppu/inc/uno/mapping.h233
-rw-r--r--cppu/inc/uno/mapping.hxx333
-rw-r--r--cppu/inc/uno/sequence2.h192
-rw-r--r--cppu/inc/uno/threadpool.h212
-rw-r--r--cppu/prj/d.lst42
-rw-r--r--cppu/source/cppu/makefile.mk76
-rw-r--r--cppu/source/threadpool/jobqueue.cxx223
-rw-r--r--cppu/source/threadpool/jobqueue.hxx112
-rw-r--r--cppu/source/threadpool/makefile.mk88
-rw-r--r--cppu/source/threadpool/thread.cxx170
-rw-r--r--cppu/source/threadpool/thread.hxx102
-rw-r--r--cppu/source/threadpool/threadident.cxx218
-rw-r--r--cppu/source/threadpool/threadpool.cxx473
-rw-r--r--cppu/source/threadpool/threadpool.hxx163
-rw-r--r--cppu/source/typelib/makefile.mk81
-rw-r--r--cppu/source/typelib/static_types.cxx626
-rw-r--r--cppu/source/typelib/typelib.cxx2112
-rw-r--r--cppu/source/uno/any.cxx135
-rw-r--r--cppu/source/uno/assign.hxx545
-rw-r--r--cppu/source/uno/constr.hxx206
-rw-r--r--cppu/source/uno/copy.hxx715
-rw-r--r--cppu/source/uno/data.cxx357
-rw-r--r--cppu/source/uno/destr.hxx411
-rw-r--r--cppu/source/uno/eq.hxx745
-rw-r--r--cppu/source/uno/lbenv.cxx981
-rw-r--r--cppu/source/uno/lbmap.cxx657
-rw-r--r--cppu/source/uno/makefile.mk93
-rw-r--r--cppu/source/uno/prim.hxx262
-rw-r--r--cppu/source/uno/sequence.cxx804
-rw-r--r--cppu/test/cpputest.idl129
-rw-r--r--cppu/test/language_binding.idl212
-rw-r--r--cppu/test/makefile.mk153
-rw-r--r--cppu/test/surrogate.hxx189
-rw-r--r--cppu/test/test_di.cxx608
-rw-r--r--cppu/test/testcppu.cxx886
-rw-r--r--cppu/test/testthreadpool.cxx223
-rw-r--r--cppu/util/makefile.mk120
-rw-r--r--cppu/util/makefile.pmk63
-rw-r--r--cppu/util/target.pmk96
-rw-r--r--cppuhelper/inc/cppuhelper/compbase.hxx249
-rw-r--r--cppuhelper/inc/cppuhelper/compbase1.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase10.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase11.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase12.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase2.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase3.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase4.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase5.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase6.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase7.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase8.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/compbase9.hxx73
-rw-r--r--cppuhelper/inc/cppuhelper/component.hxx147
-rw-r--r--cppuhelper/inc/cppuhelper/exc_hlp.hxx84
-rw-r--r--cppuhelper/inc/cppuhelper/factory.hxx272
-rw-r--r--cppuhelper/inc/cppuhelper/implbase.hxx239
-rw-r--r--cppuhelper/inc/cppuhelper/implbase1.hxx75
-rw-r--r--cppuhelper/inc/cppuhelper/implbase10.hxx77
-rw-r--r--cppuhelper/inc/cppuhelper/implbase11.hxx77
-rw-r--r--cppuhelper/inc/cppuhelper/implbase12.hxx77
-rw-r--r--cppuhelper/inc/cppuhelper/implbase2.hxx75
-rw-r--r--cppuhelper/inc/cppuhelper/implbase3.hxx75
-rw-r--r--cppuhelper/inc/cppuhelper/implbase4.hxx75
-rw-r--r--cppuhelper/inc/cppuhelper/implbase5.hxx76
-rw-r--r--cppuhelper/inc/cppuhelper/implbase6.hxx76
-rw-r--r--cppuhelper/inc/cppuhelper/implbase7.hxx76
-rw-r--r--cppuhelper/inc/cppuhelper/implbase8.hxx76
-rw-r--r--cppuhelper/inc/cppuhelper/implbase9.hxx78
-rw-r--r--cppuhelper/inc/cppuhelper/interfacecontainer.h376
-rw-r--r--cppuhelper/inc/cppuhelper/interfacecontainer.hxx240
-rw-r--r--cppuhelper/inc/cppuhelper/propshlp.hxx479
-rw-r--r--cppuhelper/inc/cppuhelper/proptypehlp.h116
-rw-r--r--cppuhelper/inc/cppuhelper/proptypehlp.hxx556
-rw-r--r--cppuhelper/inc/cppuhelper/queryinterface.hxx487
-rw-r--r--cppuhelper/inc/cppuhelper/servicefactory.hxx148
-rw-r--r--cppuhelper/inc/cppuhelper/stdidlclass.hxx554
-rw-r--r--cppuhelper/inc/cppuhelper/typeprovider.hxx226
-rw-r--r--cppuhelper/inc/cppuhelper/weak.hxx160
-rw-r--r--cppuhelper/inc/cppuhelper/weakagg.hxx149
-rw-r--r--cppuhelper/inc/cppuhelper/weakref.hxx182
-rw-r--r--cppuhelper/prj/d.lst57
-rw-r--r--cppuhelper/source/component.cxx212
-rw-r--r--cppuhelper/source/exc_thrower.cxx287
-rw-r--r--cppuhelper/source/factory.cxx719
-rw-r--r--cppuhelper/source/implbase.cxx227
-rw-r--r--cppuhelper/source/interfacecontainer.cxx383
-rw-r--r--cppuhelper/source/makefile.mk167
-rw-r--r--cppuhelper/source/propshlp.cxx1106
-rw-r--r--cppuhelper/source/servicefactory.cxx507
-rw-r--r--cppuhelper/source/stdidlclass.cxx240
-rw-r--r--cppuhelper/source/typeprovider.cxx344
-rw-r--r--cppuhelper/source/weak.cxx521
-rw-r--r--cppuhelper/test/helpertest.idl117
-rw-r--r--cppuhelper/test/makefile.mk133
-rw-r--r--cppuhelper/test/testhelper.cxx132
-rw-r--r--cppuhelper/test/testhelper.hxx64
-rw-r--r--cppuhelper/test/testidlclass.cxx259
-rw-r--r--cppuhelper/test/testimplhelper.cxx387
-rw-r--r--cppuhelper/test/testpropshlp.cxx1198
-rw-r--r--cppuhelper/test/testproptyphlp.cxx116
-rw-r--r--jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java216
-rw-r--r--jurt/com/sun/star/comp/bridgefactory/makefile.mk90
-rw-r--r--jurt/com/sun/star/comp/connections/Acceptor.java244
-rw-r--r--jurt/com/sun/star/comp/connections/Connector.java223
-rw-r--r--jurt/com/sun/star/comp/connections/ConstantInstanceProvider.java174
-rw-r--r--jurt/com/sun/star/comp/connections/PipedConnection.java318
-rw-r--r--jurt/com/sun/star/comp/connections/makefile.mk91
-rw-r--r--jurt/com/sun/star/comp/loader/FactoryHelper.java360
-rw-r--r--jurt/com/sun/star/comp/loader/JavaLoader.java914
-rw-r--r--jurt/com/sun/star/comp/loader/JavaLoaderFactory.java141
-rw-r--r--jurt/com/sun/star/comp/loader/RegistrationClassFinder.java146
-rw-r--r--jurt/com/sun/star/comp/loader/makefile.mk103
-rw-r--r--jurt/com/sun/star/comp/servicemanager/ServiceManager.java866
-rw-r--r--jurt/com/sun/star/comp/servicemanager/makefile.mk92
-rw-r--r--jurt/com/sun/star/comp/urlresolver/UrlResolver.java210
-rw-r--r--jurt/com/sun/star/comp/urlresolver/makefile.mk85
-rw-r--r--jurt/com/sun/star/lib/connections/socket/SocketConnection.java275
-rw-r--r--jurt/com/sun/star/lib/connections/socket/makefile.mk92
-rw-r--r--jurt/com/sun/star/lib/connections/socket/socketAcceptor.java262
-rw-r--r--jurt/com/sun/star/lib/connections/socket/socketConnector.java239
-rw-r--r--jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java116
-rw-r--r--jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java118
-rw-r--r--jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java775
-rw-r--r--jurt/com/sun/star/lib/uno/bridges/java_remote/makefile.mk89
-rw-r--r--jurt/com/sun/star/lib/uno/environments/java/java_environment.java410
-rw-r--r--jurt/com/sun/star/lib/uno/environments/java/makefile.mk82
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/IProtocol.java139
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/IReceiver.java92
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java122
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java348
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/Job.java284
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java515
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/makefile.mk102
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/remote_environment.java194
-rw-r--r--jurt/com/sun/star/lib/uno/protocols/urp/Cache.java213
-rw-r--r--jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java480
-rw-r--r--jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java483
-rw-r--r--jurt/com/sun/star/lib/uno/protocols/urp/makefile.mk96
-rw-r--r--jurt/com/sun/star/lib/uno/protocols/urp/urp.java621
-rw-r--r--jurt/com/sun/star/lib/util/makefile.mk83
-rw-r--r--jurt/com/sun/star/uno/Ascii.java83
-rw-r--r--jurt/com/sun/star/uno/AsciiString.java84
-rw-r--r--jurt/com/sun/star/uno/MappingException.java104
-rw-r--r--jurt/com/sun/star/uno/makefile.mk103
-rw-r--r--jurt/demo/com/sun/star/demo/DemoServer.java135
-rw-r--r--jurt/demo/com/sun/star/demo/TestOffice.java227
-rw-r--r--jurt/demo/com/sun/star/demo/makefile.mk96
-rw-r--r--jurt/prj/d.lst1
-rw-r--r--jurt/test/com/sun/star/comp/connections/PipedConnection_Test.java187
-rw-r--r--jurt/test/com/sun/star/comp/connections/makefile.mk82
-rw-r--r--jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java211
-rw-r--r--jurt/test/com/sun/star/lib/uno/bridges/java_remote/makefile.mk88
-rw-r--r--jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java111
-rw-r--r--jurt/test/com/sun/star/lib/uno/environments/java/makefile.mk87
-rw-r--r--jurt/test/com/sun/star/lib/uno/environments/remote/JobQueue_Test.java412
-rw-r--r--jurt/test/com/sun/star/lib/uno/environments/remote/ThreadPool_Test.java404
-rw-r--r--jurt/test/com/sun/star/lib/uno/environments/remote/makefile.mk84
-rw-r--r--jurt/test/com/sun/star/lib/util/makefile.mk85
-rw-r--r--jurt/test/com/sun/star/uno/makefile.mk85
-rw-r--r--jurt/test/makefile.mk80
-rw-r--r--jurt/util/makefile.mk77
-rw-r--r--jurt/util/makefile.pmk77
-rw-r--r--rdbmaker/inc/codemaker/dependency.hxx215
-rw-r--r--rdbmaker/inc/codemaker/global.hxx152
-rw-r--r--rdbmaker/inc/codemaker/options.hxx141
-rw-r--r--rdbmaker/inc/codemaker/registry.hxx254
-rw-r--r--rdbmaker/inc/codemaker/typemanager.hxx212
-rw-r--r--rdbmaker/prj/d.lst5
-rw-r--r--rdbmaker/source/codemaker/dependency.cxx348
-rw-r--r--rdbmaker/source/codemaker/global.cxx377
-rw-r--r--rdbmaker/source/codemaker/makefile.mk92
-rw-r--r--rdbmaker/source/codemaker/options.cxx138
-rw-r--r--rdbmaker/source/codemaker/typemanager.cxx322
-rw-r--r--rdbmaker/source/rdbmaker/makefile.mk128
-rw-r--r--rdbmaker/source/rdbmaker/rdbmaker.cxx554
-rw-r--r--rdbmaker/source/rdbmaker/rdboptions.cxx406
-rw-r--r--rdbmaker/source/rdbmaker/rdboptions.hxx91
-rw-r--r--rdbmaker/source/rdbmaker/rdbtype.cxx235
-rw-r--r--rdbmaker/source/rdbmaker/rdbtype.hxx90
-rw-r--r--rdbmaker/source/rdbmaker/specialtypemanager.cxx139
-rw-r--r--rdbmaker/source/rdbmaker/specialtypemanager.hxx111
-rw-r--r--rdbmaker/source/rdbmaker/typeblop.cxx517
-rw-r--r--remotebridges/prj/d.lst6
-rw-r--r--remotebridges/source/factory/brdgfctr.xml57
-rw-r--r--remotebridges/source/factory/bridgefactory.cxx412
-rw-r--r--remotebridges/source/factory/bridgeimpl.cxx263
-rw-r--r--remotebridges/source/factory/bridgeimpl.hxx139
-rw-r--r--remotebridges/source/factory/makefile.mk108
-rw-r--r--remotebridges/source/unourl_resolver/makefile.mk127
-rw-r--r--remotebridges/source/unourl_resolver/unourl_resolver.cxx269
-rw-r--r--remotebridges/source/unourl_resolver/uuresolver.xml51
-rw-r--r--stoc/prj/d.lst25
-rw-r--r--stoc/source/corereflection/base.hxx558
-rw-r--r--stoc/source/corereflection/corefl.xml52
-rw-r--r--stoc/source/corereflection/crarray.cxx262
-rw-r--r--stoc/source/corereflection/crbase.cxx318
-rw-r--r--stoc/source/corereflection/crcomp.cxx393
-rw-r--r--stoc/source/corereflection/crefl.cxx488
-rw-r--r--stoc/source/corereflection/crenum.cxx264
-rw-r--r--stoc/source/corereflection/criface.cxx1001
-rw-r--r--stoc/source/corereflection/lrucache.hxx282
-rw-r--r--stoc/source/corereflection/makefile.mk110
-rw-r--r--stoc/source/cppumaker.mk77
-rw-r--r--stoc/source/defaultregistry/defaultregistry.cxx1440
-rw-r--r--stoc/source/defaultregistry/makefile.mk107
-rw-r--r--stoc/source/implementationregistration/implreg.cxx1750
-rw-r--r--stoc/source/implementationregistration/makefile.mk107
-rw-r--r--stoc/source/inspect/insp.xml68
-rw-r--r--stoc/source/inspect/introspection.cxx3023
-rw-r--r--stoc/source/inspect/makefile.mk106
-rw-r--r--stoc/source/invocation/inv.xml89
-rw-r--r--stoc/source/invocation/invocation.cxx1282
-rw-r--r--stoc/source/invocation/makefile.mk107
-rw-r--r--stoc/source/invocation_adapterfactory/iafactory.cxx760
-rw-r--r--stoc/source/invocation_adapterfactory/invadp.xml53
-rw-r--r--stoc/source/invocation_adapterfactory/makefile.mk105
-rw-r--r--stoc/source/javaloader/javaloader.cxx674
-rw-r--r--stoc/source/javaloader/makefile.mk154
-rw-r--r--stoc/source/javavm/javavm.cxx1641
-rw-r--r--stoc/source/javavm/jen.xml54
-rw-r--r--stoc/source/javavm/jvmargs.cxx303
-rw-r--r--stoc/source/javavm/jvmargs.hxx228
-rw-r--r--stoc/source/javavm/makefile.mk147
-rw-r--r--stoc/source/loader/dllcomponentloader.cxx560
-rw-r--r--stoc/source/loader/makefile.mk107
-rw-r--r--stoc/source/namingservice/makefile.mk105
-rw-r--r--stoc/source/namingservice/namingservice.cxx301
-rw-r--r--stoc/source/namingservice/namingservice.xml47
-rw-r--r--stoc/source/proxy_factory/makefile.mk107
-rw-r--r--stoc/source/proxy_factory/proxyfac.cxx459
-rw-r--r--stoc/source/proxy_factory/proxyfac.xml49
-rw-r--r--stoc/source/registry_tdprovider/base.hxx337
-rw-r--r--stoc/source/registry_tdprovider/makefile.mk112
-rw-r--r--stoc/source/registry_tdprovider/tdcomp.cxx180
-rw-r--r--stoc/source/registry_tdprovider/tdef.cxx108
-rw-r--r--stoc/source/registry_tdprovider/tdenum.cxx152
-rw-r--r--stoc/source/registry_tdprovider/tdiface.cxx662
-rw-r--r--stoc/source/registry_tdprovider/tdprovider.cxx528
-rw-r--r--stoc/source/servicemanager/makefile.mk107
-rw-r--r--stoc/source/servicemanager/servicemanager.cxx1422
-rw-r--r--stoc/source/simpleregistry/makefile.mk107
-rw-r--r--stoc/source/simpleregistry/simpleregistry.cxx1252
-rw-r--r--stoc/source/tdmanager/lrucache.hxx282
-rw-r--r--stoc/source/tdmanager/makefile.mk108
-rw-r--r--stoc/source/tdmanager/tdmgr.cxx834
-rw-r--r--stoc/source/typeconv/convert.cxx907
-rw-r--r--stoc/source/typeconv/makefile.mk105
-rw-r--r--stoc/test/excomp/example/ExampleComponent1.idl77
-rw-r--r--stoc/test/excomp/example/ExampleComponent2.idl77
-rw-r--r--stoc/test/excomp/example/XTest.idl84
-rw-r--r--stoc/test/excomp/excomp.cxx182
-rw-r--r--stoc/test/excomp/excomp1.cxx259
-rw-r--r--stoc/test/excomp/excomp1.xml45
-rw-r--r--stoc/test/excomp/excomp2.cxx334
-rw-r--r--stoc/test/excomp/excomp2.xml45
-rw-r--r--stoc/test/excomp/exports.dxp4
-rw-r--r--stoc/test/excomp/makefile.mk167
-rw-r--r--stoc/test/javavm/makefile.mk124
-rw-r--r--stoc/test/javavm/testjavavm.cxx224
-rw-r--r--stoc/test/javavm/testjavavm.java73
-rw-r--r--stoc/test/language_binding.idl213
-rw-r--r--stoc/test/makefile.mk239
-rw-r--r--stoc/test/testconv.cxx736
-rw-r--r--stoc/test/testcorefl.cxx439
-rw-r--r--stoc/test/testcorefl.idl140
-rw-r--r--stoc/test/testiadapter.cxx1029
-rw-r--r--stoc/test/testintrosp.cxx1645
-rw-r--r--stoc/test/testintrosp.idl255
-rw-r--r--stoc/test/testloader.cxx162
-rw-r--r--stoc/test/testproxyfac.cxx243
-rw-r--r--stoc/test/testregistry.cxx671
-rw-r--r--stoc/test/testsmgr.cxx162
-rw-r--r--stoc/unosdk.mk69
-rw-r--r--unoil/prj/d.lst1
-rw-r--r--unoil/util/makefile.mk79
-rw-r--r--xml2cmp/prj/d.lst2
-rw-r--r--xml2cmp/source/inc/lst_str.h133
-rw-r--r--xml2cmp/source/inc/new_del.h89
-rw-r--r--xml2cmp/source/inc/precomp.h89
-rw-r--r--xml2cmp/source/inc/str.h105
-rw-r--r--xml2cmp/source/inc/textbuff.h119
-rw-r--r--xml2cmp/source/inc/textfile.h110
-rw-r--r--xml2cmp/source/x2cclass/x2cstl.hxx81
-rw-r--r--xml2cmp/source/x2cclass/xml_cd.hxx119
-rw-r--r--xml2cmp/source/x2cclass/xml_cdff.cxx265
-rw-r--r--xml2cmp/source/x2cclass/xml_cdff.hxx138
-rw-r--r--xml2cmp/source/x2cclass/xml_cdim.cxx217
-rw-r--r--xml2cmp/source/x2cclass/xml_cdim.hxx147
404 files changed, 114574 insertions, 0 deletions
diff --git a/bridges/inc/bridges/cpp_uno/bridge.hxx b/bridges/inc/bridges/cpp_uno/bridge.hxx
new file mode 100644
index 000000000000..ba25d64a7657
--- /dev/null
+++ b/bridges/inc/bridges/cpp_uno/bridge.hxx
@@ -0,0 +1,528 @@
+/*************************************************************************
+ *
+ * $RCSfile: bridge.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:47 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#define _BRIDGES_CPP_UNO_BRIDGE_HXX_
+
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_H_
+#include <bridges/cpp_uno/bridge.h>
+#endif
+
+#ifndef _OSL_PROCESS_H_
+#include <osl/process.h>
+#endif
+#ifndef _RTL_PROCESS_H_
+#include <rtl/process.h>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_
+#include <com/sun/star/uno/genfunc.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
+#include <com/sun/star/uno/XInterface.hpp>
+#endif
+
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_cppInterfaceProxy_free( uno_ExtEnvironment * pEnv, void * pProxy )
+{
+ cppu_cppInterfaceProxy * pThis =
+ static_cast< cppu_cppInterfaceProxy * >(
+ reinterpret_cast< ::com::sun::star::uno::XInterface * >( pProxy ) );
+ OSL_ASSERT( pEnv == pThis->pBridge->pCppEnv );
+
+ (*pThis->pBridge->pUnoEnv->revokeInterface)( pThis->pBridge->pUnoEnv, pThis->pUnoI );
+ (*pThis->pUnoI->release)( pThis->pUnoI );
+ ::typelib_typedescription_release( (typelib_TypeDescription *)pThis->pTypeDescr );
+ pThis->pBridge->release();
+
+#ifdef DEBUG
+ *(int *)pProxy = 0xdeadbabe;
+#endif
+ delete pThis;
+}
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_Mapping_uno2cpp(
+ uno_Mapping * pMapping, void ** ppCppI,
+ void * pUnoI, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ OSL_ASSERT( ppCppI && pTypeDescr );
+ if (*ppCppI)
+ {
+ reinterpret_cast< ::com::sun::star::uno::XInterface * >( *ppCppI )->release();
+ *ppCppI = 0;
+ }
+ if (pUnoI)
+ {
+ cppu_Bridge * pBridge = static_cast< cppu_Mapping * >( pMapping )->pBridge;
+
+ // get object id of uno interface to be wrapped
+ rtl_uString * pOId = 0;
+ (*pBridge->pUnoEnv->getObjectIdentifier)( pBridge->pUnoEnv, &pOId, pUnoI );
+ OSL_ASSERT( pOId );
+
+ // try to get any known interface from target environment
+ (*pBridge->pCppEnv->getRegisteredInterface)(
+ pBridge->pCppEnv, ppCppI, pOId, pTypeDescr );
+
+ if (! *ppCppI) // no existing interface, register new proxy interface
+ {
+ // try to publish a new proxy (ref count initially 1)
+ cppu_cppInterfaceProxy * pProxy = new cppu_cppInterfaceProxy(
+ pBridge, reinterpret_cast< uno_Interface * >( pUnoI ), pTypeDescr, pOId );
+ ::com::sun::star::uno::XInterface * pSurrogate = pProxy;
+ cppu_cppInterfaceProxy_patchVtable( pSurrogate, pProxy->pTypeDescr );
+
+ // proxy may be exchanged during registration
+ (*pBridge->pCppEnv->registerProxyInterface)(
+ pBridge->pCppEnv, reinterpret_cast< void ** >( &pSurrogate ),
+ cppu_cppInterfaceProxy_free, pOId, pTypeDescr );
+
+ *ppCppI = pSurrogate;
+ }
+ ::rtl_uString_release( pOId );
+ }
+}
+//__________________________________________________________________________________________________
+inline void cppu_cppInterfaceProxy::acquireProxy()
+{
+ if (1 == osl_incrementInterlockedCount( &nRef ))
+ {
+ // rebirth of proxy zombie
+ // register at cpp env
+ void * pThis = static_cast< ::com::sun::star::uno::XInterface * >( this );
+ (*pBridge->pCppEnv->registerProxyInterface)(
+ pBridge->pCppEnv, &pThis, cppu_cppInterfaceProxy_free, oid.pData, pTypeDescr );
+ OSL_ASSERT( pThis == static_cast< ::com::sun::star::uno::XInterface * >( this ) );
+ }
+}
+//__________________________________________________________________________________________________
+inline void cppu_cppInterfaceProxy::releaseProxy()
+{
+ if (! osl_decrementInterlockedCount( &nRef )) // last release
+ {
+ // revoke from cpp env
+ (*pBridge->pCppEnv->revokeInterface)(
+ pBridge->pCppEnv, static_cast< ::com::sun::star::uno::XInterface * >( this ) );
+ }
+}
+//__________________________________________________________________________________________________
+inline cppu_cppInterfaceProxy::cppu_cppInterfaceProxy(
+ cppu_Bridge * pBridge_, uno_Interface * pUnoI_,
+ typelib_InterfaceTypeDescription * pTypeDescr_, const ::rtl::OUString & rOId_ )
+ : nRef( 1 )
+ , pBridge( pBridge_ )
+ , pUnoI( pUnoI_ )
+ , pTypeDescr( pTypeDescr_ )
+ , oid( rOId_ )
+{
+ pBridge->acquire();
+ ::typelib_typedescription_acquire( (typelib_TypeDescription *)pTypeDescr );
+ if (! ((typelib_TypeDescription *)pTypeDescr)->bComplete)
+ ::typelib_typedescription_complete( (typelib_TypeDescription **)&pTypeDescr );
+ (*pBridge->pUnoEnv->registerInterface)(
+ pBridge->pUnoEnv, reinterpret_cast< void ** >( &pUnoI ), oid.pData, pTypeDescr );
+ (*pUnoI->acquire)( pUnoI );
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_unoInterfaceProxy_free( uno_ExtEnvironment * pEnv, void * pProxy )
+{
+ cppu_unoInterfaceProxy * pThis =
+ static_cast< cppu_unoInterfaceProxy * >(
+ reinterpret_cast< uno_Interface * >( pProxy ) );
+ OSL_ASSERT( pEnv == pThis->pBridge->pUnoEnv );
+
+ (*pThis->pBridge->pCppEnv->revokeInterface)( pThis->pBridge->pCppEnv, pThis->pCppI );
+ pThis->pCppI->release();
+ ::typelib_typedescription_release( (typelib_TypeDescription *)pThis->pTypeDescr );
+ pThis->pBridge->release();
+
+#ifdef DEBUG
+ *(int *)pProxy = 0xdeadbabe;
+#endif
+ delete pThis;
+}
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_unoInterfaceProxy_acquire( uno_Interface * pUnoI )
+{
+ if (1 == osl_incrementInterlockedCount( & static_cast< cppu_unoInterfaceProxy * >( pUnoI )->nRef ))
+ {
+ // rebirth of proxy zombie
+ // register at uno env
+#ifdef DEBUG
+ void * pThis = pUnoI;
+#endif
+ (*static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pBridge->pUnoEnv->registerProxyInterface)(
+ static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pBridge->pUnoEnv,
+ reinterpret_cast< void ** >( &pUnoI ), cppu_unoInterfaceProxy_free,
+ static_cast< cppu_unoInterfaceProxy * >( pUnoI )->oid.pData,
+ static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pTypeDescr );
+#ifdef DEBUG
+ OSL_ASSERT( pThis == pUnoI );
+#endif
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_unoInterfaceProxy_release( uno_Interface * pUnoI )
+{
+ if (! osl_decrementInterlockedCount( & static_cast< cppu_unoInterfaceProxy * >( pUnoI )->nRef ))
+ {
+ // revoke from uno env on last release
+ (*static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pBridge->pUnoEnv->revokeInterface)(
+ static_cast< cppu_unoInterfaceProxy * >( pUnoI )->pBridge->pUnoEnv, pUnoI );
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_Mapping_cpp2uno(
+ uno_Mapping * pMapping, void ** ppUnoI,
+ void * pCppI, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ OSL_ENSHURE( ppUnoI && pTypeDescr, "### null ptr!" );
+ if (*ppUnoI)
+ {
+ (*reinterpret_cast< uno_Interface * >( *ppUnoI )->release)(
+ reinterpret_cast< uno_Interface * >( *ppUnoI ) );
+ *ppUnoI = 0;
+ }
+ if (pCppI)
+ {
+ cppu_Bridge * pBridge = static_cast< cppu_Mapping * >( pMapping )->pBridge;
+
+ // get object id of interface to be wrapped
+ rtl_uString * pOId = 0;
+ (*pBridge->pCppEnv->getObjectIdentifier)( pBridge->pCppEnv, &pOId, pCppI );
+ OSL_ASSERT( pOId );
+
+ // try to get any known interface from target environment
+ (*pBridge->pUnoEnv->getRegisteredInterface)(
+ pBridge->pUnoEnv, ppUnoI, pOId, pTypeDescr );
+
+ if (! *ppUnoI) // no existing interface, register new proxy interface
+ {
+ // try to publish a new proxy (refcount initially 1)
+ uno_Interface * pSurrogate = new cppu_unoInterfaceProxy(
+ pBridge, reinterpret_cast< ::com::sun::star::uno::XInterface * >( pCppI ),
+ pTypeDescr, pOId );
+
+ // proxy may be exchanged during registration
+ (*pBridge->pUnoEnv->registerProxyInterface)(
+ pBridge->pUnoEnv, reinterpret_cast< void ** >( &pSurrogate ),
+ cppu_unoInterfaceProxy_free, pOId, pTypeDescr );
+
+ *ppUnoI = pSurrogate;
+ }
+ ::rtl_uString_release( pOId );
+ }
+}
+//__________________________________________________________________________________________________
+inline cppu_unoInterfaceProxy::cppu_unoInterfaceProxy(
+ cppu_Bridge * pBridge_, ::com::sun::star::uno::XInterface * pCppI_,
+ typelib_InterfaceTypeDescription * pTypeDescr_, const ::rtl::OUString & rOId_ )
+ : nRef( 1 )
+ , pBridge( pBridge_ )
+ , pCppI( pCppI_ )
+ , pTypeDescr( pTypeDescr_ )
+ , oid( rOId_ )
+{
+ pBridge->acquire();
+ ::typelib_typedescription_acquire( (typelib_TypeDescription *)pTypeDescr );
+ if (! ((typelib_TypeDescription *)pTypeDescr)->bComplete)
+ ::typelib_typedescription_complete( (typelib_TypeDescription **)&pTypeDescr );
+ (*pBridge->pCppEnv->registerInterface)(
+ pBridge->pCppEnv, reinterpret_cast< void ** >( &pCppI ), oid.pData, pTypeDescr );
+ pCppI->acquire();
+
+ // uno_Interface
+ uno_Interface::acquire = CPPU_CURRENT_NAMESPACE::cppu_unoInterfaceProxy_acquire;
+ uno_Interface::release = CPPU_CURRENT_NAMESPACE::cppu_unoInterfaceProxy_release;
+ uno_Interface::pDispatcher = CPPU_CURRENT_NAMESPACE::cppu_unoInterfaceProxy_dispatch;
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_Mapping_acquire( uno_Mapping * pMapping )
+{
+ static_cast< cppu_Mapping * >( pMapping )->pBridge->acquire();
+}
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_Mapping_release( uno_Mapping * pMapping )
+{
+ static_cast< cppu_Mapping * >( pMapping )->pBridge->release();
+}
+//__________________________________________________________________________________________________
+inline cppu_Mapping::cppu_Mapping( cppu_Bridge * pBridge_, uno_MapInterfaceFunc fpMap )
+ : pBridge( pBridge_ )
+{
+ uno_Mapping::acquire = cppu_Mapping_acquire;
+ uno_Mapping::release = cppu_Mapping_release;
+ uno_Mapping::mapInterface = fpMap;
+}
+//__________________________________________________________________________________________________
+inline cppu_Bridge::cppu_Bridge( uno_ExtEnvironment * pCppEnv_, uno_ExtEnvironment * pUnoEnv_,
+ sal_Bool bExportCpp2Uno_ )
+ : nRef( 1 )
+ , pCppEnv( pCppEnv_ )
+ , pUnoEnv( pUnoEnv_ )
+ , aCpp2Uno( this, cppu_Mapping_cpp2uno )
+ , aUno2Cpp( this, cppu_Mapping_uno2cpp )
+ , bExportCpp2Uno( bExportCpp2Uno_ )
+{
+ (*((uno_Environment *)pCppEnv)->acquire)( (uno_Environment *)pCppEnv );
+ (*((uno_Environment *)pUnoEnv)->acquire)( (uno_Environment *)pUnoEnv );
+}
+//__________________________________________________________________________________________________
+inline void SAL_CALL cppu_Bridge_free( uno_Mapping * pMapping )
+{
+ cppu_Bridge * pThis = static_cast< cppu_Mapping * >( pMapping )->pBridge;
+ (*((uno_Environment *)pThis->pUnoEnv)->release)( (uno_Environment *)pThis->pUnoEnv );
+ (*((uno_Environment *)pThis->pCppEnv)->release)( (uno_Environment *)pThis->pCppEnv );
+ delete pThis;
+}
+//__________________________________________________________________________________________________
+inline void cppu_Bridge::acquire()
+{
+ if (1 == osl_incrementInterlockedCount( &nRef ))
+ {
+ if (bExportCpp2Uno)
+ {
+ uno_Mapping * pMapping = &aCpp2Uno;
+ uno_registerMapping( &pMapping, cppu_Bridge_free,
+ (uno_Environment *)pCppEnv, (uno_Environment *)pUnoEnv, 0 );
+ }
+ else
+ {
+ uno_Mapping * pMapping = &aUno2Cpp;
+ uno_registerMapping( &pMapping, cppu_Bridge_free,
+ (uno_Environment *)pUnoEnv, (uno_Environment *)pCppEnv, 0 );
+ }
+ }
+}
+//__________________________________________________________________________________________________
+inline void cppu_Bridge::release()
+{
+ if (! osl_decrementInterlockedCount( &nRef ))
+ {
+ uno_revokeMapping( bExportCpp2Uno ? &aCpp2Uno : &aUno2Cpp );
+ }
+}
+
+//##################################################################################################
+inline void SAL_CALL cppu_ext_getMapping(
+ uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo )
+{
+ OSL_ASSERT( ppMapping && pFrom && pTo );
+ if (ppMapping && pFrom && pTo && pFrom->pExtEnv && pTo->pExtEnv)
+ {
+ uno_Mapping * pMapping = 0;
+
+ if (0 == rtl_ustr_ascii_compare( pFrom->pTypeName->buffer, CPPU_CURRENT_LANGUAGE_BINDING_NAME ) &&
+ 0 == rtl_ustr_ascii_compare( pTo->pTypeName->buffer, UNO_LB_UNO ))
+ {
+ // ref count initially 1
+ pMapping = &(new cppu_Bridge( pFrom->pExtEnv, pTo->pExtEnv, sal_True ))->aCpp2Uno;
+ ::uno_registerMapping( &pMapping, cppu_Bridge_free,
+ (uno_Environment *)pFrom->pExtEnv,
+ (uno_Environment *)pTo->pExtEnv, 0 );
+ }
+ if (0 == rtl_ustr_ascii_compare( pTo->pTypeName->buffer, CPPU_CURRENT_LANGUAGE_BINDING_NAME ) &&
+ 0 == rtl_ustr_ascii_compare( pFrom->pTypeName->buffer, UNO_LB_UNO ))
+ {
+ // ref count initially 1
+ pMapping = &(new cppu_Bridge( pTo->pExtEnv, pFrom->pExtEnv, sal_False ))->aUno2Cpp;
+ ::uno_registerMapping( &pMapping, cppu_Bridge_free,
+ (uno_Environment *)pFrom->pExtEnv,
+ (uno_Environment *)pTo->pExtEnv, 0 );
+ }
+
+ if (*ppMapping)
+ (*(*ppMapping)->release)( *ppMapping );
+ *ppMapping = pMapping;
+ }
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))
+static ::rtl::OUString * s_pStaticOidPart = 0;
+#endif
+
+// environment init stuff
+//--------------------------------------------------------------------------------------------------
+inline const ::rtl::OUString & SAL_CALL cppu_cppenv_getStaticOIdPart()
+{
+#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))
+ static ::rtl::OUString * s_pStaticOidPart = 0;
+#endif
+ if (! s_pStaticOidPart)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! s_pStaticOidPart)
+ {
+ ::rtl::OUStringBuffer aRet( 64 );
+ aRet.appendAscii( RTL_CONSTASCII_STRINGPARAM("];") );
+ // pid
+ oslProcessInfo info;
+ info.Size = sizeof(oslProcessInfo);
+ if (::osl_getProcessInfo( 0, osl_Process_IDENTIFIER, &info ) == osl_Process_E_None)
+ {
+ aRet.append( (sal_Int64)info.Ident, 16 );
+ }
+ else
+ {
+ aRet.appendAscii( RTL_CONSTASCII_STRINGPARAM("unknown process id") );
+ }
+ // good guid
+ sal_uInt8 ar[16];
+ ::rtl_getGlobalProcessId( ar );
+ aRet.append( (sal_Unicode)';' );
+ for ( sal_Int32 i = 0; i < 16; ++i )
+ {
+ aRet.append( (sal_Int32)ar[i], 16 );
+ }
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))
+ s_pStaticOidPart = new ::rtl::OUString( aRet.makeStringAndClear() );
+#else
+ static ::rtl::OUString s_aStaticOidPart( aRet.makeStringAndClear() );
+ s_pStaticOidPart = &s_aStaticOidPart;
+#endif
+ }
+ }
+ return *s_pStaticOidPart;
+}
+// functions set at environment init
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_cppenv_computeObjectIdentifier(
+ uno_ExtEnvironment * pEnv, rtl_uString ** ppOId, void * pInterface )
+{
+ OSL_ENSHURE( pEnv && ppOId && pInterface, "### null ptr!" );
+ if (pEnv && ppOId && pInterface)
+ {
+ if (*ppOId)
+ {
+ rtl_uString_release( *ppOId );
+ *ppOId = 0;
+ }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xHome(
+ reinterpret_cast< ::com::sun::star::uno::XInterface * >( pInterface ),
+ ::com::sun::star::uno::UNO_QUERY );
+ OSL_ENSHURE( xHome.is(), "### query to XInterface failed!" );
+ if (xHome.is())
+ {
+ // interface
+ ::rtl::OUStringBuffer oid( 64 );
+ oid.append( (sal_Int64)xHome.get(), 16 );
+ oid.append( (sal_Unicode)';' );
+ // environment[context]
+ oid.append( ((uno_Environment *)pEnv)->pTypeName );
+ oid.append( (sal_Unicode)'[' );
+ oid.append( (sal_Int64)((uno_Environment *)pEnv)->pContext, 16 );
+ // process;good guid
+ oid.append( cppu_cppenv_getStaticOIdPart() );
+ ::rtl::OUString aRet( oid.makeStringAndClear() );
+ ::rtl_uString_acquire( *ppOId = aRet.pData );
+ }
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_cppenv_acquireInterface( uno_ExtEnvironment *, void * pCppI )
+{
+ reinterpret_cast< ::com::sun::star::uno::XInterface * >( pCppI )->acquire();
+}
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_cppenv_releaseInterface( uno_ExtEnvironment *, void * pCppI )
+{
+ reinterpret_cast< ::com::sun::star::uno::XInterface * >( pCppI )->release();
+}
+//--------------------------------------------------------------------------------------------------
+inline void SAL_CALL cppu_cppenv_initEnvironment( uno_Environment * pCppEnv )
+{
+ OSL_ENSHURE( pCppEnv->pExtEnv, "### expected extended environment!" );
+ OSL_ENSHURE( rtl_ustr_ascii_compare( pCppEnv->pTypeName->buffer, CPPU_CURRENT_LANGUAGE_BINDING_NAME ) == 0,
+ "### wrong environment type!" );
+ ((uno_ExtEnvironment *)pCppEnv)->computeObjectIdentifier = CPPU_CURRENT_NAMESPACE::cppu_cppenv_computeObjectIdentifier;
+ ((uno_ExtEnvironment *)pCppEnv)->acquireInterface = CPPU_CURRENT_NAMESPACE::cppu_cppenv_acquireInterface;
+ ((uno_ExtEnvironment *)pCppEnv)->releaseInterface = CPPU_CURRENT_NAMESPACE::cppu_cppenv_releaseInterface;
+}
+
+}
+
+#endif
diff --git a/bridges/inc/bridges/cpp_uno/type_misc.hxx b/bridges/inc/bridges/cpp_uno/type_misc.hxx
new file mode 100644
index 000000000000..ec863e4887de
--- /dev/null
+++ b/bridges/inc/bridges/cpp_uno/type_misc.hxx
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * $RCSfile: type_misc.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:47 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
+#define _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+
+
+/** Determines whether given type might relate or relates to an interface,
+ i.e. values of this type are interface or may contain interface(s).<br>
+ @param pTypeDescr type description of type
+ @return true if type might relate to an interface, false otherwise
+*/
+inline sal_Bool SAL_CALL cppu_relatesToInterface( typelib_TypeDescription * pTypeDescr )
+{
+ switch (pTypeDescr->eTypeClass)
+ {
+// case typelib_TypeClass_TYPEDEF:
+ case typelib_TypeClass_SEQUENCE:
+ {
+ switch (((typelib_IndirectTypeDescription *)pTypeDescr)->pType->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE:
+ case typelib_TypeClass_UNION: // might relate to interface
+ case typelib_TypeClass_ANY: // might relate to interface
+ return sal_True;
+ case typelib_TypeClass_SEQUENCE:
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType );
+ sal_Bool bRel = cppu_relatesToInterface( pTD );
+ TYPELIB_DANGER_RELEASE( pTD );
+ return bRel;
+ }
+ }
+ return sal_False;
+ }
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ // ...optimized... to avoid getDescription() calls!
+ typelib_CompoundTypeDescription * pComp = (typelib_CompoundTypeDescription *)pTypeDescr;
+ typelib_TypeDescriptionReference ** pTypes = pComp->ppTypeRefs;
+ for ( sal_Int32 nPos = pComp->nMembers; nPos--; )
+ {
+ switch (pTypes[nPos]->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE:
+ case typelib_TypeClass_UNION: // might relate to interface
+ case typelib_TypeClass_ANY: // might relate to interface
+ return sal_True;
+// case typelib_TypeClass_TYPEDEF:
+ case typelib_TypeClass_SEQUENCE:
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, pTypes[nPos] );
+ sal_Bool bRel = cppu_relatesToInterface( pTD );
+ TYPELIB_DANGER_RELEASE( pTD );
+ if (bRel)
+ return sal_True;
+ }
+ }
+ }
+ if (pComp->pBaseTypeDescription)
+ return cppu_relatesToInterface( (typelib_TypeDescription *)pComp->pBaseTypeDescription );
+ break;
+ }
+ case typelib_TypeClass_UNION: // might relate to interface
+ case typelib_TypeClass_ANY: // might relate to interface
+ case typelib_TypeClass_INTERFACE:
+ return sal_True;
+ }
+ return sal_False;
+}
+
+/** Determines whether given type is a cpp simple type, e.g. int, enum.<br>
+ @param pTypeDescr type description of type
+ @return true if type is a cpp simple type, false otherwise
+*/
+inline sal_Bool SAL_CALL cppu_isSimpleType( typelib_TypeDescription * pTypeDescr )
+{
+ return (pTypeDescr->eTypeClass <= typelib_TypeClass_ENUM &&
+ pTypeDescr->eTypeClass != typelib_TypeClass_STRING &&
+ pTypeDescr->eTypeClass != typelib_TypeClass_ANY &&
+ pTypeDescr->eTypeClass != typelib_TypeClass_TYPE);
+}
+
+#endif
diff --git a/bridges/inc/bridges/remote/bridgeimpl.hxx b/bridges/inc/bridges/remote/bridgeimpl.hxx
new file mode 100644
index 000000000000..15151185c74b
--- /dev/null
+++ b/bridges/inc/bridges/remote/bridgeimpl.hxx
@@ -0,0 +1,129 @@
+/*************************************************************************
+ *
+ * $RCSfile: bridgeimpl.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:47 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _BRIDGES_REMOTE_BRIDGEIMPL_HXX_
+#define _BRIDGES_REMOTE_BRIDGEIMPL_HXX_
+
+#include <osl/interlck.h>
+
+#include <uno/environment.h>
+
+#include <bridges/remote/context.h>
+#include <bridges/remote/remote.h>
+
+
+struct remote_BridgeImpl
+{
+ void (SAL_CALL * m_allThreadsAreGone ) ( uno_Environment * );
+ requestClientSideDispatcher m_sendRequest;
+ oslInterlockedCount m_nRemoteThreads;
+ sal_Bool m_bDisposed;
+ sal_Bool m_bReleaseStubsCalled;
+};
+
+namespace bridges_remote {
+
+ enum RemoteThreadCounter_HoldEnvWeak
+ {
+ RTC_HOLDENVWEAK = 0x1
+ };
+
+ class RemoteThreadCounter
+ {
+ public:
+ // performance optimization. In some cases, it is not necessary to acquire the
+ // environment.
+ RemoteThreadCounter( uno_Environment *pEnvRemote, RemoteThreadCounter_HoldEnvWeak value )
+ : m_pEnvRemote( pEnvRemote )
+ , m_bReleaseEnvironment( sal_False )
+ {
+ remote_Context *pContext = ((remote_Context *) m_pEnvRemote->pContext );
+ osl_incrementInterlockedCount( &( pContext->m_pBridgeImpl->m_nRemoteThreads ) );
+ }
+
+ RemoteThreadCounter( uno_Environment *pEnvRemote )
+ : m_pEnvRemote( pEnvRemote )
+ , m_bReleaseEnvironment( sal_True )
+ {
+ m_pEnvRemote->acquire( m_pEnvRemote );
+
+ remote_Context *pContext = ((remote_Context *) m_pEnvRemote->pContext );
+ osl_incrementInterlockedCount( &( pContext->m_pBridgeImpl->m_nRemoteThreads ) );
+ }
+
+ ~RemoteThreadCounter( )
+ {
+ remote_Context *pContext = ((remote_Context *) m_pEnvRemote->pContext );
+ if( 0 == osl_decrementInterlockedCount( &( pContext->m_pBridgeImpl->m_nRemoteThreads)) &&
+ pContext->m_pBridgeImpl->m_bDisposed &&
+ ! pContext->m_pBridgeImpl->m_bReleaseStubsCalled )
+ {
+ pContext->m_pBridgeImpl->m_allThreadsAreGone( m_pEnvRemote );
+ }
+ if( m_bReleaseEnvironment )
+ m_pEnvRemote->release( m_pEnvRemote );
+ }
+
+ sal_Bool m_bReleaseEnvironment;
+ uno_Environment *m_pEnvRemote;
+ };
+}
+
+#endif
diff --git a/bridges/inc/bridges/remote/connection.h b/bridges/inc/bridges/remote/connection.h
new file mode 100644
index 000000000000..32806c58e909
--- /dev/null
+++ b/bridges/inc/bridges/remote/connection.h
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * $RCSfile: connection.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:47 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _BRIDGES_REMOTE_CONNECTION_H_
+#define _BRIDGES_REMOTE_CONNECTION_H_
+#include <sal/types.h>
+
+struct remote_Connection
+{
+ void ( SAL_CALL * acquire ) ( remote_Connection *);
+
+ void ( SAL_CALL * release ) ( remote_Connection *);
+
+
+ /***
+ * reads nSize bytes from the connection. This method blocks, until
+ * all bytes are available or an error occurs.
+ * @return Number of bytes read.<br>
+ * If the return value is less than nSize, an unrecoverable
+ * i/o error has occured or the connection was closed.
+ *
+ ***/
+ sal_Int32 (SAL_CALL * read)(remote_Connection *, sal_Int8 *pDest, sal_Int32 nSize );
+
+ /***
+ * @return Number of bytes written.<br>
+ * if the return value is less than nSize an unrecoverable
+ * i/o error has occured or the connection was closed.
+ ***/
+ sal_Int32 (SAL_CALL * write)(remote_Connection *, const sal_Int8 *pSource, sal_Int32 nSize );
+
+ void ( SAL_CALL * flush ) ( remote_Connection * );
+
+ /***
+ * closes the connection. Any read or write operation after this call shall not be served
+ * anymore. Any ongoing read or write operation must return immeadiatly after this call.
+ * The implementation should cope with multiple calls to this method.
+ ***/
+ void (SAL_CALL * close) ( remote_Connection * );
+};
+
+#endif
diff --git a/bridges/inc/bridges/remote/context.h b/bridges/inc/bridges/remote/context.h
new file mode 100644
index 000000000000..31b2213f318f
--- /dev/null
+++ b/bridges/inc/bridges/remote/context.h
@@ -0,0 +1,263 @@
+/*************************************************************************
+ *
+ * $RCSfile: context.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _BRIDGES_REMOTE_CONTEXT_H_
+#define _BRIDGES_REMOTE_CONTEXT_H_
+#include <osl/interlck.h>
+#include <osl/conditn.h>
+
+#include <typelib/typedescription.h>
+
+#include <uno/environment.h>
+
+struct uno_Context
+{
+ void (SAL_CALL * acquire)( uno_Context *pContext );
+
+ void (SAL_CALL * release)( uno_Context *pContext);
+
+ void * (SAL_CALL *query ) ( uno_Context *pContext , rtl_uString *pId);
+};
+
+struct remote_Connection;
+struct remote_Context;
+struct remote_Interface;
+
+
+/*****
+ * @deprecated
+ ****/
+typedef void ( SAL_CALL * remote_createStubFunc ) (
+ remote_Interface **ppRemoteI,
+ rtl_uString *pOid ,
+ typelib_TypeDescriptionReference *pTypeRef,
+ uno_Environment *pEnvRemote );
+
+/***
+ * performs a query-interface for a certain interface via the remote connection !
+ *
+ * @param pEnvRemote The environment, that shall perform the call.
+ * @param ppRemoteI in/out parameter contains the interface returned by queryInterface
+ * @param pOid the oid of the 'ghost' object on which the call must be done.
+ ***/
+typedef void ( SAL_CALL * remote_getInstanceFunc ) (
+ uno_Environment *pEnvRemote,
+ remote_Interface **ppRemoteI,
+ rtl_uString *pOid,
+ typelib_TypeDescriptionReference *pInterfaceTypeRef);
+
+struct remote_InstanceProvider
+{
+ void (SAL_CALL * acquire ) ( remote_InstanceProvider * pProvider );
+ void (SAL_CALL * release ) ( remote_InstanceProvider * pProvider );
+ void (SAL_CALL * getInstance ) ( remote_InstanceProvider * pProvider ,
+ uno_Environment *pEnvRemote,
+ remote_Interface **ppRemoteI,
+ rtl_uString *pInstanceName,
+ typelib_InterfaceTypeDescription *pType
+ );
+};
+
+struct remote_DisposingListener
+{
+ void (SAL_CALL * acquire ) ( remote_DisposingListener * pProvider );
+ void (SAL_CALL * release ) ( remote_DisposingListener * pProvider );
+ void (SAL_CALL * disposing ) ( remote_DisposingListener * pProvider,
+ rtl_uString *pBridgeName );
+};
+
+
+/**
+ * Try to get an existing context characterized by the IDString. Each ID-String must
+ * uniquely charcterize a certain connection.
+ *
+ * @return 0 when such a context does not exist, otherwise
+ * a pointer to an acquired uno remote context
+ **/
+extern "C" SAL_DLLEXPORT remote_Context * SAL_CALL
+remote_getContext( rtl_uString *pIdString );
+
+/**
+ * Create an acquired remote context. The Context is weakly held by the context administration
+ * and can be accessed later through getRemoteContext() (using the same id-string).
+ *
+ * @param pIdString A string, that uniquely describes the connection. For e.g. a socket connection,
+ * host and port of the local and remote host should be in the string.
+ *
+ * @param pDescription
+ * Description of the connection, that may brought up to the user.
+ *
+ * @param pProtocol
+ * The protocol, that the environment uses for
+ * communicating with the remote process.
+ * The format of the protocol string is : "protocolname,para1=para1value,..."
+ * @return 0, when a context with this name already exists.
+ **/
+extern "C" SAL_DLLEXPORT remote_Context * SAL_CALL
+remote_createContext( remote_Connection *pConnection,
+ rtl_uString *pIdStr,
+ rtl_uString *pDescription,
+ rtl_uString *pProtocol,
+ remote_InstanceProvider *);
+
+const sal_Int32 REMOTE_CONTEXT_CREATE = 1;
+const sal_Int32 REMOTE_CONTEXT_DESTROY = 2;
+
+typedef void ( SAL_CALL * remote_contextListenerFunc ) (
+ void *pThis,
+ sal_Int32 nRemoteContextMode,
+ rtl_uString *sName,
+ rtl_uString *sDescription
+ );
+
+
+extern "C" SAL_DLLEXPORT void SAL_CALL
+remote_addContextListener( remote_contextListenerFunc listener, void *pObject );
+
+extern "C" SAL_DLLEXPORT void SAL_CALL
+remote_removeContextListener( remote_contextListenerFunc listener , void *pObject );
+
+/****
+ * @param pnStringCount out parameter. Contains the number of rtl_uStrings in the array
+ * @param memAlloc a memory allocation function for the array of pointers to rtl_uStrings
+ *
+ * @return array of rtl strings. The caller must call release on all rtl_uString s and must free
+ * the pointer array.
+ *
+ ***/
+extern "C" SAL_DLLEXPORT rtl_uString ** SAL_CALL
+remote_getContextList(
+ sal_Int32 *pnStringCount,
+ void * ( SAL_CALL * memAlloc ) ( sal_uInt32 nBytesToAlloc ) );
+
+
+struct remote_BridgeImpl;
+
+struct remote_Context
+{
+ struct uno_Context aBase;
+
+ /***
+ * These methods are implemented by context administration
+ ***/
+ void ( SAL_CALL * addDisposingListener ) ( remote_Context *,
+ remote_DisposingListener * );
+ void ( SAL_CALL * removeDisposingListener ) ( remote_Context *,
+ remote_DisposingListener * );
+ /***
+ * will be called by the environment when it gets disposed
+ ***/
+ void ( SAL_CALL * dispose ) ( remote_Context * );
+
+ /********
+ * see above declaration of remote_getInstanceFunc
+ * The method is set by the environment during environment initialization.
+ *******/
+ remote_getInstanceFunc getRemoteInstance;
+
+ /*******
+ * The protocol, that the environment uses for communicating with the remote process.
+ * The format of the protocol string is : "protocolname,para1=para1value,..."
+ * The parameters are protocol dependend
+ ******/
+ rtl_uString *m_pProtocol;
+
+ /****
+ * It may be the same as m_pName.
+ * Livetime is handled by the context administration.
+ ****/
+ rtl_uString *m_pDescription;
+
+ /****
+ * The name of this context at context administration.
+ * A string, that uniquely describes this environment.
+ * Livetime is handled by the context administration.
+ ****/
+ rtl_uString *m_pName;
+
+ /**
+ * GetInstance method is called every time when a remote call with an unknown oid comes in.
+ * Is usually called on server side, when the first client request comes in.
+ * Maybe 0. Livetime is handled by the context administration.
+ ***/
+ remote_InstanceProvider *m_pInstanceProvider;
+
+ /***
+ * The connection of this context.
+ * Livetime is handled by the context administration.
+ ***/
+ remote_Connection *m_pConnection;
+
+ /**
+ * Here arbitrary data may be stored. It may be used by a connection
+ * service to store environment specific data. The bridge does not
+ * use it.
+ **/
+ void *m_pAdditionalInformation;
+
+ /**
+ * here the bridge stores its private per environment data.
+ **/
+ struct remote_BridgeImpl *m_pBridgeImpl;
+};
+
+#endif
+
diff --git a/bridges/inc/bridges/remote/counter.hxx b/bridges/inc/bridges/remote/counter.hxx
new file mode 100644
index 000000000000..085fd1eb98d5
--- /dev/null
+++ b/bridges/inc/bridges/remote/counter.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * $RCSfile: counter.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _BRIDGES_REMOTE_COUNTER_H_
+#define _BRIDGES_REMOTE_COUNTER_H_
+#include <stdio.h>
+
+#ifdef DEBUG
+struct MyCounter
+{
+ MyCounter( sal_Char *pName ) :
+ m_pName ( pName ),
+ m_nCounter( 0 )
+ {
+ }
+ ~MyCounter()
+ {
+ if( m_nCounter ) {
+ printf( "%s : %d left\n", m_pName , m_nCounter );
+ }
+ }
+ void acquire()
+ { m_nCounter ++; }
+ void release()
+ { m_nCounter --; }
+
+
+ sal_Int32 m_nCounter;
+ sal_Char *m_pName;
+};
+#endif
+
+#endif
diff --git a/bridges/inc/bridges/remote/helper.hxx b/bridges/inc/bridges/remote/helper.hxx
new file mode 100644
index 000000000000..c6eff3044dff
--- /dev/null
+++ b/bridges/inc/bridges/remote/helper.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * $RCSfile: helper.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <bridges/remote/bridgeimpl.hxx>
+
+namespace bridges_remote
+{
+ void SAL_CALL remote_createStub (
+ remote_Interface **ppRemoteI,
+ rtl_uString *pOid ,
+ typelib_TypeDescriptionReference *pType,
+ uno_Environment *pEnvRemote );
+
+ void SAL_CALL remote_retrieveOidFromProxy(
+ remote_Interface *pRemtoeI,
+ rtl_uString **ppOid );
+
+ void SAL_CALL remote_sendQueryInterface(
+ uno_Environment *pEnvRemote,
+ remote_Interface **ppRemoteI,
+ rtl_uString *pOid ,
+ typelib_TypeDescriptionReference *pType
+ );
+}
diff --git a/bridges/inc/bridges/remote/mapping.hxx b/bridges/inc/bridges/remote/mapping.hxx
new file mode 100644
index 000000000000..4dd83c3c6c2f
--- /dev/null
+++ b/bridges/inc/bridges/remote/mapping.hxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * $RCSfile: mapping.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _BRIDGES_REMOTE_MAPPING_HXX_
+#define _BRIDGES_REMOTE_MAPPING_HXX_
+
+#include <osl/interlck.h>
+#include <rtl/ustring.hxx>
+
+#include <typelib/typedescription.h>
+
+#include <bridges/remote/remote.h>
+
+typedef struct _uno_Environment uno_Environment;
+
+namespace bridges_remote
+{
+ class RemoteMapping :
+ public remote_Mapping
+ {
+ public:
+ RemoteMapping( uno_Environment *pEnvUno ,
+ uno_Environment *pEnvRemote,
+ uno_MapInterfaceFunc func ,
+ const ::rtl::OUString sPurpose);
+ ~RemoteMapping();
+
+ static void SAL_CALL thisFree( uno_Mapping * pMapping );
+ static void SAL_CALL remoteToUno(
+ uno_Mapping *pMapping,
+ void **ppOut,
+ void *pInterface,
+ typelib_InterfaceTypeDescription *pInterfaceTypeDescr );
+
+ static void SAL_CALL unoToRemote(
+ uno_Mapping *pMapping,
+ void **ppOut,
+ void *pInterface,
+ typelib_InterfaceTypeDescription *pInterfaceTypeDescr );
+
+ static void SAL_CALL thisAcquire( uno_Mapping *pMapping );
+ static void SAL_CALL thisRelease( uno_Mapping *pMapping );
+
+ oslInterlockedCount m_nRef;
+ ::rtl::OUString m_sPurpose;
+ };
+
+}
+#endif
diff --git a/bridges/inc/bridges/remote/proxy.hxx b/bridges/inc/bridges/remote/proxy.hxx
new file mode 100644
index 000000000000..b970c9bf02f8
--- /dev/null
+++ b/bridges/inc/bridges/remote/proxy.hxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * $RCSfile: proxy.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <osl/interlck.h>
+
+#include <uno/environment.h>
+#include <uno/dispatcher.h>
+#include <uno/mapping.hxx>
+
+#include <bridges/remote/remote.h>
+
+namespace bridges_remote {
+
+void SAL_CALL remote_release( void * );
+class Remote2UnoProxy :
+ public uno_Interface
+{
+public:
+ Remote2UnoProxy(
+ remote_Interface *pRemoteI,
+ rtl_uString *pOid,
+ typelib_InterfaceTypeDescription *pType ,
+ uno_Environment *pEnvUno,
+ uno_Environment *pEnvRemote
+ );
+
+ ~Remote2UnoProxy();
+
+ static void SAL_CALL thisAcquire( uno_Interface * );
+ static void SAL_CALL thisRelease( uno_Interface * );
+ static void SAL_CALL thisDispatch( uno_Interface * pUnoI,
+ typelib_TypeDescription * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException );
+ static void SAL_CALL thisFree( uno_ExtEnvironment *pEnvUno, void *pProxy );
+
+private:
+ ::rtl::OUString m_sOid;
+ typelib_InterfaceTypeDescription *m_pType;
+ remote_Interface *m_pRemoteI;
+ uno_Environment *m_pEnvUno;
+ uno_Environment *m_pEnvRemote;
+ ::com::sun::star::uno::Mapping m_mapRemote2Uno;
+ ::com::sun::star::uno::Mapping m_mapUno2Remote;
+
+ oslInterlockedCount m_nRef;
+};
+
+}
diff --git a/bridges/inc/bridges/remote/remote.h b/bridges/inc/bridges/remote/remote.h
new file mode 100644
index 000000000000..f0d42d43d177
--- /dev/null
+++ b/bridges/inc/bridges/remote/remote.h
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * $RCSfile: remote.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _BRIDGES_REMOTE_REMOTE_H
+#define _BRIDGES_REMOTE_REMOTE_H
+#include <uno/mapping.h>
+#include <uno/any2.h>
+
+#include <typelib/typedescription.h>
+
+#define UNO_LB_REMOTE "remote"
+
+#define CORBA_STRING8_NAME "com.sun.star.corba.CorbaString8"
+#define CORBA_STRING8_NAME_LENGTH (sizeof(CORBA_STRING8_NAME)-1)
+
+#define CORBA_UNION_NAME "com.sun.star.corba.CorbaUnion"
+#define CORBA_UNION_NAME_LENGTH (sizeof(CORBA_UNION_NAME)-1)
+
+#define REMOTE_MARSHALED_MSGHDR_SIZE 12
+#define REMOTE_RELEASE_METHOD_INDEX 2
+#define REMOTE_RELEASE_METHOD_NAME "release"
+
+#define CURRENT_IIOP_PROTOCOL_MAJOR 1
+#define CURRENT_IIOP_PROTOCOL_MINOR 2
+
+struct remote_Interface;
+
+typedef void (SAL_CALL * remote_DispatchMethod)( remote_Interface * pRemoteI,
+ typelib_TypeDescription * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException );
+
+
+typedef void ( SAL_CALL * requestClientSideDispatcher ) (
+ uno_Environment *pEnvRemote,
+ typelib_TypeDescription * pMemberType,
+ rtl_uString *pOid,
+ typelib_InterfaceTypeDescription *pInterfaceType,
+ void *pReturn,
+ void *ppArgs[],
+ uno_Any **ppException );
+
+struct remote_Interface
+{
+ void (SAL_CALL * acquire)( remote_Interface * pInterface );
+
+ void (SAL_CALL * release)( remote_Interface * pInterface );
+
+ remote_DispatchMethod pDispatcher;
+};
+
+
+struct remote_Mapping
+{
+ uno_Mapping aBase;
+ uno_Environment *pEnvRemote;
+ uno_Environment *pEnvUno;
+};
+
+#endif
diff --git a/bridges/inc/bridges/remote/remote.hxx b/bridges/inc/bridges/remote/remote.hxx
new file mode 100644
index 000000000000..0e4aa39cd32a
--- /dev/null
+++ b/bridges/inc/bridges/remote/remote.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * $RCSfile: remote.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _BRIDGES_REMOTE_REMOTE_HXX_
+#define _BRIDGES_REMOTE_REMOTE_HXX_
+#include <list>
+
+#include <osl/mutex.hxx>
+#include <osl/conditn.h>
+#include <osl/interlck.h>
+
+#include <vos/thread.hxx>
+
+#include <uno/environment.h>
+
+#include <bridges/remote/remote.h>
+#include <bridges/remote/connection.h>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace bridges_remote {
+
+class Remote2RemoteStub :
+ public remote_Interface
+{
+public:
+ Remote2RemoteStub(rtl_uString *pOid,
+ typelib_InterfaceTypeDescription *pType,
+ uno_Environment *pEnvRemote,
+ requestClientSideDispatcher dispatch );
+ ~Remote2RemoteStub();
+
+ static void SAL_CALL thisAcquire( remote_Interface *pThis );
+ static void SAL_CALL thisRelease( remote_Interface *pThis );
+ static void SAL_CALL thisDispatch( remote_Interface * pUnoI,
+ typelib_TypeDescription * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException );
+ static void SAL_CALL thisFree( uno_ExtEnvironment *pEnvRemote , void * );
+
+ void releaseRemote();
+public:
+ ::rtl::OUString m_sOid;
+ typelib_InterfaceTypeDescription *m_pType;
+ oslInterlockedCount m_nRef;
+ uno_Environment *m_pEnvRemote;
+ requestClientSideDispatcher m_dispatch;
+};
+
+}
+#endif
diff --git a/bridges/inc/bridges/remote/stub.hxx b/bridges/inc/bridges/remote/stub.hxx
new file mode 100644
index 000000000000..dd068b3e3aa8
--- /dev/null
+++ b/bridges/inc/bridges/remote/stub.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * $RCSfile: stub.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <bridges/remote/remote.hxx>
+
+#include <uno/dispatcher.h>
+#include <uno/mapping.hxx>
+
+namespace bridges_remote {
+
+class Uno2RemoteStub :
+ public remote_Interface
+{
+public:
+ Uno2RemoteStub( uno_Interface *pUnoI,
+ rtl_uString *pOid,
+ typelib_InterfaceTypeDescription *pType,
+ uno_Environment *pEnvUno,
+ uno_Environment *pEnvRemote );
+ ~Uno2RemoteStub();
+
+ static void SAL_CALL thisAcquire( remote_Interface *pThis );
+ static void SAL_CALL thisRelease( remote_Interface *pThis );
+ static void SAL_CALL thisDispatch( remote_Interface * pUnoI,
+ typelib_TypeDescription * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException );
+ static void SAL_CALL thisFree( uno_ExtEnvironment * pEnvRemote, void *pThis );
+
+public:
+ ::rtl::OUString m_sOid;
+ typelib_InterfaceTypeDescription *m_pType;
+ uno_Interface *m_pUnoI;
+ oslInterlockedCount m_nRef;
+
+ uno_Environment *m_pEnvUno;
+ uno_Environment *m_pEnvRemote;
+ ::com::sun::star::uno::Mapping m_mapRemote2Uno;
+ ::com::sun::star::uno::Mapping m_mapUno2Remote;
+};
+
+}
diff --git a/bridges/prj/d.lst b/bridges/prj/d.lst
new file mode 100644
index 000000000000..d4137b83a3ee
--- /dev/null
+++ b/bridges/prj/d.lst
@@ -0,0 +1,26 @@
+mkdir: %_DEST%\inc%_EXT%\bridges
+mkdir: %_DEST%\inc%_EXT%\bridges\remote
+
+..\inc\bridges\remote\connection.h %_DEST%\inc%_EXT%\bridges\remote\connection.h
+..\inc\bridges\remote\context.h %_DEST%\inc%_EXT%\bridges\remote\context.h
+..\inc\bridges\remote\remote.h %_DEST%\inc%_EXT%\bridges\remote\remote.h
+
+..\%__SRC%\lib\irmcxt* %_DEST%\lib%_EXT%\*
+..\%__SRC%\lib\librmcxt* %_DEST%\lib%_EXT%\*
+..\%__SRC%\bin\rmcxt* %_DEST%\bin%_EXT%\*
+
+..\%__SRC%\lib\libremote_uno* %_DEST%\lib%_EXT%\libremote_uno*
+..\%__SRC%\bin\remote_uno* %_DEST%\bin%_EXT%\remote_uno*
+..\%__SRC%\lib\liburp_uno* %_DEST%\lib%_EXT%\liburp_uno*
+..\%__SRC%\bin\urp_uno* %_DEST%\bin%_EXT%\urp_uno*
+..\%__SRC%\lib\libjava_uno* %_DEST%\lib%_EXT%\libjava_uno*
+..\%__SRC%\bin\java_uno* %_DEST%\bin%_EXT%\java_uno*
+..\%__SRC%\lib\java_uno.jar %_DEST%\bin%_EXT%\java_uno.jar
+
+..\version.mk %_DEST%\inc%_EXT%\bridges\version.mk
+
+..\%__SRC%\bin\prot_uno_uno.* %_DEST%\bin%_EXT%\prot_uno_uno.*
+..\%__SRC%\bin\msci_uno.* %_DEST%\bin%_EXT%\msci_uno.*
+..\%__SRC%\lib\libprot_uno_uno.* %_DEST%\lib%_EXT%\libprot_uno_uno.*
+..\%__SRC%\lib\libgcc2_uno.* %_DEST%\lib%_EXT%\libgcc2_uno.*
+..\%__SRC%\lib\libsunpro5_uno.* %_DEST%\lib%_EXT%\libsunpro5_uno.*
diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/call.s b/bridges/source/cpp_uno/cc50_solaris_intel/call.s
new file mode 100644
index 000000000000..826bf03139d2
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_intel/call.s
@@ -0,0 +1,212 @@
+ .globl privateSnippetExecutor
+ .align 4
+privateSnippetExecutor:
+.L21:
+ subl $32, %esp
+ / original %ebx, %eax, %ecx saved by jmp snippet into -12, -16, -20 resp
+ movl %esp, -24(%ebp)
+ movl %ecx, -28(%ebp)
+
+ / real code
+ movl %ebp, %eax
+ addl $4, %eax
+ pushl %eax
+ pushl %ebx / nTablePos
+
+ / set ebx to GOT
+.L_GOT_BEGIN:
+ call .L_GOT_END
+.L_GOT_END:
+ popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-.L_GOT_END],%ebx
+
+ / call collector
+ call __1cHsunpro5Pcpp_vtable_call6Fippv_v_@PLT
+.L22:
+ movl -28(%ebp), %ecx
+ cmp $0, %ecx / float
+ jne .L23
+ flds -8(%ebp)
+ jmp .L29
+.L23:
+ cmp $1, %ecx / double
+ jne .L24
+ fldl -8(%ebp)
+ jmp .L29
+.L24:
+ cmp $2, %ecx / longlong
+ jne .L25
+ movl -4(%ebp), %edx
+ movl -8(%ebp), %eax
+ jmp .L29
+.L25:
+ cmp $3, %ecx / long
+ jne .L28
+ movl -8(%ebp), %eax
+ jmp .L29
+.L28:
+ movl -16(%ebp), %eax
+.L29:
+ movl -12(%ebp), %ebx
+ movl -20(%ebp), %ecx
+ movl %ebp, %esp
+ popl %ebp
+ ret
+ .type privateSnippetExecutor, @function
+ .size privateSnippetExecutor, .-privateSnippetExecutor
+
+ .globl privateSnippetExceptionHandler
+privateSnippetExceptionHandler:
+ movl -12(%ebp), %ebx
+ movl -16(%ebp), %eax
+ movl -20(%ebp), %ecx
+ movl -24(%ebp), %esp
+ call __1cG__CrunMex_rethrow_q6F_v_@PLT
+ ret
+ .type privateSnippetExceptionHandler, @function
+ .size privateSnippetExceptionHandler, .-privateSnippetExceptionHandler
+
+ .align 4
+ .globl callVirtualMethod
+callVirtualMethod:
+ pushl %ebp
+ movl %esp, %ebp
+ subl $24, %esp
+ movl %edx, -4(%ebp)
+ movl %ecx, -8(%ebp)
+ movl %eax, -12(%ebp)
+ movl %esp, -16(%ebp)
+ movl %ebx, -20(%ebp)
+
+ / set ebx to GOT
+.L_GOT_BEGIN_2:
+ call .L_GOT_END_2
+.L_GOT_END_2:
+ popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-.L_GOT_END_2],%ebx
+.callBeginPosition:
+ movl 28(%ebp), %eax
+ movl %eax, %edx
+ dec %edx
+ shl $2, %edx
+ add 24(%ebp), %edx
+.copyLong:
+ movl 0(%edx), %ecx
+ sub $4, %edx
+ push %ecx
+ dec %eax
+ jne .copyLong
+.doCall:
+ movl 8(%ebp), %edx
+ movl 0(%edx), %edx
+ movl 12(%ebp), %eax
+ add $2, %eax
+ shl $2, %eax
+ add %eax, %edx
+ movl 0(%edx), %edx
+
+ call *%edx
+
+.callVirtualMethodExceptionPosition:
+ / handle returns
+ movl 20(%ebp), %ecx
+
+ / byte types
+ cmp $2, %ecx / typelib_TypeClass_BOOLEAN
+ je .handleByte
+ cmp $3, %ecx
+ je .handleByte / typelib_TypeClass_BYTE
+
+ / half word types
+ cmp $4, %ecx / typelib_TypeClass_SHORT
+ je .handleShort
+ cmp $5, %ecx / typelib_TypeClass_UNSIGNED_SHORT
+ je .handleShort
+
+ / word types
+ cmp $6, %ecx / typelib_TypeClass_LONG
+ je .handleWord
+ cmp $7, %ecx / typelib_TypeClass_UNSIGNED_LONG
+ je .handleWord
+ cmp $1, %ecx / typelib_TypeClass_CHAR (wchar_t)
+ je .handleWord
+ cmp $15, %ecx / typelib_TypeClass_ENUM
+ je .handleWord
+
+ / double word types
+ cmp $8, %ecx / typelib_TypeClass_HYPER
+ je .handleDoubleWord
+ cmp $9, %ecx / typelib_TypeClass_UNSIGNED_HYPER
+ je .handleDoubleWord
+
+ / float
+ cmp $10, %ecx / typelib_TypeClass_FLOAT
+ je .handleFloat
+
+ / double
+ cmp $11, %ecx / typelib_TypeClass_DOUBLE
+ je .handleDouble
+
+ / default: return void
+ jmp .doRestore
+.handleByte:
+ movl 16(%ebp), %ecx
+ movb %al, 0(%ecx)
+ jmp .doRestore
+.handleShort:
+ movl 16(%ebp), %ecx
+ movw %ax, 0(%ecx)
+ jmp .doRestore
+.handleWord:
+ movl 16(%ebp), %ecx
+ movl %eax, 0(%ecx)
+ jmp .doRestore
+.handleDoubleWord:
+ movl 16(%ebp), %ecx
+ movl %eax, 0(%ecx)
+ movl %edx, 4(%ecx)
+ jmp .doRestore
+.handleFloat:
+ movl 16(%ebp), %ecx
+ fstps 0(%ecx)
+ jmp .doRestore
+.handleDouble:
+ movl 16(%ebp), %ecx
+ fstpl 0(%ecx)
+ jmp .doRestore
+.doRestore:
+ movl -4(%ebp), %edx
+ movl -8(%ebp), %ecx
+ movl -12(%ebp), %eax
+ movl -20(%ebp), %ebx
+ movl %ebp, %esp
+ popl %ebp
+ ret
+ .type callVirtualMethod, @function
+ .size callVirtualMethod, .-callVirtualMethod
+
+ .globl callVirtualMethodExceptionHandler
+callVirtualMethodExceptionHandler:
+ movl -4(%ebp), %edx
+ movl -8(%ebp), %ecx
+ movl -12(%ebp), %eax
+ movl -16(%ebp), %esp
+ movl -20(%ebp), %ebx
+ call __1cG__CrunMex_rethrow_q6F_v_@PLT
+ ret
+
+ .type callVirtualMethodExceptionHandler, @function
+ .size callVirtualMethodExceptionHandler, .-callVirtualMethodExceptionHandler
+
+
+ .section .exception_ranges,"aw"
+ .align 4
+
+ .4byte .L21@rel
+ .4byte .L22-.L21
+ .4byte privateSnippetExceptionHandler-.L21
+ .zero 8
+ .4byte .callBeginPosition@rel
+ .4byte .callVirtualMethodExceptionPosition-.callBeginPosition
+ .4byte callVirtualMethodExceptionHandler-.callBeginPosition
+ .zero 8
diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/cc50_solaris_intel.hxx b/bridges/source/cpp_uno/cc50_solaris_intel/cc50_solaris_intel.hxx
new file mode 100644
index 000000000000..25d89a8538ed
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_intel/cc50_solaris_intel.hxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * $RCSfile: cc50_solaris_intel.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+#include <typeinfo>
+
+typedef struct _uno_Any uno_Any;
+typedef struct _uno_Mapping uno_Mapping;
+
+// private C50 structures and functions
+namespace __Crun
+{
+ struct static_type_info
+ {
+ char* m_pClassName;
+ int m_nSkip1; // must be 0
+ void* m_pMagic; // points to some magic data
+ int m_nMagic[ 4 ];
+ int m_nSkip2[2]; // must be 0
+ };
+ void* ex_alloc(unsigned);
+ void ex_throw( void*, const static_type_info*, void(*)(void*));
+ void* ex_get();
+ void ex_rethrow_q();
+}
+
+namespace __Cimpl
+{
+ const char* ex_name();
+}
+
+extern "C" void _ex_register( void*, int );
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//##################################################################################################
+//#### exceptions ##################################################################################
+//##################################################################################################
+
+void cc50_solaris_intel_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
+void cc50_solaris_intel_fillUnoException( void*, const char*, uno_Any*, uno_Mapping * pCpp2Uno );
+
+}
+
diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/cpp2uno.cxx b/bridges/source/cpp_uno/cc50_solaris_intel/cpp2uno.cxx
new file mode 100644
index 000000000000..25d1d87391a5
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_intel/cpp2uno.cxx
@@ -0,0 +1,637 @@
+/*************************************************************************
+ *
+ * $RCSfile: cpp2uno.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define LEAK_STATIC_DATA
+// #define TRACE(x) OSL_TRACE(x)
+#define TRACE(x)
+
+#include <alloca.h>
+#include <stl/list>
+#include <stl/map>
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
+#include <typelib/typedescription.hxx>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#include <bridges/cpp_uno/bridge.hxx>
+#endif
+#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
+#include <bridges/cpp_uno/type_misc.hxx>
+#endif
+
+#include "cc50_solaris_intel.hxx"
+
+using namespace com::sun::star::uno;
+using namespace std;
+using namespace osl;
+using namespace rtl;
+
+extern "C"
+{
+ void privateSnippetExecutor();
+}
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//==================================================================================================
+static inline typelib_TypeClass cpp2uno_call(
+ cppu_cppInterfaceProxy * pThis,
+ const typelib_TypeDescription * pMemberTypeDescr,
+ typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
+ sal_Int32 nParams, typelib_MethodParameter * pParams,
+ void ** pCallStack,
+ sal_Int64 * pRegisterReturn /* space for register return */ )
+{
+ // pCallStack: [return ptr], this, params
+ char * pCppStack = (char *)(pCallStack +1);
+
+ // return
+ typelib_TypeDescription * pReturnTypeDescr = 0;
+ if (pReturnTypeRef)
+ TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
+
+ void * pUnoReturn = 0;
+ void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
+
+ if (pReturnTypeDescr)
+ {
+ if (cppu_isSimpleType( pReturnTypeDescr ))
+ {
+ pUnoReturn = pRegisterReturn; // direct way for simple types
+ }
+ else // complex return via ptr (pCppReturn)
+ {
+ pCppReturn = *(void**)pCppStack;
+ pCppStack += sizeof( void* );
+ pUnoReturn = (cppu_relatesToInterface( pReturnTypeDescr )
+ ? alloca( pReturnTypeDescr->nSize )
+ : pCppReturn); // direct way
+ }
+ }
+ // pop this
+ pCppStack += sizeof( void* );
+
+ // stack space
+ OSL_ENSHURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
+ // parameters
+ void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
+ void ** pCppArgs = pUnoArgs + nParams;
+ // indizes of values this have to be converted (interface conversion cpp<=>uno)
+ sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams));
+ // type descriptions for reconversions
+ typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
+
+ sal_Int32 nTempIndizes = 0;
+
+ for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
+ {
+ const typelib_MethodParameter & rParam = pParams[nPos];
+ typelib_TypeDescription * pParamTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
+
+ if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr )) // value
+ {
+ pCppArgs[ nPos ] = pUnoArgs[ nPos ] = pCppStack;
+ switch (pParamTypeDescr->eTypeClass)
+ {
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ case typelib_TypeClass_DOUBLE:
+ pCppStack += sizeof(sal_Int32); // extra long
+ }
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ else // ptr to complex value | ref
+ {
+ pCppArgs[nPos] = *(void **)pCppStack;
+
+ if (! rParam.bIn) // is pure out
+ {
+ // uno out is unconstructed mem!
+ pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
+ pTempIndizes[nTempIndizes] = nPos;
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ // is in/inout
+ else if (cppu_relatesToInterface( pParamTypeDescr ))
+ {
+ uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
+ *(void **)pCppStack, pParamTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ else // direct way
+ {
+ pUnoArgs[nPos] = *(void **)pCppStack;
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ }
+ pCppStack += sizeof(sal_Int32); // standard parameter length
+ }
+
+ // ExceptionHolder
+ uno_Any aUnoExc; // Any will be constructed by callee
+ uno_Any * pUnoExc = &aUnoExc;
+
+ // invoke uno dispatch call
+ (*pThis->pUnoI->pDispatcher)( pThis->pUnoI, pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
+
+ // in case no exception occured...
+ if (pUnoExc)
+ {
+ // destruct temporary in/inout params
+ for ( ; nTempIndizes--; )
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+
+ if (pParams[nIndex].bIn) // is in/inout => was constructed
+ uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 );
+ TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
+ }
+ if (pReturnTypeDescr)
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
+
+ cc50_solaris_intel_raiseException( &aUnoExc, &pThis->pBridge->aUno2Cpp ); // has to destruct the any
+ // is here for dummy
+ return typelib_TypeClass_VOID;
+ }
+ else // else no exception occured...
+ {
+ // temporary params
+ for ( ; nTempIndizes--; )
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+ typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
+
+ if (pParams[nIndex].bOut) // inout/out
+ {
+ // convert and assign
+ uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
+ uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+ }
+ // destroy temp uno param
+ uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
+
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ // return
+ if (pCppReturn) // has complex return
+ {
+ if (pUnoReturn != pCppReturn) // needs reconversion
+ {
+ uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+ // destroy temp uno return
+ uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
+ }
+ // complex return ptr is set to eax
+ *(void **)pRegisterReturn = pCppReturn;
+ }
+ if (pReturnTypeDescr)
+ {
+ typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
+ return eRet;
+ }
+ else
+ return typelib_TypeClass_VOID;
+ }
+}
+
+
+//==================================================================================================
+static inline typelib_TypeClass cpp_mediate(
+ sal_Int32 nVtableCall,
+ void ** pCallStack,
+ sal_Int64 * pRegisterReturn /* space for register return */ )
+{
+ OSL_ENSHURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" );
+
+ // pCallStack: this, params
+ // _this_ ptr is patched cppu_Interface object
+ cppu_cppInterfaceProxy * pCppI = NULL;
+ if( nVtableCall & 0x80000000 )
+ {
+ nVtableCall &= 0x7fffffff;
+ pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*(pCallStack +2);
+ }
+ else
+ pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*(pCallStack +1);
+
+ typelib_InterfaceTypeDescription * pTypeDescr = pCppI->pTypeDescr;
+
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex,
+ "### illegal vtable index!" );
+ if (nVtableCall >= pTypeDescr->nMapFunctionIndexToMemberIndex)
+ {
+ throw RuntimeException( OUString::createFromAscii("illegal vtable index!"), (XInterface *)pCppI );
+ }
+
+ // determine called method
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
+ sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nVtableCall];
+ OSL_ENSHURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
+
+ TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
+
+ typelib_TypeClass eRet;
+ switch (aMemberDescr.get()->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nVtableCall)
+ {
+ // is GET method
+ eRet = cpp2uno_call(
+ pCppI, aMemberDescr.get(),
+ ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
+ 0, 0, // no params
+ pCallStack, pRegisterReturn );
+ }
+ else
+ {
+ // is SET method
+ typelib_MethodParameter aParam;
+ aParam.pTypeRef =
+ ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
+ aParam.bIn = sal_True;
+ aParam.bOut = sal_False;
+
+ eRet = cpp2uno_call(
+ pCppI, aMemberDescr.get(),
+ 0, // indicates void return
+ 1, &aParam,
+ pCallStack, pRegisterReturn );
+ }
+ break;
+ }
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ // is METHOD
+ switch (nVtableCall)
+ {
+ // standard XInterface vtable calls
+ case 1: // acquire()
+ pCppI->acquireProxy(); // non virtual call!
+ eRet = typelib_TypeClass_VOID;
+ break;
+ case 2: // release()
+ pCppI->releaseProxy(); // non virtual call!
+ eRet = typelib_TypeClass_VOID;
+ break;
+ case 0: // queryInterface() opt
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pCallStack[3] )->getTypeLibType() );
+ OSL_ASSERT( pTD );
+
+ XInterface * pInterface = 0;
+ (*pCppI->pBridge->pCppEnv->getRegisteredInterface)(
+ pCppI->pBridge->pCppEnv,
+ (void **)&pInterface, pCppI->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
+
+ if (pInterface)
+ {
+ uno_any_construct( reinterpret_cast< uno_Any * >( pCallStack[1] ),
+ &pInterface, pTD, cpp_acquire );
+ pInterface->release();
+ TYPELIB_DANGER_RELEASE( pTD );
+ *(void **)pRegisterReturn = pCallStack[1];
+ eRet = typelib_TypeClass_ANY;
+ break;
+ }
+ TYPELIB_DANGER_RELEASE( pTD );
+ } // else perform queryInterface()
+ default:
+ eRet = cpp2uno_call(
+ pCppI, aMemberDescr.get(),
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
+ pCallStack, pRegisterReturn );
+ }
+ break;
+ }
+ default:
+ {
+ throw RuntimeException( OUString::createFromAscii("no member description found!"), (XInterface *)pCppI );
+ // is here for dummy
+ eRet = typelib_TypeClass_VOID;
+ }
+ }
+
+ return eRet;
+}
+
+
+//==================================================================================================
+class MediateClassData
+{
+public:
+ struct ClassDataBuffer
+ {
+ void** m_pVTable;
+
+ ~ClassDataBuffer();
+ };
+private:
+
+ map< OUString, ClassDataBuffer* > m_aClassData;
+ Mutex m_aMutex;
+
+ void createVTable( ClassDataBuffer*, typelib_InterfaceTypeDescription* );
+public:
+ const ClassDataBuffer* getClassData( typelib_InterfaceTypeDescription* );
+
+ MediateClassData() {}
+ ~MediateClassData();
+};
+//__________________________________________________________________________________________________
+
+MediateClassData::ClassDataBuffer::~ClassDataBuffer()
+{
+ delete m_pVTable;
+}
+
+//__________________________________________________________________________________________________
+MediateClassData::~MediateClassData()
+{
+ TRACE( "> calling ~MediateClassData(): freeing mediate vtables... <\n" );
+
+ // this MUST be the absolute last one which is called!
+ for ( map< OUString, ClassDataBuffer* >::iterator iPos( m_aClassData.begin() ); iPos != m_aClassData.end(); ++iPos )
+ {
+ // todo
+// delete (*iPos).second;
+ }
+}
+
+//__________________________________________________________________________________________________
+
+const MediateClassData::ClassDataBuffer* MediateClassData::getClassData( typelib_InterfaceTypeDescription* pType )
+{
+ MutexGuard aGuard( m_aMutex );
+
+ map< OUString, ClassDataBuffer* >::iterator element = m_aClassData.find( pType->aBase.pTypeName );
+ if( element != m_aClassData.end() )
+ return (*element).second;
+
+ ClassDataBuffer* pBuffer = new ClassDataBuffer();
+ createVTable( pBuffer, pType );
+ m_aClassData[ pType->aBase.pTypeName ] = pBuffer;
+ return pBuffer;
+}
+
+//==================================================================================================
+void cpp_vtable_call( int nTableEntry, void** pCallStack )
+{
+ cpp_mediate( nTableEntry, pCallStack, (sal_Int64*)(pCallStack - 3) );
+}
+
+enum SpecialReturnType { ReturnVoid, ReturnFloat, ReturnDouble, ReturnLong, ReturnLongLong };
+
+//__________________________________________________________________________________________________
+void MediateClassData::createVTable( ClassDataBuffer* pBuffer, typelib_InterfaceTypeDescription* pType )
+{
+ // get all member functions
+ list< SpecialReturnType > aSpecialReturn;
+ list< sal_Bool > aComplexReturn;
+
+ for( int n = 0; n < pType->nAllMembers; n++ )
+ {
+ typelib_TypeDescription* pMember = NULL;
+ TYPELIB_DANGER_GET( &pMember, pType->ppAllMembers[n] );
+ if( pMember->eTypeClass == typelib_TypeClass_INTERFACE_ATTRIBUTE )
+ {
+ typelib_TypeDescription * pRetTD = 0;
+ TYPELIB_DANGER_GET( &pRetTD, ((typelib_InterfaceAttributeTypeDescription *)pMember)->pAttributeTypeRef );
+ // get method
+ switch( pRetTD->eTypeClass )
+ {
+ case typelib_TypeClass_FLOAT:
+ aSpecialReturn.push_back( ReturnFloat );
+ break;
+ case typelib_TypeClass_DOUBLE:
+ aSpecialReturn.push_back( ReturnDouble );
+ break;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ aSpecialReturn.push_back( ReturnLongLong );
+ break;
+ default:
+ aSpecialReturn.push_back( ReturnLong );
+ break;
+ }
+ aComplexReturn.push_back( !cppu_isSimpleType( pRetTD ) );
+ // set method
+ if( ! ((typelib_InterfaceAttributeTypeDescription*)pMember)->bReadOnly )
+ {
+ aSpecialReturn.push_back( ReturnVoid );
+ aComplexReturn.push_back( sal_False );
+ }
+ TYPELIB_DANGER_RELEASE( pRetTD );
+ }
+ else
+ {
+ typelib_TypeDescription * pRetTD = 0;
+ TYPELIB_DANGER_GET( &pRetTD, ((typelib_InterfaceMethodTypeDescription *)pMember)->pReturnTypeRef );
+ switch( pRetTD->eTypeClass )
+ {
+ case typelib_TypeClass_FLOAT:
+ aSpecialReturn.push_back( ReturnFloat );
+ break;
+ case typelib_TypeClass_DOUBLE:
+ aSpecialReturn.push_back( ReturnDouble );
+ break;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ aSpecialReturn.push_back( ReturnLongLong );
+ break;
+ case typelib_TypeClass_VOID:
+ aSpecialReturn.push_back( ReturnVoid );
+ break;
+ default:
+ aSpecialReturn.push_back( ReturnLong );
+ break;
+ }
+ aComplexReturn.push_back( !cppu_isSimpleType( pRetTD ) );
+ TYPELIB_DANGER_RELEASE( pRetTD );
+ }
+ TYPELIB_DANGER_RELEASE( pMember );
+ }
+
+ const int nSnippetSize = 256;
+ int nSize = aSpecialReturn.size();
+ char * pSpace = (char *)rtl_allocateMemory( ((nSize+3)*sizeof(void *)) + (nSize * nSnippetSize) );
+ pBuffer->m_pVTable = (void**)pSpace;
+
+ char * pCode = pSpace + ((nSize+3)*sizeof(void *));
+ void ** pvft = (void **)pSpace;
+ pvft[0] = NULL; // RTTI
+ pvft[1] = NULL; // null
+ pvft[2] = NULL; // destructor
+
+ // setup vft and code
+ for ( sal_Int32 nPos = 0; nPos < nSize; ++nPos )
+ {
+ unsigned char * codeSnip =
+ (unsigned char*)((unsigned char *)pCode + (nPos*nSnippetSize));
+ SpecialReturnType eRet = aSpecialReturn.front();
+ aSpecialReturn.pop_front();
+ long nTablePos = nPos;
+ if( aComplexReturn.front() )
+ nTablePos |= 0x80000000;
+ aComplexReturn.pop_front();
+ pvft[nPos+3] = codeSnip;
+ /*generate this code:
+ * pushl %ebp
+ * movl %esp, %ebp
+ * movl %eax, -20(%esp)
+ * movl %ebx, -16(%esp)
+ * movl %ecx, -24(%esp)
+ * movl $nTablePos, %ebx
+ * movl $<return type>, %ecx
+ * jmp privateSnippetExecutor
+ */
+ *codeSnip++ = 0x55; // pushl %ebp
+ *codeSnip++ = 0x8b; // movl %esp, %ebp
+ *codeSnip++ = 0xec;
+ *codeSnip++ = 0x89; // movl %eax, -16(%ebp)
+ *codeSnip++ = 0x45;
+ *codeSnip++ = 0xf0;
+ *codeSnip++ = 0x89; // movl %ebx, -12(%ebp)
+ *codeSnip++ = 0x5d;
+ *codeSnip++ = 0xf4;
+ *codeSnip++ = 0x89; // movl %ecx, -20(%ebp)
+ *codeSnip++ = 0x4d;
+ *codeSnip++ = 0xec;
+
+ *codeSnip++ = 0xbb; // movl $nTablePos, %ebx
+ *((long*)codeSnip) = nTablePos;
+ codeSnip += sizeof(long);
+ *codeSnip++ = 0xb9; // movl <return type>, %ecx
+ switch( eRet )
+ {
+ case ReturnFloat: *((long*)codeSnip) = 0;break;
+ case ReturnDouble: *((long*)codeSnip) = 1;break;
+ case ReturnLong: *((long*)codeSnip) = 3;break;
+ case ReturnLongLong: *((long*)codeSnip) = 2;break;
+ case ReturnVoid:
+ default: *((long*)codeSnip) = 4;break;
+ }
+ codeSnip += sizeof(long);
+ *codeSnip++ = 0xe9; // jmp privateSnippetExecutor
+ *((long*)codeSnip) = ((unsigned char *)privateSnippetExecutor) - codeSnip - sizeof(long);
+ codeSnip += sizeof(long);
+ }
+}
+
+//==================================================================================================
+void SAL_CALL cppu_cppInterfaceProxy_patchVtable(
+ XInterface * pCppI, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ static MediateClassData * s_pMediateClassData = 0;
+ if (! s_pMediateClassData)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pMediateClassData)
+ {
+#ifdef LEAK_STATIC_DATA
+ s_pMediateClassData = new MediateClassData();
+#else
+ static MediateClassData s_aMediateClassData;
+ s_pMediateClassData = &s_aMediateClassData;
+#endif
+ }
+ }
+ *(const void **)pCppI = s_pMediateClassData->getClassData( pTypeDescr )->m_pVTable + 1;
+}
+
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pCppEnv )
+{
+ CPPU_CURRENT_NAMESPACE::cppu_cppenv_initEnvironment( pCppEnv );
+}
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_ext_getMapping(
+ uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo )
+{
+ CPPU_CURRENT_NAMESPACE::cppu_ext_getMapping( ppMapping, pFrom, pTo );
+}
+
diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx b/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx
new file mode 100644
index 000000000000..f5903a694a83
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx
@@ -0,0 +1,453 @@
+/*************************************************************************
+ *
+ * $RCSfile: except.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <dlfcn.h>
+#include <new.h>
+#include <typeinfo>
+#include <stl/list>
+#include <stl/map>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#include <bridges/cpp_uno/bridge.hxx>
+#endif
+#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
+#include <typelib/typedescription.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+
+#include "cc50_solaris_intel.hxx"
+
+// need a += operator for OString and sal_Char
+namespace rtl
+{
+ inline OString& operator+=( OString& rString, sal_Char cAdd )
+ {
+ sal_Char add[2];
+ add[0] = cAdd;
+ add[1] = 0;
+ return rString += add;
+ }
+}
+
+using namespace std;
+using namespace osl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//==================================================================================================
+static OString toUNOname( const OString & rRTTIname )
+{
+ OString aRet;
+
+ const sal_Char* pRTTI = rRTTIname.getStr();
+ const sal_Char* pOrg = pRTTI;
+ const sal_Char* pLast = pRTTI;
+
+ while( 1 )
+ {
+ if( *pRTTI == ':' || *pRTTI == 0 )
+ {
+ if( aRet.getLength() )
+ aRet += ".";
+ aRet += rRTTIname.copy( pLast - pOrg, pRTTI - pLast );
+ while( *pRTTI == ':' )
+ pRTTI++;
+ pLast = pRTTI;
+ if( ! *pRTTI )
+ break;
+ }
+ else
+ pRTTI++;
+ }
+
+ return aRet;
+}
+//==================================================================================================
+static OString toRTTIname( const OString & rUNOname )
+{
+ OString aRet;
+
+ int nTokens = rUNOname.getTokenCount( '.' );
+ for( int i = 0; i < nTokens; i++ )
+ {
+ if( i > 0 )
+ aRet += "::";
+ aRet += rUNOname.getToken( i, '.' );
+ }
+
+ return aRet;
+}
+//==================================================================================================
+
+static int replaceQdDdD( const OString& rIn, OString& rOutdD, OString& rOutdDdD )
+{
+ int nRet = 0;
+ int nLen = rIn.getLength(), i, n;
+ rOutdD = OString();
+ rOutdDdD = OString();
+ for( i = 0, n = 0; ( i = rIn.indexOf( 'Q', i ) ) != -1 && i < nLen; i++ )
+ {
+ rOutdD += rIn.copy( n, i-n+1 );
+ rOutdDdD += rIn.copy( n, i-n+1 );
+ n = i+1;
+ rOutdD += "dD";
+ rOutdDdD += "dDdD";
+ nRet++;
+ }
+ rOutdD += rIn.copy( n );
+ rOutdDdD += rIn.copy( n );
+ return nRet;
+}
+
+static OString toRTTIsymbolname( const OString & rRTTIname )
+{
+ if( ! rRTTIname.getLength() )
+ return OString();
+
+ OString aRet;
+ OString aPrefix;
+
+ int nUnoTokens = rRTTIname.getTokenCount( ':' );
+ int nAdjust = 0;
+ for( int i = 0; i < nUnoTokens; i++ )
+ {
+ OString aToken( rRTTIname.getToken( i, ':' ) );
+ int nBytes = aToken.getLength();
+ if( nBytes )
+ {
+ OString aAdd;
+ if( nBytes > 25 )
+ {
+ aAdd += (sal_Char)( nBytes/26 + 'a' );
+ aAdd += (sal_Char)( nBytes % 26 + 'A' );
+ }
+ else
+ aAdd += (sal_Char)( nBytes + 'A' );
+ aRet += aAdd;
+ // special case "Q"
+ if( ( ( nBytes % 26 ) +'A' ) == 'Q' )
+ {
+ aRet += "dD";
+ nAdjust += 2;
+ }
+
+ OString adD, adDdD;
+ int nRepl = replaceQdDdD( aToken, adD, adDdD );
+ if( nUnoTokens == 1 )
+ {
+ // must replace "Q" by "QdD"
+ aRet += adD;
+ nAdjust += 2* nRepl;
+ }
+ else
+ {
+ // must replace "Q" by "QdDdD"
+ aRet += adDdD;
+ nAdjust += 4* nRepl;
+ }
+
+ if( i < nUnoTokens - 1 )
+ {
+ aPrefix += aAdd;
+ // must replace "Q" by "QdD"
+ aPrefix += adD;
+ }
+ }
+ }
+ aRet += '_';
+
+ if( aPrefix.getLength() )
+ {
+ int nBytes = aRet.getLength() - nAdjust + 10;
+ if( nBytes > 25 )
+ {
+ aPrefix += (sal_Char)( nBytes/26 + 'a' );
+ aPrefix += (sal_Char)( nBytes % 26 + 'A' );
+ }
+ else
+ aPrefix += (sal_Char)( nBytes + 'A' );
+
+
+ aRet = "__1c" + aPrefix + "__RTTI__1n" + aRet + "_";
+ }
+ else
+ aRet = "__RTTI__1n"+aRet;
+
+ return aRet;
+}
+
+//##################################################################################################
+//#### RTTI simulation #############################################################################
+//##################################################################################################
+
+class RTTIHolder
+{
+ static std::map< OString, void* > aAllRTTI;
+public:
+ static void* getRTTI( const OString& rTypename );
+ static void* getRTTI_UnoName( const OString& rUnoTypename )
+ { return getRTTI( toRTTIname( rUnoTypename ) ); }
+
+ static void* insertRTTI( const OString& rTypename );
+ static void* insertRTTI_UnoName( const OString& rTypename )
+ { return insertRTTI( toRTTIname( rTypename ) ); }
+
+ // rSuperTypename MUST exist !!!
+ static void* insertRTTI( const OString& rTypename, const OString& rSuperTypename );
+ static void* insertRTTI_UnoNames( const OString& rTypename, const OString& rSuperTypename )
+ { return insertRTTI( toRTTIname( rTypename ), toRTTIname( rSuperTypename ) ); }
+
+};
+
+std::map< OString, void* > RTTIHolder::aAllRTTI;
+
+void* RTTIHolder::getRTTI( const OString& rTypename )
+{
+ std::map< OString, void* >::iterator element;
+
+ element = aAllRTTI.find( rTypename );
+ if( element != aAllRTTI.end() )
+ return (*element).second;
+ // create new rtti
+ // first look for existing type info function
+ static void* pMain = dlopen( NULL, RTLD_NOW );
+
+ void* pSymbol = dlsym( pMain, toRTTIsymbolname( rTypename ).getStr() );
+ if( pSymbol )
+ {
+ // there exists type info, use it (otherwise it will not be equal
+ // since addresses - not contents - are matched in RTTI compare)
+ aAllRTTI[ rTypename ] = pSymbol;
+ return pSymbol;
+ }
+ // no type found
+ return NULL;
+}
+
+static long nMagicId = 1;
+
+void* RTTIHolder::insertRTTI( const OString& rTypename )
+{
+ void** pRTTI = new void*[ 19 ];
+ memset( pRTTI, 0, 19*sizeof( void* ) );
+ pRTTI[ 0 ] = (void*)strdup( rTypename.getStr() );
+ pRTTI[ 2 ] = (void*)(7*sizeof(void*));
+ pRTTI[ 3 ] = (void*)nMagicId++;
+ pRTTI[ 4 ] = (void*)nMagicId++;
+ pRTTI[ 5 ] = (void*)nMagicId++;
+ pRTTI[ 6 ] = (void*)nMagicId++;
+
+ pRTTI[ 9 ] = pRTTI[ 3 ];
+ pRTTI[ 10 ] = pRTTI[ 4 ];
+ pRTTI[ 11 ] = pRTTI[ 5 ];
+ pRTTI[ 12 ] = pRTTI[ 6 ];
+ pRTTI[ 13 ] = (void*)0x80000000;
+
+ aAllRTTI[ rTypename ] = (void*)pRTTI;
+ return pRTTI;
+}
+
+void* RTTIHolder::insertRTTI( const OString& rTypename, const OString& rSuperTypename )
+{
+ OSL_ENSHURE( ! getRTTI( rTypename ), "insert RTTI called on already existing type" );
+
+ void** pBaseRTTI = (void**)getRTTI( rSuperTypename );
+ OSL_ENSHURE( pBaseRTTI, "insert RTTI called with nonexisting supertype" );
+
+ std::list< void* > aSuperTypes;
+
+ void** pTypeList = pBaseRTTI + 2 + ((int)pBaseRTTI[2] / sizeof(void*));
+ while( *pTypeList != (void*)0x80000000 )
+ aSuperTypes.push_back( *pTypeList++ );
+
+ void** pRTTI = new void*[ 8 + aSuperTypes.size()+1 ];
+ memset( pRTTI, 0, (8 + aSuperTypes.size()+1 + 5)*sizeof(void*));
+ pRTTI[ 0 ] = (void*)strdup( rTypename.getStr() );
+ pRTTI[ 2 ] = (void*)(7*sizeof(void*));
+ pRTTI[ 3 ] = (void*)nMagicId++;
+ pRTTI[ 4 ] = (void*)nMagicId++;
+ pRTTI[ 5 ] = (void*)nMagicId++;
+ pRTTI[ 6 ] = (void*)nMagicId++;
+
+ int nPos = 9;
+ while( aSuperTypes.size() )
+ {
+ pRTTI[ nPos++ ] = aSuperTypes.front();
+ aSuperTypes.pop_front();
+ }
+ pRTTI[ nPos++ ] = 0;
+ pRTTI[ nPos++ ] = pRTTI[ 3 ];
+ pRTTI[ nPos++ ] = pRTTI[ 4 ];
+ pRTTI[ nPos++ ] = pRTTI[ 5 ];
+ pRTTI[ nPos++ ] = pRTTI[ 6 ];
+ pRTTI[ nPos ] = (void*)0x80000000;
+
+ aAllRTTI[ rTypename ] = pRTTI;
+ return pRTTI;
+}
+
+//--------------------------------------------------------------------------------------------------
+
+static void* generateRTTI( typelib_CompoundTypeDescription * pCompTypeDescr )
+{
+ OString aCompTypeName( OUStringToOString( pCompTypeDescr->aBase.pTypeName, RTL_TEXTENCODING_ASCII_US ) );
+
+ void* pRTTI = RTTIHolder::getRTTI_UnoName( aCompTypeName );
+ if( pRTTI )
+ return pRTTI;
+
+ if( ! pCompTypeDescr->pBaseTypeDescription )
+ // this is a base type
+ return RTTIHolder::insertRTTI_UnoName( aCompTypeName );
+ // generate super rtti if necessary
+ void* pSuperRTTI = generateRTTI( pCompTypeDescr->pBaseTypeDescription );
+ OSL_ENSHURE( pSuperRTTI, "could not generate RTTI for supertype!" );
+
+ return RTTIHolder::insertRTTI_UnoNames(
+ aCompTypeName,
+ OUStringToOString( pCompTypeDescr->pBaseTypeDescription->aBase.pTypeName, RTL_TEXTENCODING_ASCII_US )
+ );
+}
+
+//--------------------------------------------------------------------------------------------------
+
+static std::map< void*, typelib_TypeDescription* > aExceptionMap;
+
+static void deleteException( void* pExc )
+{
+ std::map< void*, typelib_TypeDescription* >::iterator element =
+ aExceptionMap.find( pExc );
+ if( element != aExceptionMap.end() )
+ {
+ typelib_TypeDescription* pType = (*element).second;
+ aExceptionMap.erase( pExc );
+ uno_destructData( pExc, pType, cpp_release );
+ typelib_typedescription_release( pType );
+ }
+}
+
+//__________________________________________________________________________________________________
+
+//##################################################################################################
+//#### exported ####################################################################################
+//##################################################################################################
+
+
+void cc50_solaris_intel_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
+{
+ // construct cpp exception object
+ typelib_TypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
+
+ void * pCppExc = __Crun::ex_alloc( pTypeDescr->nSize ); // will be released in generated dtor
+ uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
+
+ // destruct uno exception
+ uno_any_destruct( pUnoExc, 0 );
+
+ // a must be
+ OSL_ENSHURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" );
+
+ typelib_CompoundTypeDescription * pCompTypeDescr = (typelib_CompoundTypeDescription *)pTypeDescr;
+ void* pRTTI = generateRTTI( pCompTypeDescr );
+
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+
+ __Crun::ex_throw( pCppExc, (const __Crun::static_type_info*)pRTTI, deleteException );
+}
+
+void cc50_solaris_intel_fillUnoException(
+ void* pCppExc,
+ const char* pInfo,
+ uno_Any* pExc,
+ uno_Mapping * pCpp2Uno )
+{
+ OUString aName( OStringToOUString( toUNOname( pInfo ), RTL_TEXTENCODING_ASCII_US ) );
+ typelib_TypeDescription * pExcTypeDescr = 0;
+ typelib_typedescription_getByName(
+ &pExcTypeDescr,
+ aName.pData );
+ if (pExcTypeDescr)
+ {
+ // construct cpp exception any
+ Any aAny( pCppExc, pExcTypeDescr ); // const_cast
+ typelib_typedescription_release( pExcTypeDescr );
+ // construct uno exception any
+ typelib_TypeDescription* pAnyDescr = 0;
+ getCppuType( (const Any *)0 ).getDescription( &pAnyDescr );
+ uno_copyAndConvertData( pExc, &aAny, pAnyDescr, pCpp2Uno );
+ typelib_typedescription_release( pAnyDescr );
+ }
+}
+
+}
+
diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/makefile.mk b/bridges/source/cpp_uno/cc50_solaris_intel/makefile.mk
new file mode 100644
index 000000000000..edc4410ba4b9
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_intel/makefile.mk
@@ -0,0 +1,110 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=cppu
+TARGET=sunpro5_uno
+LIBTARGET=no
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(COM)$(CPU)" == "C50I"
+
+CFLAGS += -O5 -xO5
+
+SLOFILES= \
+ $(SLO)$/cpp2uno.obj \
+ $(SLO)$/uno2cpp.obj \
+ $(SLO)$/except.obj \
+ $(SLO)$/call.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1IMPLIB= i$(TARGET)
+
+SHL1OBJS= \
+ $(SLO)$/cpp2uno.obj \
+ $(SLO)$/uno2cpp.obj \
+ $(SLO)$/except.obj \
+ $(SLO)$/call.obj
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(SALLIB)
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+$(SLO)$/call.obj: call.s
+ CC -c -o $(SLO)$/call.o call.s ; touch $(SLO)$/call.obj
+
diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/uno2cpp.cxx b/bridges/source/cpp_uno/cc50_solaris_intel/uno2cpp.cxx
new file mode 100644
index 000000000000..11f2899b22f3
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_intel/uno2cpp.cxx
@@ -0,0 +1,444 @@
+/*************************************************************************
+ *
+ * $RCSfile: uno2cpp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <alloca.h>
+#include <stl/map>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#include <bridges/cpp_uno/bridge.hxx>
+#endif
+#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
+#include <bridges/cpp_uno/type_misc.hxx>
+#endif
+
+#include "cc50_solaris_intel.hxx"
+
+using namespace std;
+using namespace osl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+extern "C" {
+ void callVirtualMethod(
+ void * pThis,
+ sal_Int32 nVtableIndex,
+ void * pRegisterReturn,
+ typelib_TypeClass eReturnType,
+ sal_Int32 * pStackLongs,
+ sal_Int32 nStackLongs
+ );
+}
+
+//==================================================================================================
+static inline void cpp_call( cppu_unoInterfaceProxy * pThis,
+ sal_Int32 nVtableCall,
+ typelib_TypeDescriptionReference * pReturnTypeRef,
+ sal_Int32 nParams, typelib_MethodParameter * pParams,
+ sal_Int32 nExceptions, typelib_TypeDescriptionReference ** ppExceptionRefs,
+ void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
+{
+ // max space for: [complex ret ptr], values|ptr ...
+ char * pCppStack = (char *)alloca( ((nParams+3) * sizeof(sal_Int64)) );
+ char * pCppStackStart = pCppStack;
+
+ // return
+ typelib_TypeDescription * pReturnTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
+ OSL_ENSHURE( pReturnTypeDescr, "### expected return type description!" );
+
+ void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
+
+ long return_buffer[64];
+ void * pReturnSpace = 0;
+
+ if (pReturnTypeDescr)
+ {
+ if (cppu_isSimpleType( pReturnTypeDescr ))
+ {
+ pCppReturn = pUnoReturn; // direct way for simple types
+ }
+ else
+ {
+ // complex return via ptr
+ pCppReturn = *(void **)pCppStack =
+ (cppu_relatesToInterface( pReturnTypeDescr )
+ ? (pReturnTypeDescr->nSize > sizeof(return_buffer) ? (pReturnSpace = rtl_allocateMemory( pReturnTypeDescr->nSize )) : return_buffer)
+ : pUnoReturn); // direct way
+ pCppStack += sizeof(void *);
+ }
+ }
+ // push this
+ *(void**)pCppStack = pThis->pCppI;
+ pCppStack += sizeof( void* );
+
+ const int nMaxParams = 32;
+ // args
+ void * args_buffer[3 * nMaxParams];
+ void ** pCppArgs = (void **)(nParams > nMaxParams ? rtl_allocateMemory( 3 * sizeof(void *) * nParams ) : args_buffer);
+ // indizes of values this have to be converted (interface conversion cpp<=>uno)
+ sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
+ // type descriptions for reconversions
+ typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
+
+ sal_Int32 nTempIndizes = 0;
+
+ const int nTempBufferSize = 256;
+ sal_Int32 nTempBufferPos = 0;
+ long params_buffer[nTempBufferSize];
+
+ for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
+ {
+ const typelib_MethodParameter & rParam = pParams[nPos];
+ typelib_TypeDescription * pParamTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
+
+ if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr ))
+ {
+ pCppArgs[ nPos ] = pCppStack;
+ uno_copyAndConvertData( pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+
+ switch (pParamTypeDescr->eTypeClass)
+ {
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ case typelib_TypeClass_DOUBLE:
+ pCppStack += sizeof(sal_Int32); // extra long
+ }
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ else // ptr to complex value | ref
+ {
+ if (! rParam.bIn) // is pure out
+ {
+ // cpp out is constructed mem, uno out is not!
+ if (pParamTypeDescr->nSize > (sizeof(long) * (nTempBufferSize - nTempBufferPos)))
+ {
+ uno_constructData(
+ *(void **)pCppStack = pCppArgs[nPos] = rtl_allocateMemory( pParamTypeDescr->nSize ),
+ pParamTypeDescr );
+ pTempIndizes[nTempIndizes] = nPos | 0x80000000; // default constructed for cpp call
+ }
+ else
+ {
+ uno_constructData(
+ *(void **)pCppStack = pCppArgs[nPos] = (params_buffer + nTempBufferPos),
+ pParamTypeDescr );
+ pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
+ nTempBufferPos += (pParamTypeDescr->nSize / sizeof(long)) +1;
+ }
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ // is in/inout
+ else if (cppu_relatesToInterface( pParamTypeDescr ))
+ {
+ if (pParamTypeDescr->nSize > (sizeof(long)*(nTempBufferSize - nTempBufferPos)))
+ {
+ uno_copyAndConvertData(
+ *(void **)pCppStack = pCppArgs[nPos] = rtl_allocateMemory( pParamTypeDescr->nSize ),
+ pUnoArgs[nPos], pParamTypeDescr, &pThis->pBridge->aUno2Cpp );
+ pTempIndizes[nTempIndizes] = nPos | 0x80000000; // has to be reconverted
+ }
+ else
+ {
+ uno_copyAndConvertData(
+ *(void **)pCppStack = pCppArgs[nPos] = (params_buffer + nTempBufferPos),
+ pUnoArgs[nPos], pParamTypeDescr, &pThis->pBridge->aUno2Cpp );
+ pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
+ nTempBufferPos += (pParamTypeDescr->nSize / sizeof(long)) +1;
+ }
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ else // direct way
+ {
+ *(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ }
+ pCppStack += sizeof(sal_Int32); // standard parameter length
+ }
+
+ try
+ {
+ int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32);
+ if( nStackLongs & 1 )
+ // stack has to be 8 byte aligned
+ nStackLongs++;
+
+ callVirtualMethod(
+ pThis->pCppI,
+ nVtableCall,
+ pCppReturn,
+ pReturnTypeDescr->eTypeClass,
+ (sal_Int32 *)pCppStackStart,
+ nStackLongs
+ );
+
+ // NO exception occured...
+ *ppUnoExc = 0;
+
+ // reconvert temporary params
+ for ( ; nTempIndizes--; )
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+ sal_Bool bAllocated = (nIndex & 0x80000000) != 0;
+ nIndex &= 0x7fffffff;
+ typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
+
+ if (pParams[nIndex].bIn)
+ {
+ if (pParams[nIndex].bOut) // inout
+ {
+ uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
+ uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ }
+ }
+ else // pure out
+ {
+ uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ }
+ // destroy temp cpp param => cpp: every param was constructed
+ uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
+
+ if (bAllocated)
+ rtl_freeMemory( pCppArgs[nIndex] );
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ // return value
+ if (pCppReturn && pUnoReturn != pCppReturn)
+ {
+ uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
+ }
+ }
+ catch( ... )
+ {
+ // get exception
+ cc50_solaris_intel_fillUnoException( __Crun::ex_get(),
+ __Cimpl::ex_name(),
+ *ppUnoExc,
+ &pThis->pBridge->aCpp2Uno );
+ // temporary params
+ for ( ; nTempIndizes--; )
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+ sal_Bool bAllocated = (nIndex & 0x80000000) != 0;
+ nIndex &= 0x7fffffff;
+ // destroy temp cpp param => cpp: every param was constructed
+ uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
+ if (bAllocated)
+ rtl_freeMemory( pCppArgs[nIndex] );
+ TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
+ }
+ // return type
+ if (pReturnTypeDescr)
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
+ }
+
+ if (pCppArgs != (void **)args_buffer)
+ rtl_freeMemory( pCppArgs );
+ if (pReturnSpace)
+ rtl_freeMemory( pReturnSpace );
+}
+
+//==================================================================================================
+void SAL_CALL cppu_unoInterfaceProxy_dispatch(
+ uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ // is my surrogate
+ cppu_unoInterfaceProxy * pThis = (cppu_unoInterfaceProxy *)pUnoI;
+ typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
+
+ switch (pMemberDescr->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ // determine vtable call index
+ sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
+ OSL_ENSHURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
+
+ sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
+
+ typelib_TypeDescriptionReference * pRuntimeExcRef = 0;
+
+ if (pReturn)
+ {
+ // dependent dispatch
+ cpp_call( pThis, nVtableCall,
+ ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
+ 0, 0, // no params
+ 1, &pRuntimeExcRef, // RuntimeException
+ pReturn, pArgs, ppException );
+ }
+ else
+ {
+ // is SET
+ typelib_MethodParameter aParam;
+ aParam.pTypeRef =
+ ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
+ aParam.bIn = sal_True;
+ aParam.bOut = sal_False;
+
+ typelib_TypeDescriptionReference * pReturnTypeRef = 0;
+ OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
+ typelib_typedescriptionreference_new(
+ &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
+
+ // dependent dispatch
+ cpp_call( pThis, nVtableCall +1, // get, then set method
+ pReturnTypeRef,
+ 1, &aParam,
+ 1, &pRuntimeExcRef,
+ pReturn, pArgs, ppException );
+
+ typelib_typedescriptionreference_release( pReturnTypeRef );
+ }
+
+ break;
+ }
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ // determine vtable call index
+ sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
+ OSL_ENSHURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
+
+ sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
+
+ switch (nVtableCall)
+ {
+ // standard calls
+ case 1: // acquire uno interface
+ (*pUnoI->acquire)( pUnoI );
+ *ppException = 0;
+ break;
+ case 2: // release uno interface
+ (*pUnoI->release)( pUnoI );
+ *ppException = 0;
+ break;
+ case 0: // queryInterface() opt
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
+ OSL_ASSERT( pTD );
+
+ uno_Interface * pInterface = 0;
+ (*pThis->pBridge->pUnoEnv->getRegisteredInterface)(
+ pThis->pBridge->pUnoEnv,
+ (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
+
+ if (pInterface)
+ {
+ uno_any_construct( reinterpret_cast< uno_Any * >( pReturn ), &pInterface, pTD, 0 );
+ (*pInterface->release)( pInterface );
+ TYPELIB_DANGER_RELEASE( pTD );
+ *ppException = 0;
+ break;
+ }
+ TYPELIB_DANGER_RELEASE( pTD );
+ } // else perform queryInterface()
+ default:
+ // dependent dispatch
+ cpp_call( pThis, nVtableCall,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nExceptions,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->ppExceptions,
+ pReturn, pArgs, ppException );
+ }
+ break;
+ }
+ default:
+ {
+ ::com::sun::star::uno::RuntimeException aExc;
+ aExc.Message = OUString::createFromAscii("illegal member type description!");
+ aExc.Context = pThis->pCppI;
+
+ typelib_TypeDescription * pTD = 0;
+ const Type & rExcType = ::getCppuType( (const ::com::sun::star::uno::RuntimeException *)0 );
+ TYPELIB_DANGER_GET( &pTD, rExcType.getTypeLibType() );
+ uno_any_construct( *ppException, &aExc, pTD, 0 );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ }
+}
+
+}
+
diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/call.s b/bridges/source/cpp_uno/cc50_solaris_sparc/call.s
new file mode 100644
index 000000000000..b8fa60af3989
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_sparc/call.s
@@ -0,0 +1,165 @@
+.global callVirtualMethod
+.type callVirtualMethod,2
+callVirtualMethod:
+ ! allocate FIRST stack to have own local registers
+ save %sp, -96, %sp
+ ! copy in to out parameters for second stackframe
+ mov %i0, %o0
+ mov %i1, %o1
+ mov %i2, %o2
+ mov %i3, %o3
+ mov %i4, %o4
+ mov %i5, %o5
+
+ ! decide wether there are more than 6 parameter
+ mov -96, %l3 ! default stack space
+ subcc %i5, 6, %l5
+ ble allocateSecondStack
+ nop
+ sll %l5, 2, %l5
+ sub %l3, %l5, %l3
+allocateSecondStack:
+ save %sp, %l3, %sp ! allocate new stack
+ ! copy stack longs if necessary
+ subcc %i5, 6, %l5
+ ble copyRegisters
+ nop
+
+ ! prepare source location
+ add %i4, 24, %l4
+
+ ! prepare real stack
+ add %sp, 92, %l3
+
+copyLong:
+ ld [%l4+0], %l0
+ st %l0, [%l3]
+ add %l4, 4, %l4
+ add %l3, 4, %l3
+ deccc %l5
+ bne copyLong
+ nop
+copyRegisters:
+ mov %i5, %l5
+ mov %i4, %l4
+
+ ld [%l4], %o0
+ add %l4, 4, %l4
+ deccc %l5
+ ble doCall
+
+ ld [%l4], %o1
+ add %l4, 4, %l4
+ deccc %l5
+ ble doCall
+
+ ld [%l4], %o2
+ add %l4, 4, %l4
+ deccc %l5
+ ble doCall
+
+ ld [%l4], %o3
+ add %l4, 4, %l4
+ deccc %l5
+ ble doCall
+
+ ld [%l4], %o4
+ add %l4, 4, %l4
+ deccc %l5
+ ble doCall
+
+ ld [%l4], %o5
+ add %l4, 4, %l4
+
+ ! prepare complex return pointer
+ st %i2, [%sp+64]
+doCall:
+ ! get virtual table entry
+ mov %i1, %l1
+ add %l1, 2, %l1
+ sll %l1, 2, %l1
+ ld [%i0], %l3
+ add %l3, %l1, %l1
+ ld [%l1], %l0
+ jmpl %l0,%o7
+ nop
+.global callVirtualMethodExceptionHandler
+.type callVirtualMethodExceptionHandler,2
+callVirtualMethodExceptionHandler:
+ ! handle returns
+
+ !byte types
+ subcc %i3, 2, %l3 ! typelib_TypeClass_BOOLEAN
+ be handleByte
+ subcc %i3, 3, %l3 ! typelib_TypeClass_BYTE
+ be handleByte
+
+ ! half word types
+ subcc %i3, 4, %l3 ! typelib_TypeClass_SHORT
+ be handleShort
+ subcc %i3, 5, %l3 ! typelib_TypeClass_UNSIGNED_SHORT
+ be handleShort
+ subcc %i3, 1, %l3 ! typelib_TypeClass_CHAR (sal_Unicode==sal_uInt16)
+ be handleShort
+
+ ! word types
+ subcc %i3, 6, %l3 ! typelib_TypeClass_LONG
+ be handleWord
+ subcc %i3, 7, %l3 ! typelib_TypeClass_UNSIGNED_LONG
+ be handleWord
+ subcc %i3, 15, %l3 ! typelib_TypeClass_ENUM
+ be handleWord
+
+ ! double word types
+ subcc %i3, 8, %l3 ! typelib_TypeClass_HYPER
+ be handleDoubleWord
+ subcc %i3, 9, %l3 ! typelib_TypeClass_UNSIGNED_HYPER
+ be handleDoubleWord
+
+ ! float
+ subcc %i3, 10, %l3 ! typelib_TypeClass_FLOAT
+ be handleFloat
+
+ ! double
+ subcc %i3, 11, %l3 ! typelib_TypeClass_DOUBLE
+ be handleDouble
+
+ ! default: return void
+ nop ! empty prefetch
+ ba doRestore
+ nop
+handleByte:
+ stb %o0, [%i2]
+ ba doRestore
+ nop
+handleShort:
+ sth %o0, [%i2]
+ ba doRestore
+ nop
+handleWord:
+ st %o0, [%i2]
+ ba doRestore
+ nop
+handleDoubleWord:
+ st %o0, [%i2]
+ st %o1, [%i2+4]
+ ba doRestore
+ nop
+handleFloat:
+ st %f0, [%i2]
+ ba doRestore
+ nop
+handleDouble:
+ std %f0, [%fp-8]
+ ldd [%fp-8], %o0
+ st %o0, [%i2]
+ st %o1, [%i2+4]
+ ba doRestore
+ nop
+doRestore:
+ restore ! stack frame for called method
+ ret
+ restore ! stack frame for own locals
+.size callVirtualMethodExceptionHandler,(.-callVirtualMethodExceptionHandler)
+.size callVirtualMethod,(.-callVirtualMethod)
+.align 8 \ No newline at end of file
diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/cc50_solaris_sparc.hxx b/bridges/source/cpp_uno/cc50_solaris_sparc/cc50_solaris_sparc.hxx
new file mode 100644
index 000000000000..4dd06177a346
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_sparc/cc50_solaris_sparc.hxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * $RCSfile: cc50_solaris_sparc.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+#include <typeinfo>
+
+typedef struct _uno_Any uno_Any;
+typedef struct _uno_Mapping uno_Mapping;
+
+// private C50 structures and functions
+namespace __Crun
+{
+ struct static_type_info
+ {
+ char* m_pClassName;
+ int m_nSkip1; // must be 0
+ void* m_pMagic; // points to some magic data
+ int m_nMagic[ 4 ];
+ int m_nSkip2[2]; // must be 0
+ };
+ void* ex_alloc(unsigned);
+ void ex_throw( void*, const static_type_info*, void(*)(void*));
+ void* ex_get();
+ void ex_rethrow_q() throw();
+}
+
+namespace __Cimpl
+{
+ const char* ex_name();
+}
+
+extern "C" void _ex_register( void*, int );
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+inline char* adjustPointer( char* pIn, typelib_TypeDescription* pType )
+{
+ switch( pType->nSize )
+ {
+ case 1: return pIn + 3;
+ case 2: return pIn + 2;
+ case 3: return pIn + 1;
+ // Huh ? perhaps a char[3] ? Though that would be a pointer
+ // well, we have it anyway for symmetry
+ }
+ return pIn;
+}
+
+//##################################################################################################
+//#### exceptions ##################################################################################
+//##################################################################################################
+
+void cc50_solaris_sparc_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
+void cc50_solaris_sparc_fillUnoException( void*, const char*, uno_Any*, uno_Mapping * pCpp2Uno );
+
+}
+
diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/cpp2uno.cxx b/bridges/source/cpp_uno/cc50_solaris_sparc/cpp2uno.cxx
new file mode 100644
index 000000000000..df04a7ccb7dd
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_sparc/cpp2uno.cxx
@@ -0,0 +1,696 @@
+/*************************************************************************
+ *
+ * $RCSfile: cpp2uno.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#define LEAK_STATIC_DATA
+// #define TRACE(x) OSL_TRACE(x)
+#define TRACE(x)
+
+#include <alloca.h>
+#include <stl/list>
+#include <stl/map>
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
+#include <typelib/typedescription.hxx>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#include <bridges/cpp_uno/bridge.hxx>
+#endif
+#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
+#include <bridges/cpp_uno/type_misc.hxx>
+#endif
+
+#include "cc50_solaris_sparc.hxx"
+
+using namespace com::sun::star::uno;
+using namespace std;
+using namespace osl;
+using namespace rtl;
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//==================================================================================================
+static typelib_TypeClass cpp2uno_call(
+ cppu_cppInterfaceProxy * pThis,
+ const typelib_TypeDescription * pMemberTypeDescr,
+ typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
+ sal_Int32 nParams, typelib_MethodParameter * pParams,
+ void ** pCallStack,
+ sal_Int64 * pRegisterReturn /* space for register return */ )
+{
+ // pCallStack: [return ptr], this, params
+ char * pCppStack = (char *)pCallStack;
+
+ // return
+ typelib_TypeDescription * pReturnTypeDescr = 0;
+ if (pReturnTypeRef)
+ TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
+
+ void * pUnoReturn = 0;
+ void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
+
+ if (pReturnTypeDescr)
+ {
+ if (cppu_isSimpleType( pReturnTypeDescr ))
+ {
+ pUnoReturn = pRegisterReturn; // direct way for simple types
+ }
+ else // complex return via ptr (pCppReturn)
+ {
+ pCppReturn = *pCallStack;
+ pCppStack += sizeof( void* );
+ pUnoReturn = (cppu_relatesToInterface( pReturnTypeDescr )
+ ? alloca( pReturnTypeDescr->nSize )
+ : pCppReturn); // direct way
+ }
+ }
+ // pop this
+ pCppStack += sizeof( void* );
+
+ // stack space
+ OSL_ENSHURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
+ // parameters
+ void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
+ void ** pCppArgs = pUnoArgs + nParams;
+ // indizes of values this have to be converted (interface conversion cpp<=>uno)
+ sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams));
+ // type descriptions for reconversions
+ typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
+
+ sal_Int32 nTempIndizes = 0;
+
+ for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
+ {
+ const typelib_MethodParameter & rParam = pParams[nPos];
+ typelib_TypeDescription * pParamTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
+
+ if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr )) // value
+ {
+ pCppArgs[ nPos ] = pUnoArgs[ nPos ] =
+ adjustPointer( pCppStack, pParamTypeDescr );
+ switch (pParamTypeDescr->eTypeClass)
+ {
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ case typelib_TypeClass_DOUBLE:
+ pCppStack += sizeof(sal_Int32); // extra long
+ }
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ else // ptr to complex value | ref
+ {
+ pCppArgs[nPos] = *(void **)pCppStack;
+
+ if (! rParam.bIn) // is pure out
+ {
+ // uno out is unconstructed mem!
+ pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
+ pTempIndizes[nTempIndizes] = nPos;
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ // is in/inout
+ else if (cppu_relatesToInterface( pParamTypeDescr ))
+ {
+ uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
+ *(void **)pCppStack, pParamTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ else // direct way
+ {
+ pUnoArgs[nPos] = *(void **)pCppStack;
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ }
+ pCppStack += sizeof(sal_Int32); // standard parameter length
+ }
+
+ // ExceptionHolder
+ uno_Any aUnoExc; // Any will be constructed by callee
+ uno_Any * pUnoExc = &aUnoExc;
+
+ // invoke uno dispatch call
+ (*pThis->pUnoI->pDispatcher)( pThis->pUnoI, pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
+
+ // in case no exception occured...
+ if (pUnoExc)
+ {
+ // destruct temporary in/inout params
+ for ( ; nTempIndizes--; )
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+
+ if (pParams[nIndex].bIn) // is in/inout => was constructed
+ uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 );
+ TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
+ }
+ if (pReturnTypeDescr)
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
+
+ cc50_solaris_sparc_raiseException( &aUnoExc, &pThis->pBridge->aUno2Cpp ); // has to destruct the any
+ // is here for dummy
+ return typelib_TypeClass_VOID;
+ }
+ else // else no exception occured...
+ {
+ // temporary params
+ for ( ; nTempIndizes--; )
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+ typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
+
+ if (pParams[nIndex].bOut) // inout/out
+ {
+ // convert and assign
+ uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
+ uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+ }
+ // destroy temp uno param
+ uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
+
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ // return
+ if (pCppReturn) // has complex return
+ {
+ if (pUnoReturn != pCppReturn) // needs reconversion
+ {
+ uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+ // destroy temp uno return
+ uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
+ }
+ // complex return ptr is set to eax
+ *(void **)pRegisterReturn = pCppReturn;
+ }
+ if (pReturnTypeDescr)
+ {
+ typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
+ return eRet;
+ }
+ else
+ return typelib_TypeClass_VOID;
+ }
+}
+
+
+//==================================================================================================
+static typelib_TypeClass cpp_mediate(
+ sal_Int32 nVtableCall,
+ void ** pCallStack,
+ sal_Int64 * pRegisterReturn /* space for register return */ )
+{
+ OSL_ENSHURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" );
+
+ // pCallStack: this, params
+ // _this_ ptr is patched cppu_Interface object
+ cppu_cppInterfaceProxy * pCppI = NULL;
+ if( nVtableCall & 0x80000000 )
+ {
+ nVtableCall &= 0x7fffffff;
+ pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*(pCallStack +1);
+ }
+ else
+ pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*pCallStack;
+
+ typelib_InterfaceTypeDescription * pTypeDescr = pCppI->pTypeDescr;
+
+// OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex,
+// "### illegal vtable index!" );
+// if (nVtableCall >= pTypeDescr->nMapFunctionIndexToMemberIndex)
+// {
+// RuntimeException aExc;
+// aExc.Message = OUString::createFromAscii("illegal vtable index!");
+// aExc.Context = (XInterface *)pCppI;
+// throw aExc;
+// }
+
+ // determine called method
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
+ sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nVtableCall];
+ OSL_ENSHURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
+
+ TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
+
+ typelib_TypeClass eRet;
+ switch (aMemberDescr.get()->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nVtableCall)
+ {
+ // is GET method
+ eRet = cpp2uno_call(
+ pCppI, aMemberDescr.get(),
+ ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
+ 0, 0, // no params
+ pCallStack, pRegisterReturn );
+ }
+ else
+ {
+ // is SET method
+ typelib_MethodParameter aParam;
+ aParam.pTypeRef =
+ ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
+ aParam.bIn = sal_True;
+ aParam.bOut = sal_False;
+
+ eRet = cpp2uno_call(
+ pCppI, aMemberDescr.get(),
+ 0, // indicates void return
+ 1, &aParam,
+ pCallStack, pRegisterReturn );
+ }
+ break;
+ }
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ // is METHOD
+ switch (nVtableCall)
+ {
+ // standard XInterface vtable calls
+ case 1: // acquire()
+ pCppI->acquireProxy(); // non virtual call!
+ eRet = typelib_TypeClass_VOID;
+ break;
+ case 2: // release()
+ pCppI->releaseProxy(); // non virtual call!
+ eRet = typelib_TypeClass_VOID;
+ break;
+ case 0: // queryInterface() opt
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pCallStack[2] )->getTypeLibType() );
+ OSL_ASSERT( pTD );
+
+ XInterface * pInterface = 0;
+ (*pCppI->pBridge->pCppEnv->getRegisteredInterface)(
+ pCppI->pBridge->pCppEnv,
+ (void **)&pInterface, pCppI->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
+
+ if (pInterface)
+ {
+ uno_any_construct( reinterpret_cast< uno_Any * >( pCallStack[0] ),
+ &pInterface, pTD, cpp_acquire );
+ pInterface->release();
+ TYPELIB_DANGER_RELEASE( pTD );
+ *(void **)pRegisterReturn = pCallStack[0];
+ eRet = typelib_TypeClass_ANY;
+ break;
+ }
+ TYPELIB_DANGER_RELEASE( pTD );
+ } // else perform queryInterface()
+ default:
+ eRet = cpp2uno_call(
+ pCppI, aMemberDescr.get(),
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
+ pCallStack, pRegisterReturn );
+ }
+ break;
+ }
+// default:
+// {
+// RuntimeException aExc;
+// aExc.Message = OUString::createFromAscii("no member description found!");
+// aExc.Context = (XInterface *)pCppI;
+// throw aExc;
+// // is here for dummy
+// eRet = typelib_TypeClass_VOID;
+// }
+ }
+
+ return eRet;
+}
+
+
+//==================================================================================================
+class MediateClassData
+{
+public:
+ struct ClassDataBuffer
+ {
+ void** m_pVTable;
+
+ ~ClassDataBuffer();
+ };
+private:
+
+ map< OUString, ClassDataBuffer* > m_aClassData;
+ Mutex m_aMutex;
+
+ void createVTable( ClassDataBuffer*, typelib_InterfaceTypeDescription* );
+public:
+ const ClassDataBuffer* getClassData( typelib_InterfaceTypeDescription* );
+
+ MediateClassData() {}
+ ~MediateClassData();
+};
+//__________________________________________________________________________________________________
+
+MediateClassData::ClassDataBuffer::~ClassDataBuffer()
+{
+ delete m_pVTable;
+}
+
+//__________________________________________________________________________________________________
+MediateClassData::~MediateClassData()
+{
+ TRACE( "> calling ~MediateClassData(): freeing mediate vtables... <\n" );
+
+ // this MUST be the absolute last one which is called!
+ for ( map< OUString, ClassDataBuffer* >::iterator iPos( m_aClassData.begin() ); iPos != m_aClassData.end(); ++iPos )
+ {
+ // todo
+// delete (*iPos).second;
+ }
+}
+
+//__________________________________________________________________________________________________
+
+const MediateClassData::ClassDataBuffer* MediateClassData::getClassData( typelib_InterfaceTypeDescription* pType )
+{
+ MutexGuard aGuard( m_aMutex );
+
+ map< OUString, ClassDataBuffer* >::iterator element = m_aClassData.find( pType->aBase.pTypeName );
+ if( element != m_aClassData.end() )
+ return (*element).second;
+
+ ClassDataBuffer* pBuffer = new ClassDataBuffer();
+ createVTable( pBuffer, pType );
+ m_aClassData[ pType->aBase.pTypeName ] = pBuffer;
+ return pBuffer;
+}
+
+//==================================================================================================
+void cpp_vtable_call( int nTableEntry, void** pCallStack )
+{
+ long nRegReturn[2];
+ typelib_TypeClass aType =
+ cpp_mediate( nTableEntry, pCallStack+17, (sal_Int64*)nRegReturn );
+ switch( aType )
+ {
+ // move return value into register space
+ // (will be loaded by machine code snippet)
+ case typelib_TypeClass_BOOLEAN:
+ case typelib_TypeClass_BYTE:
+ pCallStack[ 17 ] = (void*)(((char*)nRegReturn)[0]);
+ break;
+ case typelib_TypeClass_CHAR:
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ pCallStack[ 17 ] = (void*)(((short*)nRegReturn)[0]);
+ break;
+ case typelib_TypeClass_DOUBLE:
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ // move long to %i1
+ pCallStack[ 18 ] = (void*) nRegReturn[ 1 ];
+ case typelib_TypeClass_FLOAT:
+ default:
+ // move long to %i0
+ pCallStack[ 17 ] = (void*) nRegReturn[ 0 ];
+ break;
+ }
+}
+
+enum SpecialReturnType { None, ReturnFloat, ReturnDouble };
+
+//__________________________________________________________________________________________________
+void MediateClassData::createVTable( ClassDataBuffer* pBuffer, typelib_InterfaceTypeDescription* pType )
+{
+ // get all member functions
+ list< SpecialReturnType > aSpecialReturn;
+ list< sal_Bool > aComplexReturn;
+
+ for( int n = 0; n < pType->nAllMembers; n++ )
+ {
+ typelib_TypeDescription* pMember = NULL;
+ TYPELIB_DANGER_GET( &pMember, pType->ppAllMembers[n] );
+ if( pMember->eTypeClass == typelib_TypeClass_INTERFACE_ATTRIBUTE )
+ {
+ typelib_TypeDescription * pRetTD = 0;
+ TYPELIB_DANGER_GET( &pRetTD, ((typelib_InterfaceAttributeTypeDescription *)pMember)->pAttributeTypeRef );
+ // get method
+ switch( pRetTD->eTypeClass )
+ {
+ case typelib_TypeClass_FLOAT:
+ aSpecialReturn.push_back( ReturnFloat );
+ break;
+ case typelib_TypeClass_DOUBLE:
+ aSpecialReturn.push_back( ReturnDouble );
+ break;
+ default:
+ aSpecialReturn.push_back( None );
+ break;
+ }
+ aComplexReturn.push_back( !cppu_isSimpleType( pRetTD ) );
+ // set method
+ if( ! ((typelib_InterfaceAttributeTypeDescription*)pMember)->bReadOnly )
+ {
+ aSpecialReturn.push_back( None );
+ aComplexReturn.push_back( sal_False );
+ }
+ TYPELIB_DANGER_RELEASE( pRetTD );
+ }
+ else
+ {
+ typelib_TypeDescription * pRetTD = 0;
+ TYPELIB_DANGER_GET( &pRetTD, ((typelib_InterfaceMethodTypeDescription *)pMember)->pReturnTypeRef );
+ switch( pRetTD->eTypeClass )
+ {
+ case typelib_TypeClass_FLOAT:
+ aSpecialReturn.push_back( ReturnFloat );
+ break;
+ case typelib_TypeClass_DOUBLE:
+ aSpecialReturn.push_back( ReturnDouble );
+ break;
+ default:
+ aSpecialReturn.push_back( None );
+ break;
+ }
+ aComplexReturn.push_back( !cppu_isSimpleType( pRetTD ) );
+ TYPELIB_DANGER_RELEASE( pRetTD );
+ }
+ TYPELIB_DANGER_RELEASE( pMember );
+ }
+
+ const int nSnippetSize = 256;
+ int nSize = aSpecialReturn.size();
+ char * pSpace = (char *)rtl_allocateMemory( ((nSize+3)*sizeof(void *)) + (nSize * nSnippetSize) );
+ pBuffer->m_pVTable = (void**)pSpace;
+
+ char * pCode = pSpace + ((nSize+3)*sizeof(void *));
+ void ** pvft = (void **)pSpace;
+ pvft[0] = NULL; // RTTI
+ pvft[1] = NULL; // null
+ pvft[2] = NULL; // destructor
+
+ // setup vft and code
+ for ( sal_Int32 nPos = 0; nPos < nSize; ++nPos )
+ {
+ unsigned long * codeSnip =
+ (unsigned long*)((unsigned char *)pCode + (nPos*nSnippetSize));
+ SpecialReturnType eRet = aSpecialReturn.front();
+ aSpecialReturn.pop_front();
+ unsigned long nTablePos = nPos;
+ if( aComplexReturn.front() )
+ nTablePos |= 0x80000000;
+ aComplexReturn.pop_front();
+ pvft[nPos+3] = codeSnip;
+ /*generate this code:
+ * save %sp, -104, %sp
+ * st %i0, [ %fp + 68 ]
+ * st %i1, [ %fp + 72 ]
+ * st %i2, [ %fp + 76 ]
+ * st %i3, [ %fp + 80 ]
+ * st %i4, [ %fp + 84 ]
+ * st %i5, [ %fp + 88 ]
+ * prepare vtable entry
+ * sethi %hi( nTablePos ), %o0
+ * or %lo( nTablePos ), %o0
+ *
+ * ( if complex return, set high bit )
+ *
+ * mov %fp, %o1 prepare stack
+ * call cpp_vtable_call
+ * nop
+ * ld [ %fp + 68 ], %i0 restore (perhaps changed) registers
+ * ld [ %fp + 72 ], %i1
+ * ld [ %fp + 76 ], %i2
+ * ld [ %fp + 80 ], %i3
+ * ld [ %fp + 84 ], %i4
+ * ld [ %fp + 88 ], %i5
+ *
+ * ( if double return value, get (%i0, %i1) into %f0
+ * std %i0, [ %fp - 8 ]
+ * ldd [ %fp - 8 ], %f0
+ *
+ * ( if float return value, get (%i0) into %f0
+ * ld [ %fp + 68 ], %f0
+ *
+ * jmp %i7+8 return
+ * restore
+ *exception cleanup code
+ * call __Crun::ex_rethrow_q
+ * nop
+ */
+ *codeSnip++ = 0x9de3bf98;
+ *codeSnip++ = 0xf027a044;
+ *codeSnip++ = 0xf227a048;
+ *codeSnip++ = 0xf427a04c;
+ *codeSnip++ = 0xf627a050;
+ *codeSnip++ = 0xf827a054;
+ *codeSnip++ = 0xfa27a058;
+ *codeSnip++ = 0x11000000 | (nTablePos >> 10);
+ *codeSnip++ = 0x90122000 | (nTablePos & 1023);
+ *codeSnip++ = 0x9210001e;
+ unsigned long rel32 = (unsigned long)cpp_vtable_call - ((unsigned long)codeSnip);
+ *codeSnip++ = 0x40000000 | (rel32 >> 2 );
+ *codeSnip++ = 0x01000000;
+ *codeSnip++ = 0xf007a044;
+ *codeSnip++ = 0xf207a048;
+ *codeSnip++ = 0xf407a04c;
+ *codeSnip++ = 0xf607a050;
+ *codeSnip++ = 0xf807a054;
+ *codeSnip++ = 0xfa07a058;
+
+ switch( eRet )
+ {
+ case ReturnFloat:
+ *codeSnip++ = 0xc107a044;
+ break;
+ case ReturnDouble:
+ *codeSnip++ = 0xf03fbff8;
+ *codeSnip++ = 0xc11fbff8;
+ break;
+ default:
+ break;
+ }
+
+ unsigned long* exc_frame = codeSnip;
+ *codeSnip++ = 0x81c7e008;
+ *codeSnip++ = 0x81e80000;
+ unsigned long* exc_handler = codeSnip;
+ *codeSnip++ = 0x40000000 | (((unsigned long)__Crun::ex_rethrow_q) >> 2);
+ *codeSnip++ = 0x01000000;
+
+ unsigned long* frame_info = new unsigned long[5];
+ memset( frame_info, 0, 5*sizeof(unsigned long) );
+ frame_info[ 0 ] = (unsigned long)exc_frame;
+ frame_info[ 2 ] = (unsigned long)(exc_handler);
+ _ex_register( frame_info, 1 );
+ }
+}
+
+//==================================================================================================
+void SAL_CALL cppu_cppInterfaceProxy_patchVtable(
+ XInterface * pCppI, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ static MediateClassData * s_pMediateClassData = 0;
+ if (! s_pMediateClassData)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pMediateClassData)
+ {
+#ifdef LEAK_STATIC_DATA
+ s_pMediateClassData = new MediateClassData();
+#else
+ static MediateClassData s_aMediateClassData;
+ s_pMediateClassData = &s_aMediateClassData;
+#endif
+ }
+ }
+ *(const void **)pCppI = s_pMediateClassData->getClassData( pTypeDescr )->m_pVTable + 1;
+}
+
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pCppEnv )
+{
+ CPPU_CURRENT_NAMESPACE::cppu_cppenv_initEnvironment( pCppEnv );
+}
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_ext_getMapping(
+ uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo )
+{
+ CPPU_CURRENT_NAMESPACE::cppu_ext_getMapping( ppMapping, pFrom, pTo );
+}
+
diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx b/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx
new file mode 100644
index 000000000000..0c0b2eda5dad
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx
@@ -0,0 +1,421 @@
+/*************************************************************************
+ *
+ * $RCSfile: except.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <dlfcn.h>
+#include <new.h>
+#include <typeinfo>
+#include <stl/list>
+#include <stl/map>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#include <bridges/cpp_uno/bridge.hxx>
+#endif
+#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
+#include <typelib/typedescription.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+
+#include "cc50_solaris_sparc.hxx"
+
+// need a += operator for OString and sal_Char
+namespace rtl
+{
+ inline OString& operator+=( OString& rString, sal_Char cAdd )
+ {
+ sal_Char add[2];
+ add[0] = cAdd;
+ add[1] = 0;
+ return rString += add;
+ }
+}
+
+using namespace std;
+using namespace osl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//==================================================================================================
+static OString toUNOname( const OString & rRTTIname )
+{
+ OString aRet;
+
+ const sal_Char* pRTTI = rRTTIname.getStr();
+ const sal_Char* pOrg = pRTTI;
+ const sal_Char* pLast = pRTTI;
+
+ while( 1 )
+ {
+ if( *pRTTI == ':' || ! *pRTTI )
+ {
+ if( aRet.getLength() )
+ aRet += ".";
+ aRet += rRTTIname.copy( pLast - pOrg, pRTTI - pLast );
+ while( *pRTTI == ':' )
+ pRTTI++;
+ pLast = pRTTI;
+ if( ! *pRTTI )
+ break;
+ }
+ else
+ pRTTI++;
+ }
+
+ return aRet;
+}
+//==================================================================================================
+static OString toRTTIname( const OString & rUNOname )
+{
+ OString aRet;
+
+ int nTokens = rUNOname.getTokenCount( '.' );
+ for( int i = 0; i < nTokens; i++ )
+ {
+ if( i > 0 )
+ aRet += "::";
+ aRet += rUNOname.getToken( i, '.' );
+ }
+
+ return aRet;
+}
+//==================================================================================================
+
+static int replaceQdDdD( const OString& rIn, OString& rOutdD, OString& rOutdDdD )
+{
+ int nRet = 0;
+ int nLen = rIn.getLength(), i, n;
+ rOutdD = OString();
+ rOutdDdD = OString();
+ for( i = 0, n = 0; ( i = rIn.indexOf( 'Q', i ) ) != -1 && i < nLen; i++ )
+ {
+ rOutdD += rIn.copy( n, i-n+1 );
+ rOutdDdD += rIn.copy( n, i-n+1 );
+ n = i+1;
+ rOutdD += "dD";
+ rOutdDdD += "dDdD";
+ nRet++;
+ }
+ rOutdD += rIn.copy( n );
+ rOutdDdD += rIn.copy( n );
+ return nRet;
+}
+
+static OString toRTTIsymbolname( const OString & rRTTIname )
+{
+ if( ! rRTTIname.getLength() )
+ return OString();
+
+ OString aRet;
+ OString aPrefix;
+
+ int nUnoTokens = rRTTIname.getTokenCount( ':' );
+ int nAdjust = 0;
+ for( int i = 0; i < nUnoTokens; i++ )
+ {
+ OString aToken( rRTTIname.getToken( i, ':' ) );
+ int nBytes = aToken.getLength();
+ if( nBytes )
+ {
+ OString aAdd;
+ if( nBytes > 25 )
+ {
+ aAdd += (sal_Char)( nBytes/26 + 'a' );
+ aAdd += (sal_Char)( nBytes % 26 + 'A' );
+ }
+ else
+ aAdd += (sal_Char)( nBytes + 'A' );
+ aRet += aAdd;
+ // special case "Q"
+ if( ( ( nBytes % 26 ) +'A' ) == 'Q' )
+ {
+ aRet += "dD";
+ nAdjust += 2;
+ }
+
+ OString adD, adDdD;
+ int nRepl = replaceQdDdD( aToken, adD, adDdD );
+ if( nUnoTokens == 1 )
+ {
+ // must replace "Q" by "QdD"
+ aRet += adD;
+ nAdjust += 2* nRepl;
+ }
+ else
+ {
+ // must replace "Q" by "QdDdD"
+ aRet += adDdD;
+ nAdjust += 4* nRepl;
+ }
+
+ if( i < nUnoTokens - 1 )
+ {
+ aPrefix += aAdd;
+ // must replace "Q" by "QdD"
+ aPrefix += adD;
+ }
+ }
+ }
+ aRet += '_';
+
+ if( aPrefix.getLength() )
+ {
+ int nBytes = aRet.getLength() - nAdjust + 10;
+ if( nBytes > 25 )
+ {
+ aPrefix += (sal_Char)( nBytes/26 + 'a' );
+ aPrefix += (sal_Char)( nBytes % 26 + 'A' );
+ }
+ else
+ aPrefix += (sal_Char)( nBytes + 'A' );
+
+
+ aRet = "__1c" + aPrefix + "__RTTI__1n" + aRet + "_";
+ }
+ else
+ aRet = "__RTTI__1n"+aRet;
+
+ return aRet;
+}
+
+
+//##################################################################################################
+//#### RTTI simulation #############################################################################
+//##################################################################################################
+
+class RTTIHolder
+{
+ static std::map< OString, void* > aAllRTTI;
+public:
+ static void* getRTTI( const OString& rTypename );
+ static void* getRTTI_UnoName( const OString& rUnoTypename )
+ { return getRTTI( toRTTIname( rUnoTypename ) ); }
+
+ static void* insertRTTI( const OString& rTypename );
+ static void* insertRTTI_UnoName( const OString& rTypename )
+ { return insertRTTI( toRTTIname( rTypename ) ); }
+};
+
+std::map< OString, void* > RTTIHolder::aAllRTTI;
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+void* RTTIHolder::getRTTI( const OString& rTypename )
+{
+ std::map< OString, void* >::iterator element;
+
+ element = aAllRTTI.find( rTypename );
+ if( element != aAllRTTI.end() )
+ return (*element).second;
+ // get rtti
+ // look for existing type info
+ static void* pMain = dlopen( NULL, RTLD_NOW | RTLD_GLOBAL );
+
+ void* pSymbol = dlsym( pMain, toRTTIsymbolname( rTypename ).getStr() );
+
+ if( pSymbol )
+ {
+ // there exists type info, use it (otherwise it will not be equal
+ // since addresses - not contents - are matched in RTTI compare)
+ aAllRTTI[ rTypename ] = pSymbol;
+ return pSymbol;
+ }
+
+#ifdef DEBUG
+ fprintf( stderr, "exception type \"%s\" not found via dlsym !!!\n", toRTTIsymbolname( rTypename ).getStr() );
+#endif
+
+ // no type found (time for plan b: look for base type )
+ return NULL;
+}
+
+static long nMagicId = 1;
+
+void* RTTIHolder::insertRTTI( const OString& rTypename )
+{
+#ifdef DEBUG
+ fprintf( stderr, "generating base RTTI for type %s\n", rTypename.getStr() );
+#endif
+ void** pRTTI = new void*[ 19 ];
+ memset( pRTTI, 0, 19*sizeof( void* ) );
+ pRTTI[ 0 ] = (void*)strdup( rTypename.getStr() );
+ pRTTI[ 2 ] = (void*)(7*sizeof(void*));
+ pRTTI[ 3 ] = (void*)nMagicId++;
+ pRTTI[ 4 ] = (void*)nMagicId++;
+ pRTTI[ 5 ] = (void*)nMagicId++;
+ pRTTI[ 6 ] = (void*)nMagicId++;
+
+ pRTTI[ 9 ] = pRTTI[ 3 ];
+ pRTTI[ 10 ] = pRTTI[ 4 ];
+ pRTTI[ 11 ] = pRTTI[ 5 ];
+ pRTTI[ 12 ] = pRTTI[ 6 ];
+ pRTTI[ 13 ] = (void*)0x80000000;
+
+ aAllRTTI[ rTypename ] = (void*)pRTTI;
+ return pRTTI;
+}
+
+//--------------------------------------------------------------------------------------------------
+
+static void* generateRTTI( typelib_CompoundTypeDescription * pCompTypeDescr )
+{
+ static ::osl::Mutex aMutex;
+ ::osl::Guard< ::osl::Mutex > guard( aMutex );
+
+ OString aCompTypeName( OUStringToOString( pCompTypeDescr->aBase.pTypeName, RTL_TEXTENCODING_ASCII_US ) );
+
+ void* pRTTI = RTTIHolder::getRTTI_UnoName( aCompTypeName );
+ if( pRTTI )
+ return pRTTI;
+
+ // uh oh. Compiler did not generate RTTI for this type
+ // but that means that this was neither thrown nor caught explicitly
+ // then let's downcast it until we find real RTTI
+ // since the object will be destructed by deleteException which does
+ // this with the correct type description all should be well
+
+ if( ! pCompTypeDescr->pBaseTypeDescription )
+ // this is a base type (and a bad case, we should not need to generate any RTTI)
+ return RTTIHolder::insertRTTI_UnoName( aCompTypeName );
+
+ // get base class RTTI
+ void* pSuperRTTI = generateRTTI( pCompTypeDescr->pBaseTypeDescription );
+ OSL_ENSHURE( pSuperRTTI, "could not generate RTTI for supertype!" );
+
+ return pSuperRTTI;
+}
+
+//--------------------------------------------------------------------------------------------------
+
+static void deleteException( void* pExc )
+{
+ typelib_TypeDescription* pType = (typelib_TypeDescription*)((void**)pExc)[-2];
+ uno_destructData( pExc, pType, cpp_release );
+ typelib_typedescription_release( pType );
+}
+
+//__________________________________________________________________________________________________
+
+//##################################################################################################
+//#### exported ####################################################################################
+//##################################################################################################
+
+void cc50_solaris_sparc_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
+{
+ typelib_TypeDescription * pTypeDescr = 0;
+ // will be released by deleteException
+ typelib_typedescriptionreference_getDescription( &pTypeDescr, pUnoExc->pType );
+
+ void* pRTTI = generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr );
+
+ // a must be
+ OSL_ENSHURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" );
+
+ void** pExcSpace = (void**)__Crun::ex_alloc( pTypeDescr->nSize + 8 );
+ void * pCppExc = (void*)(((char*)pExcSpace)+8);
+ // will be released in generated dtor
+ // alignment to 8
+ pExcSpace[0] = pTypeDescr;
+ uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
+
+ // destruct uno exception
+ uno_any_destruct( pUnoExc, 0 );
+
+ __Crun::ex_throw( pCppExc, (const __Crun::static_type_info*)pRTTI, deleteException );
+}
+
+void cc50_solaris_sparc_fillUnoException(
+ void* pCppExc,
+ const char* pInfo,
+ uno_Any* pExc,
+ uno_Mapping * pCpp2Uno )
+{
+ OUString aName( OStringToOUString( toUNOname( pInfo ), RTL_TEXTENCODING_ASCII_US ) );
+ typelib_TypeDescription * pExcTypeDescr = 0;
+ typelib_typedescription_getByName(
+ &pExcTypeDescr,
+ aName.pData );
+ if (pExcTypeDescr)
+ {
+ // construct cpp exception any
+ Any aAny( pCppExc, pExcTypeDescr ); // const_cast
+ typelib_typedescription_release( pExcTypeDescr );
+ // construct uno exception any
+ typelib_TypeDescription* pAnyDescr = 0;
+ getCppuType( (const Any *)0 ).getDescription( &pAnyDescr );
+ uno_copyAndConvertData( pExc, &aAny, pAnyDescr, pCpp2Uno );
+ typelib_typedescription_release( pAnyDescr );
+ }
+}
+
+}
+
diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/makefile.mk b/bridges/source/cpp_uno/cc50_solaris_sparc/makefile.mk
new file mode 100644
index 000000000000..39d3be889633
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_sparc/makefile.mk
@@ -0,0 +1,111 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=cppu
+TARGET=sunpro5_uno
+LIBTARGET=no
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(COM)$(CPU)" == "C50S"
+
+#CFLAGS += -O5 -xO5
+
+SLOFILES= \
+ $(SLO)$/cpp2uno.obj \
+ $(SLO)$/uno2cpp.obj \
+ $(SLO)$/except.obj \
+ $(SLO)$/call.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1IMPLIB= i$(TARGET)
+
+SHL1OBJS= \
+ $(SLO)$/cpp2uno.obj \
+ $(SLO)$/uno2cpp.obj \
+ $(SLO)$/except.obj \
+ $(SLO)$/call.obj
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(SALLIB)
+
+.ENDIF
+
+.INCLUDE : target.mk
+
+
+$(SLO)$/call.obj: call.s
+ as -o $(SLO)$/call.o call.s ; touch $(SLO)$/call.obj
+
diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/uno2cpp.cxx b/bridges/source/cpp_uno/cc50_solaris_sparc/uno2cpp.cxx
new file mode 100644
index 000000000000..d903c1ad23bb
--- /dev/null
+++ b/bridges/source/cpp_uno/cc50_solaris_sparc/uno2cpp.cxx
@@ -0,0 +1,423 @@
+/*************************************************************************
+ *
+ * $RCSfile: uno2cpp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <alloca.h>
+#include <stl/map>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#include <bridges/cpp_uno/bridge.hxx>
+#endif
+#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
+#include <bridges/cpp_uno/type_misc.hxx>
+#endif
+
+#include "cc50_solaris_sparc.hxx"
+
+using namespace std;
+using namespace osl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+extern "C" {
+ void callVirtualMethod(
+ void * pThis,
+ sal_Int32 nVtableIndex,
+ void * pRegisterReturn,
+ typelib_TypeClass eReturnType,
+ sal_Int32 * pStackLongs,
+ sal_Int32 nStackLongs
+ );
+ extern void* callVirtualMethodExceptionHandler;
+}
+
+//==================================================================================================
+static void cpp_call(
+ cppu_unoInterfaceProxy * pThis,
+ sal_Int32 nVtableCall,
+ typelib_TypeDescriptionReference * pReturnTypeRef,
+ sal_Int32 nParams, typelib_MethodParameter * pParams,
+ sal_Int32 nExceptions, typelib_TypeDescriptionReference ** ppExceptionRefs,
+ void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
+{
+ // pCppI is cc50_solaris_sparc this pointer
+ OSL_ENSHURE( pThis, "### no interface given!" );
+
+ // max space for: [complex ret ptr], values|ptr ...
+ char * pCppStack = (char *)alloca( ((nParams+3) * sizeof(sal_Int64)) );
+ char * pCppStackStart = pCppStack;
+
+ // return
+ typelib_TypeDescription * pReturnTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
+ OSL_ENSHURE( pReturnTypeDescr, "### expected return type description!" );
+
+ void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
+
+ if (pReturnTypeDescr)
+ {
+ if (cppu_isSimpleType( pReturnTypeDescr ))
+ {
+ pCppReturn = pUnoReturn; // direct way for simple types
+ }
+ else
+ {
+ // complex return via ptr
+ pCppReturn = *(void **)pCppStack = (cppu_relatesToInterface( pReturnTypeDescr )
+ ? alloca( pReturnTypeDescr->nSize )
+ : pUnoReturn); // direct way
+ pCppStack += sizeof(void *);
+ }
+ }
+ // push this
+ *(void**)pCppStack = pThis->pCppI;
+ pCppStack += sizeof( void* );
+
+ // args
+ void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams );
+ // indizes of values this have to be converted (interface conversion cpp<=>uno)
+ sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
+ // type descriptions for reconversions
+ typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
+
+ sal_Int32 nTempIndizes = 0;
+
+ for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
+ {
+ const typelib_MethodParameter & rParam = pParams[nPos];
+ typelib_TypeDescription * pParamTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
+
+ if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr ))
+ {
+ pCppArgs[ nPos ] = adjustPointer( pCppStack, pParamTypeDescr );
+ uno_copyAndConvertData( pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+
+ switch (pParamTypeDescr->eTypeClass)
+ {
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ case typelib_TypeClass_DOUBLE:
+ pCppStack += sizeof(sal_Int32); // extra long
+ }
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ else // ptr to complex value | ref
+ {
+ if (! rParam.bIn) // is pure out
+ {
+ // cpp out is constructed mem, uno out is not!
+ uno_constructData(
+ *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
+ pParamTypeDescr );
+ pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ // is in/inout
+ else if (cppu_relatesToInterface( pParamTypeDescr ))
+ {
+ uno_copyAndConvertData(
+ *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
+ pUnoArgs[nPos], pParamTypeDescr, &pThis->pBridge->aUno2Cpp );
+
+ pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ else // direct way
+ {
+ *(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ }
+ pCppStack += sizeof(sal_Int32); // standard parameter length
+ }
+
+// seems that EH registration for callVirtualMethod is not really
+// necessary
+
+// static unsigned long* pFrameInfo = NULL;
+
+// if( ! pFrameInfo )
+// {
+// pFrameInfo = new unsigned long[ 7 ];
+// pFrameInfo[ 0 ] = 0x40000000 | (((unsigned long)__Crun::ex_rethrow_q) >> 2);
+// pFrameInfo[ 1 ] = 0x01000000;
+// pFrameInfo[ 2 ] = (unsigned long)callVirtualMethodExceptionHandler;
+// pFrameInfo[ 3 ] = 0;
+// pFrameInfo[ 4 ] = (unsigned long)pFrameInfo - (unsigned long)callVirtualMethodExceptionHandler;
+// pFrameInfo[ 5 ] = 0;
+// pFrameInfo[ 6 ] = 0;
+// _ex_register( pFrameInfo+2, 1 );
+// }
+
+ try
+ {
+ int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32);
+ if( nStackLongs & 1 )
+ // stack has to be 8 byte aligned
+ nStackLongs++;
+
+ callVirtualMethod(
+ pThis->pCppI,
+ nVtableCall,
+ pCppReturn,
+ pReturnTypeDescr->eTypeClass,
+ (sal_Int32 *)pCppStackStart,
+ nStackLongs
+ );
+
+ // NO exception occured...
+ *ppUnoExc = 0;
+
+ // reconvert temporary params
+ for ( ; nTempIndizes--; )
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+ typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
+
+ if (pParams[nIndex].bIn)
+ {
+ if (pParams[nIndex].bOut) // inout
+ {
+ uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
+ uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ }
+ }
+ else // pure out
+ {
+ uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ }
+ // destroy temp cpp param => cpp: every param was constructed
+ uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
+
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ // return value
+ if (pCppReturn && pUnoReturn != pCppReturn)
+ {
+ uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
+ }
+ }
+ catch( ... )
+ {
+ // get exception
+ cc50_solaris_sparc_fillUnoException( __Crun::ex_get(),
+ __Cimpl::ex_name(),
+ *ppUnoExc,
+ &pThis->pBridge->aCpp2Uno);
+ // temporary params
+ for ( ; nTempIndizes--; )
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+ // destroy temp cpp param => cpp: every param was constructed
+ uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
+ TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
+ }
+ // return type
+ if (pReturnTypeDescr)
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
+ }
+}
+
+//==================================================================================================
+void SAL_CALL cppu_unoInterfaceProxy_dispatch(
+ uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ // is my surrogate
+ cppu_unoInterfaceProxy * pThis = (cppu_unoInterfaceProxy *)pUnoI;
+ typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
+
+ switch (pMemberDescr->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ // determine vtable call index
+ sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
+ OSL_ENSHURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
+
+ sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
+
+ typelib_TypeDescriptionReference * pRuntimeExcRef = 0;
+
+ if (pReturn)
+ {
+ // dependent dispatch
+ cpp_call( pThis, nVtableCall,
+ ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
+ 0, 0, // no params
+ 1, &pRuntimeExcRef, // RuntimeException
+ pReturn, pArgs, ppException );
+ }
+ else
+ {
+ // is SET
+ typelib_MethodParameter aParam;
+ aParam.pTypeRef =
+ ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
+ aParam.bIn = sal_True;
+ aParam.bOut = sal_False;
+
+ typelib_TypeDescriptionReference * pReturnTypeRef = 0;
+ OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
+ typelib_typedescriptionreference_new(
+ &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
+
+ // dependent dispatch
+ cpp_call( pThis, nVtableCall +1, // get, then set method
+ pReturnTypeRef,
+ 1, &aParam,
+ 1, &pRuntimeExcRef,
+ pReturn, pArgs, ppException );
+
+ typelib_typedescriptionreference_release( pReturnTypeRef );
+ }
+
+ break;
+ }
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ // determine vtable call index
+ sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
+ OSL_ENSHURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
+
+ sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
+
+ switch (nVtableCall)
+ {
+ // standard calls
+ case 1: // acquire uno interface
+ (*pUnoI->acquire)( pUnoI );
+ *ppException = 0;
+ break;
+ case 2: // release uno interface
+ (*pUnoI->release)( pUnoI );
+ *ppException = 0;
+ break;
+ case 0: // queryInterface() opt
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
+ OSL_ASSERT( pTD );
+
+ uno_Interface * pInterface = 0;
+ (*pThis->pBridge->pUnoEnv->getRegisteredInterface)(
+ pThis->pBridge->pUnoEnv,
+ (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
+
+ if (pInterface)
+ {
+ uno_any_construct( reinterpret_cast< uno_Any * >( pReturn ), &pInterface, pTD, 0 );
+ (*pInterface->release)( pInterface );
+ TYPELIB_DANGER_RELEASE( pTD );
+ *ppException = 0;
+ break;
+ }
+ TYPELIB_DANGER_RELEASE( pTD );
+ } // else perform queryInterface()
+ default:
+ // dependent dispatch
+ cpp_call( pThis, nVtableCall,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nExceptions,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->ppExceptions,
+ pReturn, pArgs, ppException );
+ }
+ break;
+ }
+ default:
+ {
+ ::com::sun::star::uno::RuntimeException aExc;
+ aExc.Message = OUString::createFromAscii("illegal member type description!");
+ aExc.Context = pThis->pCppI;
+
+ typelib_TypeDescription * pTD = 0;
+ const Type & rExcType = ::getCppuType( (const ::com::sun::star::uno::RuntimeException *)0 );
+ TYPELIB_DANGER_GET( &pTD, rExcType.getTypeLibType() );
+ uno_any_construct( *ppException, &aExc, pTD, 0 );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ }
+}
+
+}
+
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx b/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
new file mode 100644
index 000000000000..8b7ddf39098b
--- /dev/null
+++ b/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
@@ -0,0 +1,563 @@
+/*************************************************************************
+ *
+ * $RCSfile: cpp2uno.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:49 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#define LEAK_STATIC_DATA
+// #define TRACE(x) OSL_TRACE(x)
+#define TRACE(x)
+
+#pragma warning( disable : 4237 )
+#include <stl/list>
+#include <malloc.h>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
+#include <typelib/typedescription.hxx>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#include <bridges/cpp_uno/bridge.hxx>
+#endif
+#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
+#include <bridges/cpp_uno/type_misc.hxx>
+#endif
+
+#include "msci.hxx"
+
+using namespace std;
+using namespace rtl;
+using namespace osl;
+using namespace com::sun::star::uno;
+
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//==================================================================================================
+static inline typelib_TypeClass cpp2uno_call(
+ cppu_cppInterfaceProxy * pThis,
+ const typelib_TypeDescription * pMemberTypeDescr,
+ typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
+ sal_Int32 nParams, typelib_MethodParameter * pParams,
+ void ** pCallStack,
+ sal_Int64 * pRegisterReturn /* space for register return */ )
+{
+ // pCallStack: ret, this, [complex return ptr], params
+ char * pCppStack = (char *)(pCallStack +2);
+
+ // return
+ typelib_TypeDescription * pReturnTypeDescr = 0;
+ if (pReturnTypeRef)
+ TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
+
+ void * pUnoReturn = 0;
+ void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
+
+ if (pReturnTypeDescr)
+ {
+ if (cppu_isSimpleType( pReturnTypeDescr ))
+ {
+ pUnoReturn = pRegisterReturn; // direct way for simple types
+ }
+ else // complex return via ptr (pCppReturn)
+ {
+ pCppReturn = *(void **)pCppStack;
+ pCppStack += sizeof(void *);
+
+ pUnoReturn = (cppu_relatesToInterface( pReturnTypeDescr )
+ ? alloca( pReturnTypeDescr->nSize )
+ : pCppReturn); // direct way
+ }
+ }
+
+ // stack space
+ OSL_ENSHURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
+ // parameters
+ void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
+ void ** pCppArgs = pUnoArgs + nParams;
+ // indizes of values this have to be converted (interface conversion cpp<=>uno)
+ sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams));
+ // type descriptions for reconversions
+ typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
+
+ sal_Int32 nTempIndizes = 0;
+
+ for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
+ {
+ const typelib_MethodParameter & rParam = pParams[nPos];
+ typelib_TypeDescription * pParamTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
+
+ if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr )) // value
+ {
+ pCppArgs[nPos] = pCppStack;
+ pUnoArgs[nPos] = pCppStack;
+ switch (pParamTypeDescr->eTypeClass)
+ {
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ case typelib_TypeClass_DOUBLE:
+ pCppStack += sizeof(sal_Int32); // extra long
+ }
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ else // ptr to complex value | ref
+ {
+ pCppArgs[nPos] = *(void **)pCppStack;
+
+ if (! rParam.bIn) // is pure out
+ {
+ // uno out is unconstructed mem!
+ pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
+ pTempIndizes[nTempIndizes] = nPos;
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ // is in/inout
+ else if (cppu_relatesToInterface( pParamTypeDescr ))
+ {
+ uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
+ *(void **)pCppStack, pParamTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ else // direct way
+ {
+ pUnoArgs[nPos] = *(void **)pCppStack;
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ }
+ pCppStack += sizeof(sal_Int32); // standard parameter length
+ }
+
+ // ExceptionHolder
+ uno_Any aUnoExc; // Any will be constructed by callee
+ uno_Any * pUnoExc = &aUnoExc;
+
+ // invoke uno dispatch call
+ (*pThis->pUnoI->pDispatcher)( pThis->pUnoI, pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
+
+ // in case an exception occured...
+ if (pUnoExc)
+ {
+ // destruct temporary in/inout params
+ while (nTempIndizes--)
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+
+ if (pParams[nIndex].bIn) // is in/inout => was constructed
+ uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 );
+ TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
+ }
+ if (pReturnTypeDescr)
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
+
+ msci_raiseException( &aUnoExc, &pThis->pBridge->aUno2Cpp ); // has to destruct the any
+ // is here for dummy
+ return typelib_TypeClass_VOID;
+ }
+ else // else no exception occured...
+ {
+ // temporary params
+ while (nTempIndizes--)
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+ typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
+
+ if (pParams[nIndex].bOut) // inout/out
+ {
+ // convert and assign
+ uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
+ uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+ }
+ // destroy temp uno param
+ uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
+
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ // return
+ if (pCppReturn) // has complex return
+ {
+ if (pUnoReturn != pCppReturn) // needs reconversion
+ {
+ uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+ // destroy temp uno return
+ uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
+ }
+ // complex return ptr is set to eax
+ *(void **)pRegisterReturn = pCppReturn;
+ }
+ if (pReturnTypeDescr)
+ {
+ typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
+ return eRet;
+ }
+ else
+ return typelib_TypeClass_VOID;
+ }
+}
+
+//==================================================================================================
+static typelib_TypeClass __cdecl cpp_mediate(
+ void ** pCallStack, sal_Int32 nVtableCall,
+ sal_Int64 * pRegisterReturn /* space for register return */ )
+{
+ OSL_ENSHURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" );
+
+ // pCallStack: ret adr, this, [ret *], params
+ // _this_ ptr is patched cppu_XInterfaceProxy object
+ cppu_cppInterfaceProxy * pThis = static_cast< cppu_cppInterfaceProxy * >(
+ reinterpret_cast< XInterface * >( pCallStack[1] ) );
+
+ typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex,
+ "### illegal vtable index!" );
+ if (nVtableCall >= pTypeDescr->nMapFunctionIndexToMemberIndex)
+ {
+ throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM("illegal vtable index!") ),
+ (XInterface *)pThis );
+ }
+
+ // determine called method
+ sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nVtableCall];
+ OSL_ENSHURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
+
+ TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
+
+ typelib_TypeClass eRet;
+ switch (aMemberDescr.get()->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nVtableCall)
+ {
+ // is GET method
+ eRet = cpp2uno_call(
+ pThis, aMemberDescr.get(),
+ ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
+ 0, 0, // no params
+ pCallStack, pRegisterReturn );
+ }
+ else
+ {
+ // is SET method
+ typelib_MethodParameter aParam;
+ aParam.pTypeRef =
+ ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
+ aParam.bIn = sal_True;
+ aParam.bOut = sal_False;
+
+ eRet = cpp2uno_call(
+ pThis, aMemberDescr.get(),
+ 0, // indicates void return
+ 1, &aParam,
+ pCallStack, pRegisterReturn );
+ }
+ break;
+ }
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ // is METHOD
+ switch (nVtableCall)
+ {
+ // standard XInterface vtable calls
+ case 1: // acquire()
+ pThis->acquireProxy(); // non virtual call!
+ eRet = typelib_TypeClass_VOID;
+ break;
+ case 2: // release()
+ pThis->releaseProxy(); // non virtual call!
+ eRet = typelib_TypeClass_VOID;
+ break;
+ case 0: // queryInterface() opt
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pCallStack[3] )->getTypeLibType() );
+ OSL_ASSERT( pTD );
+
+ XInterface * pInterface = 0;
+ (*pThis->pBridge->pCppEnv->getRegisteredInterface)(
+ pThis->pBridge->pCppEnv,
+ (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
+
+ if (pInterface)
+ {
+ uno_any_construct( reinterpret_cast< uno_Any * >( pCallStack[2] ),
+ &pInterface, pTD, cpp_acquire );
+ pInterface->release();
+ TYPELIB_DANGER_RELEASE( pTD );
+ *(void **)pRegisterReturn = pCallStack[2];
+ eRet = typelib_TypeClass_ANY;
+ break;
+ }
+ TYPELIB_DANGER_RELEASE( pTD );
+ } // else perform queryInterface()
+ default:
+ eRet = cpp2uno_call(
+ pThis, aMemberDescr.get(),
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
+ pCallStack, pRegisterReturn );
+ }
+ break;
+ }
+ default:
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no member description found!") ),
+ (XInterface *)pThis );
+ // is here for dummy
+ eRet = typelib_TypeClass_VOID;
+ }
+ }
+
+ return eRet;
+}
+
+//==================================================================================================
+class MediateVtables
+{
+ //----------------------------------------------------------------------------------------------
+ struct DefaultRTTIEntry
+ {
+ sal_Int32 _n0, _n1, _n2;
+ type_info * _pRTTI;
+
+ DefaultRTTIEntry()
+ : _n0( 0 )
+ , _n1( 0 )
+ , _n2( 0 )
+ { _pRTTI = msci_getRTTI( "com.sun.star.uno.XInterface" ); }
+ };
+
+ typedef list<void * > t_pSpacesList;
+
+ Mutex _aMutex;
+ t_pSpacesList _aSpaces;
+
+ sal_Int32 _nCurrent;
+ const void * _pCurrent;
+
+public:
+ const void * getMediateVtable( sal_Int32 nSize );
+
+ MediateVtables( sal_Int32 nSize = 256 )
+ : _nCurrent( 0 )
+ , _pCurrent( 0 )
+ { getMediateVtable( nSize ); }
+ ~MediateVtables();
+};
+//__________________________________________________________________________________________________
+MediateVtables::~MediateVtables()
+{
+ TRACE( "> calling ~MediateVtables(): freeing mediate vtables... <\n" );
+
+ MutexGuard aGuard( _aMutex );
+
+ // this MUST be the absolute last one which is called!
+ for ( t_pSpacesList::iterator iPos( _aSpaces.begin() ); iPos != _aSpaces.end(); ++iPos )
+ {
+ rtl_freeMemory( *iPos );
+ }
+}
+
+//==================================================================================================
+/**
+ * is called on incoming vtable calls
+ * (called by asm snippets)
+ */
+static __declspec(naked) void __cdecl cpp_vtable_call(void)
+{
+__asm
+ {
+ sub esp, 8 // space for immediate return type
+ push esp
+ push eax // vtable index
+ mov eax, esp
+ add eax, 16
+ push eax // original stack ptr
+
+ call cpp_mediate
+ add esp, 12
+
+ cmp eax, typelib_TypeClass_FLOAT
+ je Lfloat
+ cmp eax, typelib_TypeClass_DOUBLE
+ je Ldouble
+ cmp eax, typelib_TypeClass_HYPER
+ je Lhyper
+ cmp eax, typelib_TypeClass_UNSIGNED_HYPER
+ je Lhyper
+ // rest is eax
+ pop eax
+ add esp, 4
+ ret
+Lhyper:
+ pop eax
+ pop edx
+ ret
+Lfloat:
+ fld dword ptr [esp]
+ add esp, 8
+ ret
+Ldouble:
+ fld qword ptr [esp]
+ add esp, 8
+ ret
+ }
+}
+
+//__________________________________________________________________________________________________
+const void * MediateVtables::getMediateVtable( sal_Int32 nSize )
+{
+ if (_nCurrent < nSize)
+ {
+ TRACE( "> need larger vtable! <\n" );
+
+ // dont ever guard each time, so ask twice when guarded
+ MutexGuard aGuard( _aMutex );
+ if (_nCurrent < nSize)
+ {
+ nSize = (nSize +1) & 0xfffffffe;
+ char * pSpace = (char *)rtl_allocateMemory( ((1+nSize)*sizeof(void *)) + (nSize*12) );
+ _aSpaces.push_back( pSpace );
+
+ // on index -1 write default rtti entry
+ static DefaultRTTIEntry s_defaultInterfaceRTTI;
+ *(void **)pSpace = &s_defaultInterfaceRTTI;
+
+ void ** pvft = (void **)(pSpace + sizeof(void *));
+ char * pCode = pSpace + ((1+nSize)*sizeof(void *));
+
+ // setup vft and code
+ for ( sal_Int32 nPos = 0; nPos < nSize; ++nPos )
+ {
+ unsigned char * codeSnip = (unsigned char *)pCode + (nPos *12);
+ pvft[nPos] = codeSnip;
+
+ /**
+ * vtable calls detonate on these code snippets
+ */
+ // mov eax, nPos
+ *codeSnip++ = 0xb8;
+ *(sal_Int32 *)codeSnip = nPos;
+ codeSnip += sizeof(sal_Int32);
+ // jmp rel32 cpp_vtable_call
+ *codeSnip++ = 0xe9;
+ *(sal_Int32 *)codeSnip = ((unsigned char *)cpp_vtable_call) - codeSnip - sizeof(sal_Int32);
+ }
+ _pCurrent = pSpace + sizeof(void *);
+ _nCurrent = nSize;
+ }
+ }
+ return _pCurrent;
+}
+
+//==================================================================================================
+void SAL_CALL cppu_cppInterfaceProxy_patchVtable(
+ XInterface * pCppI, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ static MediateVtables * s_pMediateVtables = 0;
+ if (! s_pMediateVtables)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pMediateVtables)
+ {
+#ifdef LEAK_STATIC_DATA
+ s_pMediateVtables = new MediateVtables();
+#else
+ static MediateVtables s_aMediateVtables;
+ s_pMediateVtables = &s_aMediateVtables;
+#endif
+ }
+ }
+ *(const void **)pCppI = s_pMediateVtables->getMediateVtable(
+ pTypeDescr->nMapFunctionIndexToMemberIndex );
+}
+
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pCppEnv )
+{
+ CPPU_CURRENT_NAMESPACE::cppu_cppenv_initEnvironment( pCppEnv );
+}
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_ext_getMapping(
+ uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo )
+{
+ CPPU_CURRENT_NAMESPACE::cppu_ext_getMapping( ppMapping, pFrom, pTo );
+}
+
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/except.cxx b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx
new file mode 100644
index 000000000000..9bab2d6bd5d5
--- /dev/null
+++ b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx
@@ -0,0 +1,538 @@
+/*************************************************************************
+ *
+ * $RCSfile: except.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:49 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#define LEAK_STATIC_DATA
+#define TRACE(x) OSL_TRACE(x)
+// #define TRACE(x)
+
+#pragma warning( disable : 4237 )
+#include <stl/hash_map>
+#include <sal/config.h>
+#include <malloc.h>
+#include <new.h>
+#include <typeinfo.h>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#include <bridges/cpp_uno/bridge.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+
+#include "msci.hxx"
+
+#pragma pack(push, 8)
+
+using namespace com::sun::star::uno;
+using namespace std;
+using namespace osl;
+using namespace rtl;
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//==================================================================================================
+static inline OString toUNOname( const OString & rRTTIname )
+{
+ OStringBuffer aRet( 64 );
+ OString aStr( rRTTIname.copy( 4, rRTTIname.getLength()-4-2 ) ); // filter .?AUzzz@yyy@xxx@@
+ for ( sal_Int32 nToken = aStr.getTokenCount( '@' ); nToken--; )
+ {
+ aRet.append( aStr.getToken( nToken, '@' ) );
+ if (nToken)
+ aRet.append( '.' );
+ }
+ return aRet.makeStringAndClear();
+}
+//==================================================================================================
+static inline OString toRTTIname( const OString & rUNOname )
+{
+ OStringBuffer aRet( 64 );
+ aRet.append( RTL_CONSTASCII_STRINGPARAM(".?AV") ); // class ".?AV"; struct ".?AU"
+ for ( sal_Int32 nToken = rUNOname.getTokenCount( '.' ); nToken--; )
+ {
+ aRet.append( rUNOname.getToken( nToken, '.' ) );
+ aRet.append( '@' );
+ }
+ aRet.append( '@' );
+ return aRet.makeStringAndClear();
+}
+
+
+//##################################################################################################
+//#### RTTI simulation #############################################################################
+//##################################################################################################
+
+
+//==================================================================================================
+struct FctOStringHash : public unary_function< const OString &, size_t >
+{
+ size_t operator()( const OString & rStr ) const
+ { return rStr.hashCode(); }
+};
+typedef hash_map< OString, void *, FctOStringHash, equal_to< OString > > t_string2PtrMap;
+
+//==================================================================================================
+class RTTInfos
+{
+ Mutex _aMutex;
+ t_string2PtrMap _allRTTI;
+
+ static OString toRawName( const OString & rUNOname );
+public:
+ type_info * getRTTI( const OString & rUNOname );
+
+ RTTInfos();
+ ~RTTInfos();
+};
+
+//==================================================================================================
+class __type_info
+{
+ friend type_info * RTTInfos::getRTTI( const OString & );
+ friend sal_Int32 msci_filterCppException( LPEXCEPTION_POINTERS, uno_Any *, uno_Mapping * );
+
+public:
+ virtual ~__type_info();
+
+ __type_info( void * m_data, const char * m_d_name )
+ : _m_data( m_data )
+ { ::strcpy( _m_d_name, m_d_name ); }
+
+private:
+ void * _m_data;
+ char _m_d_name[1];
+};
+//__________________________________________________________________________________________________
+__type_info::~__type_info()
+{
+}
+//__________________________________________________________________________________________________
+type_info * RTTInfos::getRTTI( const OString & rUNOname )
+{
+ // a must be
+ OSL_ENSHURE( sizeof(__type_info) == sizeof(type_info), "### type info structure size differ!" );
+
+ MutexGuard aGuard( _aMutex );
+ const t_string2PtrMap::const_iterator iFind( _allRTTI.find( rUNOname ) );
+
+ // check if type is already available
+ if (iFind == _allRTTI.end())
+ {
+ // insert new type_info
+ OString aRawName( toRTTIname( rUNOname ) );
+ __type_info * pRTTI = new(rtl_allocateMemory( sizeof(__type_info) + aRawName.getLength() ))
+ __type_info( NULL, aRawName.getStr() );
+ // put into map
+ _allRTTI[rUNOname] = pRTTI;
+
+ return (type_info *)pRTTI;
+ }
+ else
+ {
+ return (type_info *)(*iFind).second;
+ }
+}
+//__________________________________________________________________________________________________
+RTTInfos::RTTInfos()
+{
+}
+//__________________________________________________________________________________________________
+RTTInfos::~RTTInfos()
+{
+ TRACE( "> freeing generated RTTI infos... <\n" );
+
+ MutexGuard aGuard( _aMutex );
+ for ( t_string2PtrMap::const_iterator iPos( _allRTTI.begin() );
+ iPos != _allRTTI.end(); ++iPos )
+ {
+ __type_info * pType = (__type_info *)(*iPos).second;
+ pType->~__type_info(); // obsolete, but good style...
+ rtl_freeMemory( pType );
+ }
+}
+
+
+//##################################################################################################
+//#### Exception raising ###########################################################################
+//##################################################################################################
+
+
+//==================================================================================================
+struct ObjectFunction
+{
+ char somecode[12];
+ typelib_TypeDescription * _pTypeDescr; // type of object
+
+ ObjectFunction( typelib_TypeDescription * pTypeDescr, void * fpFunc );
+ ~ObjectFunction();
+};
+//__________________________________________________________________________________________________
+ObjectFunction::ObjectFunction( typelib_TypeDescription * pTypeDescr, void * fpFunc )
+ : _pTypeDescr( pTypeDescr )
+{
+ typelib_typedescription_acquire( _pTypeDescr );
+
+ unsigned char * pCode = (unsigned char *)somecode;
+ // a must be!
+ OSL_ENSHURE( (void *)this == (void *)pCode, "### unexpected!" );
+
+ // push ObjectFunction this
+ *pCode++ = 0x68;
+ *(void **)pCode = this;
+ pCode += sizeof(void *);
+ // jmp rel32 fpFunc
+ *pCode++ = 0xe9;
+ *(sal_Int32 *)pCode = ((unsigned char *)fpFunc) - pCode - sizeof(sal_Int32);
+}
+//__________________________________________________________________________________________________
+ObjectFunction::~ObjectFunction()
+{
+ typelib_typedescription_release( _pTypeDescr );
+}
+
+//==================================================================================================
+static void * __cdecl __copyConstruct( void * pExcThis, void * pSource, ObjectFunction * pThis )
+{
+ uno_copyData( pExcThis, pSource, pThis->_pTypeDescr, cpp_acquire );
+ return pExcThis;
+}
+//==================================================================================================
+static void * __cdecl __destruct( void * pExcThis, ObjectFunction * pThis )
+{
+ uno_destructData( pExcThis, pThis->_pTypeDescr, cpp_release );
+ return pExcThis;
+}
+
+// these are non virtual object methods; there is no this ptr on stack => ecx supplies _this_ ptr
+
+//==================================================================================================
+static __declspec(naked) copyConstruct()
+{
+ __asm
+ {
+ // ObjectFunction this already on stack
+ push [esp+8] // source exc object this
+ push ecx // exc object
+ call __copyConstruct
+ add esp, 12 // + ObjectFunction this
+ ret 4
+ }
+}
+//==================================================================================================
+static __declspec(naked) destruct()
+{
+ __asm
+ {
+ // ObjectFunction this already on stack
+ push ecx // exc object
+ call __destruct
+ add esp, 8 // + ObjectFunction this
+ ret
+ }
+}
+
+//==================================================================================================
+struct ExceptionType
+{
+ sal_Int32 _n0;
+ type_info * _pTypeInfo;
+ sal_Int32 _n1, _n2, _n3, _n4;
+ ObjectFunction * _pCopyCtor;
+ sal_Int32 _n5;
+
+ ExceptionType( typelib_TypeDescription * pTypeDescr )
+ : _n0( 0 )
+ , _n1( 0 )
+ , _n2( -1 )
+ , _n3( 0 )
+ , _n4( pTypeDescr->nSize )
+ , _pCopyCtor( new ObjectFunction( pTypeDescr, copyConstruct ) )
+ , _n5( 0 )
+ { _pTypeInfo = msci_getRTTI( OUStringToOString( pTypeDescr->pTypeName, RTL_TEXTENCODING_ASCII_US ) ); }
+ ~ExceptionType()
+ { delete _pCopyCtor; }
+};
+//==================================================================================================
+struct RaiseInfo
+{
+ sal_Int32 _n0;
+ ObjectFunction * _pDtor;
+ sal_Int32 _n2;
+ void * _types;
+ sal_Int32 _n3, _n4;
+
+ RaiseInfo( typelib_TypeDescription * pTypeDescr );
+ ~RaiseInfo();
+};
+//__________________________________________________________________________________________________
+RaiseInfo::RaiseInfo( typelib_TypeDescription * pTypeDescr )
+ : _n0( 0 )
+ , _pDtor( new ObjectFunction( pTypeDescr, destruct ) )
+ , _n2( 0 )
+ , _n3( 0 )
+ , _n4( 0 )
+{
+ // a must be
+ OSL_ENSHURE( sizeof(sal_Int32) == sizeof(ExceptionType *), "### pointer size differs from sal_Int32!" );
+
+ typelib_CompoundTypeDescription * pCompTypeDescr;
+
+ // info count
+ sal_Int32 nLen = 0;
+ for ( pCompTypeDescr = (typelib_CompoundTypeDescription*)pTypeDescr;
+ pCompTypeDescr; pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
+ {
+ ++nLen;
+ }
+
+ // info count accompanied by type info ptrs: type, base type, base base type, ...
+ _types = rtl_allocateMemory( sizeof(sal_Int32) + (sizeof(ExceptionType *) * nLen) );
+ *(sal_Int32 *)_types = nLen;
+
+ ExceptionType ** ppTypes = (ExceptionType **)((sal_Int32 *)_types + 1);
+
+ sal_Int32 nPos = 0;
+ for ( pCompTypeDescr = (typelib_CompoundTypeDescription*)pTypeDescr;
+ pCompTypeDescr; pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
+ {
+ ppTypes[nPos++] = new ExceptionType( (typelib_TypeDescription *)pCompTypeDescr );
+ }
+}
+//__________________________________________________________________________________________________
+RaiseInfo::~RaiseInfo()
+{
+ ExceptionType ** ppTypes = (ExceptionType **)((sal_Int32 *)_types + 1);
+ for ( sal_Int32 nTypes = *(sal_Int32 *)_types; nTypes--; )
+ delete ppTypes[nTypes];
+ rtl_freeMemory( _types );
+
+ delete _pDtor;
+}
+
+//==================================================================================================
+class ExceptionInfos
+{
+ Mutex _aMutex;
+ t_string2PtrMap _allRaiseInfos;
+public:
+ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
+
+ ExceptionInfos();
+ ~ExceptionInfos();
+};
+//__________________________________________________________________________________________________
+ExceptionInfos::ExceptionInfos()
+{
+}
+//__________________________________________________________________________________________________
+ExceptionInfos::~ExceptionInfos()
+{
+ TRACE( "> freeing exception infos... <\n" );
+
+ MutexGuard aGuard( _aMutex );
+ for ( t_string2PtrMap::const_iterator iPos( _allRaiseInfos.begin() );
+ iPos != _allRaiseInfos.end(); ++iPos )
+ {
+ delete (RaiseInfo *)(*iPos).second;
+ }
+}
+//__________________________________________________________________________________________________
+void ExceptionInfos::raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
+{
+ // construct cpp exception object
+ typelib_TypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
+
+ OSL_ENSHURE( pTypeDescr && (pTypeDescr->eTypeClass == typelib_TypeClass_STRUCT ||
+ pTypeDescr->eTypeClass == typelib_TypeClass_EXCEPTION),
+ "### can only throw types of class exception/ structs" );
+
+ void * pCppExc = alloca( pTypeDescr->nSize );
+ uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
+
+ // concatenate all types of exception for key
+ OUStringBuffer aKeyBuf;
+ typelib_CompoundTypeDescription * pCompTypeDescr;
+ for ( pCompTypeDescr = (typelib_CompoundTypeDescription *)pTypeDescr;
+ pCompTypeDescr; pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
+ {
+ aKeyBuf.append( ((typelib_TypeDescription *)pCompTypeDescr)->pTypeName );
+ }
+ OString aKey( OUStringToOString( aKeyBuf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ) );
+
+ MutexGuard aGuard( _aMutex );
+ const t_string2PtrMap::const_iterator iFind( _allRaiseInfos.find( aKey ) );
+
+ // a must be
+ OSL_ENSHURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" );
+ DWORD arFilterArgs[3];
+ arFilterArgs[0] = 0x19930520L;
+ arFilterArgs[1] = (DWORD)pCppExc;
+ arFilterArgs[2] = (DWORD)(iFind != _allRaiseInfos.end()
+ ? (*iFind).second // reuse existing info
+ : _allRaiseInfos[aKey] = new RaiseInfo( pTypeDescr )); // put into map
+
+ // this is the last chance to release anything not affected by stack unwinding:
+ // destruct uno exception
+ uno_any_destruct( pUnoExc, 0 );
+
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+
+ RaiseException( MSVC_ExceptionCode, EXCEPTION_NONCONTINUABLE, 3, arFilterArgs );
+}
+
+
+//##################################################################################################
+//#### exported ####################################################################################
+//##################################################################################################
+
+
+//##################################################################################################
+type_info * msci_getRTTI( const OString & rUNOname )
+{
+ static RTTInfos * s_pRTTIs = 0;
+ if (! s_pRTTIs)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pRTTIs)
+ {
+#ifdef LEAK_STATIC_DATA
+ s_pRTTIs = new RTTInfos();
+#else
+ static RTTInfos s_aRTTIs;
+ s_pRTTIs = &s_aRTTIs;
+#endif
+ }
+ }
+ return s_pRTTIs->getRTTI( rUNOname );
+}
+
+//##################################################################################################
+void msci_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
+{
+ static ExceptionInfos * s_pInfos = 0;
+ if (! s_pInfos)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pInfos)
+ {
+#ifdef LEAK_STATIC_DATA
+ s_pInfos = new ExceptionInfos();
+#else
+ static ExceptionInfos s_allExceptionInfos;
+ s_pInfos = &s_allExceptionInfos;
+#endif
+ }
+ }
+ s_pInfos->raiseException( pUnoExc, pUno2Cpp );
+}
+
+//##################################################################################################
+sal_Int32 msci_filterCppException(
+ LPEXCEPTION_POINTERS pPointers, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno )
+{
+ PEXCEPTION_RECORD pRecord = pPointers->ExceptionRecord;
+ if (pRecord->ExceptionCode == MSVC_ExceptionCode &&
+ pRecord->ExceptionFlags == EXCEPTION_NONCONTINUABLE &&
+ pRecord->NumberParameters == 3 &&
+// pRecord->ExceptionInformation[0] == 0x19930520 &&
+ pRecord->ExceptionInformation[1] &&
+ pRecord->ExceptionInformation[2])
+ {
+ void * types = ((RaiseInfo *)pRecord->ExceptionInformation[2])->_types;
+ if (types && *(sal_Int32 *)types) // count
+ {
+ ExceptionType * pType = *(ExceptionType **)((sal_Int32 *)types +1);
+ if (pType && pType->_pTypeInfo)
+ {
+ OUString aUNOname( OStringToOUString( toUNOname(
+ ((__type_info *)pType->_pTypeInfo)->_m_d_name ), RTL_TEXTENCODING_ASCII_US ) );
+ typelib_TypeDescription * pExcTypeDescr = 0;
+ typelib_typedescription_getByName( &pExcTypeDescr, aUNOname.pData );
+
+ if (pExcTypeDescr)
+ {
+ // construct uno exception any
+ uno_any_constructAndConvert( pUnoExc, (void *)pRecord->ExceptionInformation[1],
+ pExcTypeDescr, pCpp2Uno );
+ uno_destructData( (void *)pRecord->ExceptionInformation[1],
+ pExcTypeDescr, cpp_release );
+ typelib_typedescription_release( pExcTypeDescr );
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+ }
+ }
+ }
+ return EXCEPTION_CONTINUE_SEARCH;
+}
+
+}
+
+#pragma pack(pop)
+
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/makefile.mk b/bridges/source/cpp_uno/msvc_win32_intel/makefile.mk
new file mode 100644
index 000000000000..31435863d82a
--- /dev/null
+++ b/bridges/source/cpp_uno/msvc_win32_intel/makefile.mk
@@ -0,0 +1,119 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:28:49 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=msci_uno
+TARGET=msci_uno
+LIBTARGET=no
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+.IF "$(COM)" == "MSC"
+
+.IF "$(debug)" == ""
+CFLAGS += /O2gityb2 /Gs
+.ELSE
+CFLAGS += /Ob0
+.ENDIF
+
+SLOFILES= \
+ $(SLO)$/cpp2uno.obj \
+ $(SLO)$/uno2cpp.obj \
+ $(SLO)$/except.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1IMPLIB= i$(TARGET)
+
+SHL1OBJS= \
+ $(SLO)$/cpp2uno.obj \
+ $(SLO)$/uno2cpp.obj \
+ $(SLO)$/except.obj
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(SALLIB)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo LIBRARY $(SHL1TARGET) >$@
+ @echo DESCRIPTION 'MS Visual C++ bridge to UNO' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo uno_initEnvironment @3 >>$@
+ @echo uno_ext_getMapping @4 >>$@
+
+.ENDIF
+
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/msci.hxx b/bridges/source/cpp_uno/msvc_win32_intel/msci.hxx
new file mode 100644
index 000000000000..c934158a9ac2
--- /dev/null
+++ b/bridges/source/cpp_uno/msvc_win32_intel/msci.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * $RCSfile: msci.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:49 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <windows.h>
+
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+
+#define MSVC_ExceptionCode 0xe06d7363
+
+class type_info;
+typedef struct _uno_Any uno_Any;
+typedef struct _uno_Mapping uno_Mapping;
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//==================================================================================================
+type_info * msci_getRTTI(
+ const ::rtl::OString & rUNOname );
+
+//==================================================================================================
+sal_Int32 msci_filterCppException(
+ LPEXCEPTION_POINTERS pPointers, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno );
+
+//==================================================================================================
+void msci_raiseException(
+ uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
+
+}
+
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/uno2cpp.cxx b/bridges/source/cpp_uno/msvc_win32_intel/uno2cpp.cxx
new file mode 100644
index 000000000000..c0fa7227d3d5
--- /dev/null
+++ b/bridges/source/cpp_uno/msvc_win32_intel/uno2cpp.cxx
@@ -0,0 +1,494 @@
+/*************************************************************************
+ *
+ * $RCSfile: uno2cpp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:49 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma warning( disable : 4237 )
+#include <malloc.h>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
+#include <bridges/cpp_uno/bridge.hxx>
+#endif
+#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
+#include <bridges/cpp_uno/type_misc.hxx>
+#endif
+
+#include "msci.hxx"
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+
+//==================================================================================================
+inline static void callVirtualMethod( void * pThis, sal_Int32 nVtableIndex,
+ void * pRegisterReturn, typelib_TypeClass eReturnTypeClass,
+ sal_Int32 * pStackLongs, sal_Int32 nStackLongs )
+{
+ // parameter list is mixed list of * and values
+ // reference parameters are pointers
+
+ OSL_ENSHURE( pStackLongs && pThis, "### null ptr!" );
+ OSL_ENSHURE( (sizeof(void *) == 4) &&
+ (sizeof(sal_Int32) == 4), "### unexpected size of int!" );
+
+__asm
+ {
+ mov eax, nStackLongs
+ test eax, eax
+ je Lcall
+ // copy values
+ mov ecx, eax
+ shl eax, 2 // sizeof(sal_Int32) == 4
+ add eax, pStackLongs // params stack space
+Lcopy: sub eax, 4
+ push dword ptr [eax]
+ dec ecx
+ jne Lcopy
+Lcall:
+ // call
+ mov ecx, pThis
+ push ecx // this ptr
+ mov edx, [ecx] // pvft
+ mov eax, nVtableIndex
+ shl eax, 2 // sizeof(void *) == 4
+ add edx, eax
+ call [edx] // interface method call must be __cdecl!!!
+
+ // register return
+ mov ecx, eReturnTypeClass
+ cmp ecx, typelib_TypeClass_VOID
+ je Lcleanup
+ mov ebx, pRegisterReturn
+// int32
+ cmp ecx, typelib_TypeClass_LONG
+ je Lint32
+ cmp ecx, typelib_TypeClass_UNSIGNED_LONG
+ je Lint32
+ cmp ecx, typelib_TypeClass_ENUM
+ je Lint32
+// int8
+ cmp ecx, typelib_TypeClass_BOOLEAN
+ je Lint8
+ cmp ecx, typelib_TypeClass_BYTE
+ je Lint8
+// int16
+ cmp ecx, typelib_TypeClass_CHAR
+ je Lint16
+ cmp ecx, typelib_TypeClass_SHORT
+ je Lint16
+ cmp ecx, typelib_TypeClass_UNSIGNED_SHORT
+ je Lint16
+// float
+ cmp ecx, typelib_TypeClass_FLOAT
+ je Lfloat
+// double
+ cmp ecx, typelib_TypeClass_DOUBLE
+ je Ldouble
+// int64
+ cmp ecx, typelib_TypeClass_HYPER
+ je Lint64
+ cmp ecx, typelib_TypeClass_UNSIGNED_HYPER
+ je Lint64
+ jmp Lcleanup // no simple type
+Lint8:
+ mov byte ptr [ebx], al
+ jmp Lcleanup
+Lint16:
+ mov word ptr [ebx], ax
+ jmp Lcleanup
+Lfloat:
+ fstp dword ptr [ebx]
+ jmp Lcleanup
+Ldouble:
+ fstp qword ptr [ebx]
+ jmp Lcleanup
+Lint64:
+ mov dword ptr [ebx], eax
+ mov dword ptr [ebx+4], edx
+ jmp Lcleanup
+Lint32:
+ mov dword ptr [ebx], eax
+ jmp Lcleanup
+Lcleanup:
+ // cleanup stack (obsolete though because of function)
+ mov eax, nStackLongs
+ shl eax, 2 // sizeof(sal_Int32) == 4
+ add eax, 4 // this ptr
+ add esp, eax
+ }
+}
+
+//==================================================================================================
+inline static void cpp_call(
+ cppu_unoInterfaceProxy * pThis,
+ sal_Int32 nVtableCall,
+ typelib_TypeDescriptionReference * pReturnTypeRef,
+ sal_Int32 nParams, typelib_MethodParameter * pParams,
+ sal_Int32 nExceptions, typelib_TypeDescriptionReference ** ppExceptionRefs,
+ void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
+{
+ // max space for: [complex ret ptr], values|ptr ...
+ char * pCppStack = (char *)alloca( sizeof(sal_Int32) + (nParams * sizeof(sal_Int64)) );
+ char * pCppStackStart = pCppStack;
+
+ // return
+ typelib_TypeDescription * pReturnTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
+ OSL_ENSHURE( pReturnTypeDescr, "### expected return type description!" );
+
+ void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
+
+ if (pReturnTypeDescr)
+ {
+ if (cppu_isSimpleType( pReturnTypeDescr ))
+ {
+ pCppReturn = pUnoReturn; // direct way for simple types
+ }
+ else
+ {
+ // complex return via ptr
+ pCppReturn = *(void **)pCppStack = (cppu_relatesToInterface( pReturnTypeDescr )
+ ? alloca( pReturnTypeDescr->nSize )
+ : pUnoReturn); // direct way
+ pCppStack += sizeof(void *);
+ }
+ }
+
+ // stack space
+
+ OSL_ENSHURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
+ // args
+ void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams );
+ // indizes of values this have to be converted (interface conversion cpp<=>uno)
+ sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
+ // type descriptions for reconversions
+ typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
+
+ sal_Int32 nTempIndizes = 0;
+
+ for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
+ {
+ const typelib_MethodParameter & rParam = pParams[nPos];
+ typelib_TypeDescription * pParamTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
+
+ if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr ))
+ {
+ uno_copyAndConvertData( pCppArgs[nPos] = pCppStack, pUnoArgs[nPos], pParamTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+
+ switch (pParamTypeDescr->eTypeClass)
+ {
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ case typelib_TypeClass_DOUBLE:
+ pCppStack += sizeof(sal_Int32); // extra long
+ }
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ else // ptr to complex value | ref
+ {
+ if (! rParam.bIn) // is pure out
+ {
+ // cpp out is constructed mem, uno out is not!
+ uno_constructData(
+ *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
+ pParamTypeDescr );
+ pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ // is in/inout
+ else if (cppu_relatesToInterface( pParamTypeDescr ))
+ {
+ uno_copyAndConvertData(
+ *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
+ pUnoArgs[nPos], pParamTypeDescr,
+ &pThis->pBridge->aUno2Cpp );
+
+ pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
+ // will be released at reconversion
+ ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
+ }
+ else // direct way
+ {
+ *(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
+ // no longer needed
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ }
+ pCppStack += sizeof(sal_Int32); // standard parameter length
+ }
+
+ // only try-finally/ try-except statements possible...
+ __try
+ {
+ __try
+ {
+ // pCppI is msci this pointer
+ callVirtualMethod(
+ pThis->pCppI, nVtableCall,
+ pCppReturn, pReturnTypeDescr->eTypeClass,
+ (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+
+ // NO exception occured...
+ *ppUnoExc = 0;
+
+ // reconvert temporary params
+ while (nTempIndizes--)
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+ typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
+
+ if (pParams[nIndex].bIn)
+ {
+ if (pParams[nIndex].bOut) // inout
+ {
+ uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
+ uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ }
+ }
+ else // pure out
+ {
+ uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ }
+ // destroy temp cpp param => cpp: every param was constructed
+ uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
+
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr );
+ }
+ // return value
+ if (pCppReturn && pUnoReturn != pCppReturn)
+ {
+ uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
+ &pThis->pBridge->aCpp2Uno );
+ uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
+ }
+ }
+ __except (msci_filterCppException( GetExceptionInformation(),
+ *ppUnoExc, &pThis->pBridge->aCpp2Uno ))
+ {
+ // *ppUnoExc is untouched and any was constructed by filter function
+ // __finally block will be called
+ return;
+ }
+ }
+ __finally
+ {
+ // cleanup of params was already done in reconversion loop iff no exception occured;
+ // this is quicker than getting all param descriptions twice!
+ // so cleanup only iff an exception occured:
+ if (*ppUnoExc)
+ {
+ // temporary params
+ while (nTempIndizes--)
+ {
+ sal_Int32 nIndex = pTempIndizes[nTempIndizes];
+ // destroy temp cpp param => cpp: every param was constructed
+ uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
+ TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
+ }
+ }
+ // return type
+ if (pReturnTypeDescr)
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
+ }
+}
+
+//==================================================================================================
+void SAL_CALL cppu_unoInterfaceProxy_dispatch(
+ uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ // is my surrogate
+ cppu_unoInterfaceProxy * pThis = static_cast< cppu_unoInterfaceProxy * >( pUnoI );
+ typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
+
+ switch (pMemberDescr->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ // determine vtable call index
+ sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
+ OSL_ENSHURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
+
+ sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
+
+ typelib_TypeDescriptionReference * pRuntimeExcRef = 0;
+
+ if (pReturn)
+ {
+ // dependent dispatch
+ cpp_call( pThis, nVtableCall,
+ ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
+ 0, 0, // no params
+ 1, &pRuntimeExcRef, // RuntimeException
+ pReturn, pArgs, ppException );
+ }
+ else
+ {
+ // is SET
+ typelib_MethodParameter aParam;
+ aParam.pTypeRef =
+ ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
+ aParam.bIn = sal_True;
+ aParam.bOut = sal_False;
+
+ typelib_TypeDescriptionReference * pReturnTypeRef = 0;
+ OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
+ typelib_typedescriptionreference_new(
+ &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
+
+ // dependent dispatch
+ cpp_call( pThis, nVtableCall +1, // get, then set method
+ pReturnTypeRef,
+ 1, &aParam,
+ 1, &pRuntimeExcRef,
+ pReturn, pArgs, ppException );
+
+ typelib_typedescriptionreference_release( pReturnTypeRef );
+ }
+
+ break;
+ }
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ // determine vtable call index
+ sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
+ OSL_ENSHURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
+
+ sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
+ OSL_ENSHURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
+
+ switch (nVtableCall)
+ {
+ // standard calls
+ case 1: // acquire uno interface
+ (*pUnoI->acquire)( pUnoI );
+ *ppException = 0;
+ break;
+ case 2: // release uno interface
+ (*pUnoI->release)( pUnoI );
+ *ppException = 0;
+ break;
+ case 0: // queryInterface() opt
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
+ OSL_ASSERT( pTD );
+
+ uno_Interface * pInterface = 0;
+ (*pThis->pBridge->pUnoEnv->getRegisteredInterface)(
+ pThis->pBridge->pUnoEnv,
+ (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
+
+ if (pInterface)
+ {
+ uno_any_construct( reinterpret_cast< uno_Any * >( pReturn ), &pInterface, pTD, 0 );
+ (*pInterface->release)( pInterface );
+ TYPELIB_DANGER_RELEASE( pTD );
+ *ppException = 0;
+ break;
+ }
+ TYPELIB_DANGER_RELEASE( pTD );
+ } // else perform queryInterface()
+ default:
+ // dependent dispatch
+ cpp_call( pThis, nVtableCall,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nExceptions,
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->ppExceptions,
+ pReturn, pArgs, ppException );
+ }
+ break;
+ }
+ default:
+ {
+ ::com::sun::star::uno::RuntimeException aExc(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
+ pThis->pCppI );
+
+ typelib_TypeDescription * pTD = 0;
+ const Type & rExcType = ::getCppuType( (const ::com::sun::star::uno::RuntimeException *)0 );
+ TYPELIB_DANGER_GET( &pTD, rExcType.getTypeLibType() );
+ uno_any_construct( *ppException, &aExc, pTD, 0 );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ }
+}
+
+}
+
diff --git a/bridges/source/remote/context/context.cxx b/bridges/source/remote/context/context.cxx
new file mode 100644
index 000000000000..8e7ffc7763cc
--- /dev/null
+++ b/bridges/source/remote/context/context.cxx
@@ -0,0 +1,552 @@
+/*************************************************************************
+ *
+ * $RCSfile: context.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:49 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <list>
+#include <hash_map>
+#include <utility>
+
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+#include <osl/mutex.hxx>
+
+#include <rtl/ustring>
+
+#include <bridges/remote/context.h>
+#include <bridges/remote/remote.h>
+#include <bridges/remote/connection.h>
+
+using namespace ::std;
+using namespace ::osl;
+using namespace ::rtl;
+
+namespace remote_context
+{
+
+class remote_ContextImpl :
+ public remote_Context
+{
+public:
+ remote_ContextImpl( remote_Connection *pConnection,
+ rtl_uString *pIdStr,
+ rtl_uString *pDescription,
+ rtl_uString *pProtocol,
+ remote_InstanceProvider *pProvider );
+ ~remote_ContextImpl();
+
+ static void SAL_CALL thisAcquire( uno_Context * );
+ static void SAL_CALL thisRelease( uno_Context * );
+ static void * SAL_CALL thisQuery( uno_Context * , rtl_uString * );
+ static void SAL_CALL thisAddDisposingListener( remote_Context * , remote_DisposingListener * );
+ static void SAL_CALL thisRemoveDisposingListener( remote_Context *, remote_DisposingListener *);
+ static void SAL_CALL thisDispose( remote_Context *);
+public:
+ oslInterlockedCount m_nRef;
+ sal_Bool m_bDisposed;
+ list < remote_DisposingListener * > m_lstListener;
+ Mutex m_mutex;
+};
+
+
+
+
+struct equalOUString_Impl
+{
+ sal_Bool operator()(const OUString & s1, const OUString & s2) const
+ { return s1 == s2; }
+};
+
+struct hashOUString_Impl
+{
+ size_t operator()(const OUString & rName) const
+ { return rName.hashCode(); }
+};
+
+typedef hash_map
+<
+ OUString,
+ void *,
+ hashOUString_Impl,
+ equalOUString_Impl
+>
+ContextMap;
+
+#ifdef DEBUG
+struct MyCounter
+{
+ MyCounter( sal_Char *pName ) :
+ m_pName ( pName ),
+ m_nCounter( 0 )
+ {
+ }
+ ~MyCounter()
+ {
+ if( m_nCounter ) {
+ printf( "%s : %d left\n", m_pName , m_nCounter );
+ }
+ }
+ void acquire()
+ { m_nCounter ++; }
+ void release()
+ { m_nCounter --; }
+
+
+ sal_Int32 m_nCounter;
+ sal_Char *m_pName;
+};
+static MyCounter thisCounter( "DEBUG : Context" );
+#endif
+
+class ContextAdmin;
+
+ContextAdmin *g_pTheContext = 0;
+
+
+
+class ContextAdmin
+{
+public:
+ static ContextAdmin *getInstance();
+
+ // listener administration
+ void addContextListener( remote_contextListenerFunc listener , void *pObject );
+ void removeContextListener( remote_contextListenerFunc listener , void *pObject );
+
+ void fire( sal_Int32 nRemoteContextMode,
+ rtl_uString *sName,
+ rtl_uString *sDescription );
+
+ // context administration
+ uno_Context *createAndRegisterContext(
+ remote_Connection *pConnection,
+ rtl_uString *pIdStr,
+ rtl_uString *pDescription,
+ rtl_uString *pProtocol,
+ remote_InstanceProvider *pInstanceProvider );
+
+ void revokeContext( uno_Context *pRemoteContext );
+
+ uno_Context *get( rtl_uString *pHost );
+
+ rtl_uString ** getConnectionList(
+ sal_Int32 *pnStringCount ,
+ void * ( SAL_CALL * memAlloc ) ( sal_uInt32 nBytesToAlloc ) );
+
+private:
+ ::osl::Mutex m_mutex;
+
+ ContextMap m_mapContext;
+
+ ::std::list< ::std::pair< void *, void *> > m_lstListener;
+};
+
+ContextAdmin *ContextAdmin::getInstance()
+{
+ if( ! g_pTheContext ) {
+ ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! g_pTheContext ) {
+ static ContextAdmin admin;
+ g_pTheContext = &admin;
+ }
+ }
+ return g_pTheContext;
+}
+
+void ContextAdmin::addContextListener( remote_contextListenerFunc listener , void *pObject )
+{
+ ::osl::MutexGuard guard( m_mutex );
+
+ m_lstListener.push_back( ::std::pair< void * , void * > ( (void*) listener , pObject ) );
+}
+
+void ContextAdmin::removeContextListener( remote_contextListenerFunc listener , void *pObject )
+{
+ ::osl::MutexGuard guard( m_mutex );
+
+ for( ::std::list< ::std::pair< void *, void *> >::iterator ii = m_lstListener.begin() ;
+ ii != m_lstListener.end() ;
+ ++ii )
+ {
+ if( (*ii).first == (void*)listener &&
+ (*ii).second == (void*)pObject )
+ {
+ m_lstListener.erase( ii );
+ break;
+ }
+ }
+}
+
+void ContextAdmin::fire(
+ sal_Int32 nRemoteContextMode,
+ rtl_uString *pName,
+ rtl_uString *sDescription )
+{
+ ::osl::MutexGuard guard( m_mutex );
+ ::std::list< ::std::pair< void *, void *> > lstListener = m_lstListener;
+
+ for( ::std::list< ::std::pair< void *, void *> >::iterator ii = lstListener.begin() ;
+ ii != lstListener.end();
+ ++ii)
+ {
+ remote_contextListenerFunc listener = (remote_contextListenerFunc) (*ii).first;
+ listener( (*ii).second , nRemoteContextMode , pName, sDescription );
+ }
+}
+
+uno_Context *ContextAdmin::createAndRegisterContext( remote_Connection *pConnection,
+ rtl_uString *pIdStr,
+ rtl_uString *pDescription,
+ rtl_uString *pProtocol,
+ remote_InstanceProvider *pInstanceProvider )
+{
+ ::osl::MutexGuard guard( m_mutex );
+
+ uno_Context *pContext = get( pIdStr );
+ if( pContext )
+ {
+ pContext->release( pContext );
+ return 0;
+ }
+
+ remote_ContextImpl *p = new remote_ContextImpl( pConnection,
+ pIdStr,
+ pDescription,
+ pProtocol,
+ pInstanceProvider );
+
+ p->aBase.acquire( (uno_Context*) p );
+
+ m_mapContext[ OUString( pIdStr) ] = (void*) p;
+
+ fire( REMOTE_CONTEXT_CREATE , pIdStr , pDescription );
+ return ( uno_Context * )p;
+}
+
+
+void ContextAdmin::revokeContext( uno_Context *pRemoteContext )
+{
+ ::osl::MutexGuard guard( m_mutex );
+
+ remote_ContextImpl *p = ( remote_ContextImpl * ) pRemoteContext;
+
+ ContextMap::iterator ii = m_mapContext.find( p->m_pName );
+ OSL_ASSERT( ii != m_mapContext.end() );
+ m_mapContext.erase( ii );
+
+ fire( REMOTE_CONTEXT_DESTROY , p->m_pName , p->m_pDescription );
+
+}
+
+uno_Context *ContextAdmin::get( rtl_uString *pHost )
+{
+ ::osl::MutexGuard guard( m_mutex );
+
+ ContextMap::iterator ii = m_mapContext.find( OUString( (rtl_uString*)pHost ) );
+ if( ii == m_mapContext.end() )
+ {
+ return 0;
+ }
+
+ uno_Context *p = ( uno_Context * ) (*ii).second;
+ p->acquire( p );
+ return p;
+}
+
+
+rtl_uString ** ContextAdmin::getConnectionList(
+ sal_Int32 *pnStringCount ,
+ void * ( SAL_CALL * memAlloc ) ( sal_uInt32 nBytesToAlloc ) )
+{
+ ::osl::MutexGuard guard( m_mutex );
+
+ *pnStringCount = m_mapContext.size();
+ rtl_uString **ppReturn = ( rtl_uString ** )
+ memAlloc( sizeof( rtl_uString * ) * m_mapContext.size() );
+ memset( ppReturn , 0 , sizeof( rtl_uString * ) * m_mapContext.size() );
+
+ sal_Int32 i = 0;
+ for( ContextMap::iterator ii = m_mapContext.begin() ;
+ ii != m_mapContext.end();
+ ++ii, i++ )
+ {
+ rtl_uString_assign( &( ppReturn[i] ), (*ii).first.pData );
+ }
+
+ return ppReturn;
+}
+
+
+
+/*****************************
+ * remote_ContextImpl implementation
+ ****************************/
+
+
+
+remote_ContextImpl::remote_ContextImpl( remote_Connection *pConnection ,
+ rtl_uString *pIdStr,
+ rtl_uString *pDescription,
+ rtl_uString *pProtocol,
+ remote_InstanceProvider *pProvider ) :
+ m_nRef( 0 ),
+ m_bDisposed( sal_False )
+{
+ m_pConnection = pConnection;
+ m_pConnection->acquire( m_pConnection );
+
+ m_pInstanceProvider = pProvider;
+ if( m_pInstanceProvider )
+ {
+ m_pInstanceProvider->acquire( pProvider );
+ }
+
+ m_pName = pIdStr;
+ rtl_uString_acquire( m_pName );
+
+ m_pDescription = pDescription;
+ rtl_uString_acquire( m_pDescription );
+
+ m_pProtocol = pProtocol;
+ rtl_uString_acquire( pProtocol );
+
+ aBase.acquire = thisAcquire;
+ aBase.release = thisRelease;
+ addDisposingListener = thisAddDisposingListener;
+ removeDisposingListener = thisRemoveDisposingListener;
+ dispose = thisDispose;
+#ifdef DEBUG
+ thisCounter.acquire();
+#endif
+}
+
+remote_ContextImpl::~remote_ContextImpl()
+{
+ // disposed must have been called
+ OSL_ASSERT( m_bDisposed );
+
+ rtl_uString_release( m_pName );
+ rtl_uString_release( m_pDescription );
+ rtl_uString_release( m_pProtocol );
+#ifdef DEBUG
+ thisCounter.release();
+#endif
+
+}
+
+
+void remote_ContextImpl::thisAddDisposingListener( remote_Context *pRemoteC ,
+ remote_DisposingListener *pListener )
+{
+ remote_ContextImpl *pImpl = (remote_ContextImpl * ) pRemoteC;
+
+ ::osl::MutexGuard guard( pImpl->m_mutex );
+
+ pListener->acquire( pListener );
+ pImpl->m_lstListener.push_back( pListener );
+}
+
+void remote_ContextImpl::thisRemoveDisposingListener( remote_Context *pRemoteC,
+ remote_DisposingListener *pListener)
+{
+ remote_ContextImpl *pImpl = (remote_ContextImpl * ) pRemoteC;
+ MutexGuard guard( pImpl->m_mutex );
+
+ for( list< remote_DisposingListener * >::iterator ii = pImpl->m_lstListener.begin() ;
+ ii != pImpl->m_lstListener.end();
+ ++ii )
+ {
+ if( (*ii) == pListener )
+ {
+ pImpl->m_lstListener.erase( ii );
+ pListener->release( pListener );
+ break;
+ }
+ }
+}
+
+void remote_ContextImpl::thisDispose( remote_Context *pRemoteC )
+{
+ remote_ContextImpl *pImpl = ( remote_ContextImpl * )pRemoteC;
+
+ MutexGuard guard( pImpl->m_mutex );
+ if( ! pImpl->m_bDisposed )
+ {
+ pImpl->m_bDisposed = sal_True;
+ ContextAdmin::getInstance()->revokeContext( (uno_Context * ) pRemoteC );
+
+ if( pImpl->m_pInstanceProvider )
+ {
+ pImpl->m_pInstanceProvider->release( pImpl->m_pInstanceProvider );
+ pImpl->m_pInstanceProvider = 0;
+ }
+
+ pImpl->m_pConnection->release( pImpl->m_pConnection );
+ pImpl->m_pConnection = 0;
+
+ list< remote_DisposingListener * > lst = pImpl->m_lstListener;
+ pImpl->m_lstListener.clear();
+
+ for( list < remote_DisposingListener * >::iterator ii = lst.begin();
+ ii != lst.end();
+ ++ii )
+ {
+ (*ii)->disposing( (*ii) , pImpl->m_pName );
+ (*ii)->release( (*ii) );
+ }
+
+ }
+}
+
+
+
+void remote_ContextImpl::thisAcquire( uno_Context *pRemoteC )
+{
+ remote_ContextImpl *p = SAL_REINTERPRET_CAST(remote_ContextImpl * ,pRemoteC );
+ osl_incrementInterlockedCount( &(p->m_nRef) );
+}
+
+void remote_ContextImpl::thisRelease( uno_Context *pRemoteC )
+{
+ remote_ContextImpl *p = SAL_REINTERPRET_CAST( remote_ContextImpl * , pRemoteC );
+ if (! osl_decrementInterlockedCount( &(p->m_nRef) ))
+ {
+ // enshure, that this piece of code is not reentered
+ osl_incrementInterlockedCount( &(p->m_nRef) );
+
+ // dispose, if necessary
+ p->dispose( p );
+
+ // restore the counter
+ osl_decrementInterlockedCount( &(p->m_nRef) );
+
+ if( 0 == p->m_nRef )
+ {
+ delete p;
+ }
+ else
+ {
+ // reanimated, but disposed !
+ }
+ }
+}
+
+void *remote_ContextImpl::thisQuery( uno_Context * , rtl_uString * )
+{
+ return 0;
+}
+
+
+} // end namespace remote_context
+
+
+using namespace remote_context;
+
+//-----------------------
+//
+// C-Interface
+//
+//-----------------------
+extern "C" SAL_DLLEXPORT remote_Context * SAL_CALL
+remote_getContext( rtl_uString *pIdString )
+{
+ return (remote_Context *) ContextAdmin::getInstance()->get( pIdString );
+}
+
+
+
+extern "C" SAL_DLLEXPORT remote_Context * SAL_CALL
+remote_createContext( remote_Connection *pConnection,
+ rtl_uString *pIdStr,
+ rtl_uString *pDescription,
+ rtl_uString *pProtocol,
+ remote_InstanceProvider *pProvider )
+{
+ remote_ContextImpl *p = (remote_ContextImpl * )
+ ContextAdmin::getInstance()->createAndRegisterContext(
+ pConnection ,
+ pIdStr ,
+ pDescription,
+ pProtocol,
+ pProvider );
+
+ return (remote_Context * )p;
+}
+
+
+extern "C" SAL_DLLEXPORT void SAL_CALL
+remote_addContextListener( remote_contextListenerFunc listener, void *pObject )
+{
+ ContextAdmin::getInstance()->addContextListener( listener , pObject );
+}
+
+extern "C" SAL_DLLEXPORT void SAL_CALL
+remote_removeContextListener( remote_contextListenerFunc listener , void *pObject )
+{
+ ContextAdmin::getInstance()->removeContextListener( listener , pObject );
+}
+
+extern "C" SAL_DLLEXPORT rtl_uString ** SAL_CALL
+remote_getContextList(
+ sal_Int32 *pnStringCount,
+ void * ( SAL_CALL * memAlloc ) ( sal_uInt32 nBytesToAlloc ) )
+{
+ return ContextAdmin::getInstance()->getConnectionList( pnStringCount , memAlloc );
+}
diff --git a/bridges/source/remote/context/exports.dxp b/bridges/source/remote/context/exports.dxp
new file mode 100644
index 000000000000..dcef3c369b10
--- /dev/null
+++ b/bridges/source/remote/context/exports.dxp
@@ -0,0 +1,5 @@
+remote_getContext
+remote_createContext
+remote_getContextList
+remote_removeContextListener
+remote_addContextListener \ No newline at end of file
diff --git a/bridges/source/remote/context/makefile.mk b/bridges/source/remote/context/makefile.mk
new file mode 100644
index 000000000000..0d74b2d01dd6
--- /dev/null
+++ b/bridges/source/remote/context/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:28:49 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=bridges
+TARGET=rmcxt
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+.INCLUDE : $(PRJ)$/version.mk
+# ------------------------------------------------------------------
+
+UNOUCRDEP=$(SOLARUCRDIR)$/uce.rdb
+UNOUCRRDB=$(SOLARUCRDIR)$/uce.rdb
+
+# output directory (one dir for each project)
+UNOUCROUT=$(OUT)$/inc$/$(PRJNAME)$/$(TARGET)
+
+# adding to inludepath
+INCPRE+=$(UNOUCROUT)
+
+UNOTYPES=
+
+SLOFILES= $(SLO)$/context.obj
+
+SHL1TARGET= $(RMCXT_TARGET)$(RMCXT_MAJOR)
+
+SHL1STDLIBS= \
+ $(VOSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/bridges/source/remote/idl/corba.idl b/bridges/source/remote/idl/corba.idl
new file mode 100644
index 000000000000..7c7971d43f05
--- /dev/null
+++ b/bridges/source/remote/idl/corba.idl
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * $RCSfile: corba.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:49 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+module com
+{
+module sun
+{
+module star
+{
+
+module corba
+{
+
+ // CosBridging module
+ typedef unsigned long ObjectSystemID;
+ typedef sequence< byte > OpaqueData;
+
+ struct OneThreadID
+ {
+ ObjectSystemID objSysID;
+ OpaqueData threadID;
+ };
+
+ typedef sequence<OneThreadID> ThreadIDs;
+
+ struct LogicalThreadID // Service context
+ {
+ ThreadIDs IDs;
+ };
+
+ struct CorbaString8
+ {
+ string theString;
+ };
+
+ struct CorbaUnion
+ {
+ long dummy;
+ };
+
+ struct ObjectKey
+ {
+ CorbaString8 sOid;
+ CorbaString8 sType;
+ };
+
+ enum TCKind
+ {
+ tk_null, tk_void,
+ tk_short, tk_long, tk_ushort, tk_ulong,
+ tk_float, tk_double, tk_boolean, tk_char,
+ tk_octet, tk_any, tk_TypeCode, tk_Principal, tk_objref,
+ tk_struct, tk_union, tk_enum, tk_string,
+ tk_sequence, tk_array, tk_alias, tk_except,
+ tk_longlong, tk_ulonglong, tk_longdouble,
+ tk_wchar, tk_wstring, tk_fixed,
+ tk_value, tk_value_box,
+ tk_native,
+ tk_abstract_interface
+ };
+};
+
+};
+};
+};
diff --git a/bridges/source/remote/static/helper.cxx b/bridges/source/remote/static/helper.cxx
new file mode 100644
index 000000000000..5fbd68350771
--- /dev/null
+++ b/bridges/source/remote/static/helper.cxx
@@ -0,0 +1,232 @@
+/*************************************************************************
+ *
+ * $RCSfile: helper.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <rtl/alloc.h>
+#include <osl/diagnose.h>
+
+#include <bridges/remote/helper.hxx>
+
+#include <bridges/remote/stub.hxx>
+#include <bridges/remote/proxy.hxx>
+#include <bridges/remote/remote.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+
+namespace bridges_remote
+{
+
+void SAL_CALL remote_createStub (
+ remote_Interface **ppRemoteI,
+ rtl_uString *pOid ,
+ typelib_TypeDescriptionReference *pTypeRef,
+ uno_Environment *pEnvRemote )
+{
+ typelib_TypeDescription *pType = 0;
+ typelib_typedescriptionreference_getDescription( &pType, pTypeRef );
+
+ pEnvRemote->pExtEnv->getRegisteredInterface(
+ pEnvRemote->pExtEnv,
+ (void **)ppRemoteI,
+ pOid,
+ (typelib_InterfaceTypeDescription* )pType );
+
+ if( *ppRemoteI )
+ {
+ if( (*ppRemoteI)->acquire == ::bridges_remote::Remote2RemoteStub::thisAcquire ) {
+
+ // send a release to remote
+ ((::bridges_remote::Remote2RemoteStub *)*ppRemoteI)->releaseRemote();
+ }
+ else
+ {
+ // Uno2RemoteStub
+ // no release necessary
+ }
+ }
+ else
+ {
+ remote_BridgeImpl *pImpl = ((remote_Context *)pEnvRemote->pContext)->m_pBridgeImpl;
+ *ppRemoteI =
+ new ::bridges_remote::Remote2RemoteStub(
+ pOid,
+ (typelib_InterfaceTypeDescription * ) pType,
+ pEnvRemote,
+ pImpl->m_sendRequest);
+
+ // ppRemoteI may change during registration
+ pEnvRemote->pExtEnv->registerProxyInterface(
+ pEnvRemote->pExtEnv,
+ (void **) ppRemoteI,
+ ::bridges_remote::Remote2RemoteStub::thisFree,
+ pOid,
+ (typelib_InterfaceTypeDescription * ) pType );
+ }
+
+ typelib_typedescription_release( pType );
+}
+
+void SAL_CALL remote_sendQueryInterface(
+ uno_Environment *pEnvRemote,
+ remote_Interface **ppRemoteI,
+ rtl_uString *pOid ,
+ typelib_TypeDescriptionReference *pTypeRef
+ )
+{
+ OSL_ASSERT( ppRemoteI );
+
+ typelib_InterfaceTypeDescription *pType = 0;
+ typelib_typedescriptionreference_getDescription( (typelib_TypeDescription ** )&pType, pTypeRef );
+
+ if( *ppRemoteI )
+ {
+ (*ppRemoteI)->release( *ppRemoteI );
+ (*ppRemoteI) = 0;
+ }
+
+ remote_BridgeImpl *pImpl = ((remote_Context *)pEnvRemote->pContext)->m_pBridgeImpl;
+
+ Type type = ::getCppuType( (Reference < XInterface > *)0 );
+
+ // get type for queryInterface
+ OUString sCompleteMethodName = type.getTypeName();
+ sCompleteMethodName += OUString::createFromAscii("::queryInterface");
+
+ typelib_InterfaceMemberTypeDescription *pMemberType = 0;
+ typelib_typedescription_getByName(
+ (typelib_TypeDescription **) &pMemberType,
+ sCompleteMethodName.pData );
+
+ OSL_ASSERT( pMemberType );
+
+ uno_Any anyInterface;
+ anyInterface.pType = 0;
+ anyInterface.pData = 0;
+
+ void *pReturn = &anyInterface;
+ void *ppArgs[1];
+
+ ppArgs[0] = 0;
+ typelib_TypeDescriptionReference *pRef = 0;
+ typelib_typedescriptionreference_new( &pRef ,
+ pType->aBase.eTypeClass,
+ pType->aBase.pTypeName);
+
+ ppArgs[0] = &pRef;
+
+ uno_Any anyException;
+ uno_Any *pAnyException = &anyException;
+
+ // do the queryInterface
+ pImpl->m_sendRequest(
+ pEnvRemote,
+ (typelib_TypeDescription * ) pMemberType,
+ pOid,
+ pType,
+ pReturn,
+ ppArgs,
+ &pAnyException );
+
+
+ // now release everything
+ typelib_typedescriptionreference_release( pRef );
+ typelib_typedescription_release( (typelib_TypeDescription * ) pMemberType );
+
+ if( pAnyException )
+ {
+ uno_any_destruct( pAnyException , 0 );
+ }
+ else
+ {
+ // set out parameter
+ if( typelib_TypeClass_INTERFACE == anyInterface.pType->eTypeClass )
+ {
+ *ppRemoteI = *( remote_Interface ** ) anyInterface.pData;
+ rtl_freeMemory( anyInterface.pData );
+ }
+ typelib_typedescriptionreference_release( anyInterface.pType );
+ }
+
+ typelib_typedescription_release( (typelib_TypeDescription * ) pType );
+}
+
+
+void SAL_CALL remote_retrieveOidFromProxy(
+ remote_Interface *pRemoteI,
+ rtl_uString **ppOid )
+{
+ if( pRemoteI->acquire == ::bridges_remote::Remote2RemoteStub::thisAcquire )
+ {
+ // Remote2RemoteStub
+ ::bridges_remote::Remote2RemoteStub *pStub = (::bridges_remote::Remote2RemoteStub * ) pRemoteI;
+ rtl_uString_newFromString( ppOid , pStub->m_sOid.pData );
+ }
+ else
+ {
+ // Uno2RemoteStub
+ ::bridges_remote::Uno2RemoteStub *pStub = (::bridges_remote::Uno2RemoteStub * ) pRemoteI;
+ rtl_uString_newFromString( ppOid , pStub->m_sOid.pData );
+ pRemoteI->acquire( pRemoteI );
+ }
+}
+
+}
diff --git a/bridges/source/remote/static/makefile.mk b/bridges/source/remote/static/makefile.mk
new file mode 100644
index 000000000000..22f2b2516a91
--- /dev/null
+++ b/bridges/source/remote/static/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=bridges
+TARGET=bridges_remote_static
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+BRIDGES_MARSHALLIB = bridges_marshal.lib
+#CPPUMAKERFLAGS += -C
+UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb
+
+# output directory (one dir for each project)
+UNOUCROUT=$(OUT)$/inc
+
+# adding to inludepath
+INCPRE+=$(UNOUCROUT)
+
+UNOTYPES= com.sun.star.uno.XInterface \
+ com.sun.star.uno.TypeClass
+
+
+SLOFILES= \
+ $(SLO)$/proxy.obj \
+ $(SLO)$/stub.obj \
+ $(SLO)$/remote.obj \
+ $(SLO)$/mapping.obj \
+ $(SLO)$/helper.obj \
+ $(SLO)$/remote_types.obj
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/bridges/source/remote/static/mapping.cxx b/bridges/source/remote/static/mapping.cxx
new file mode 100644
index 000000000000..91706e5aab7e
--- /dev/null
+++ b/bridges/source/remote/static/mapping.cxx
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * $RCSfile: mapping.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <osl/diagnose.h>
+
+#include <bridges/remote/proxy.hxx>
+#include <bridges/remote/stub.hxx>
+#include <bridges/remote/counter.hxx>
+#include <bridges/remote/mapping.hxx>
+
+namespace bridges_remote {
+
+RemoteMapping::RemoteMapping( uno_Environment *pEnvUno_ ,
+ uno_Environment *pEnvRemote_,
+ uno_MapInterfaceFunc func,
+ const ::rtl::OUString sPurpose) :
+ m_nRef( 1 ),
+ m_sPurpose( sPurpose )
+{
+ pEnvUno = pEnvUno_;
+ pEnvRemote = pEnvRemote_;
+
+ pEnvUno->acquire( pEnvUno );
+ pEnvRemote->acquire( pEnvRemote );
+
+ aBase.mapInterface = func;
+ aBase.acquire = thisAcquire;
+ aBase.release = thisRelease;
+}
+
+void RemoteMapping::thisFree( uno_Mapping * p )
+{
+ delete ( RemoteMapping * ) p;
+}
+
+RemoteMapping::~RemoteMapping( )
+{
+ pEnvUno->release( pEnvUno );
+ pEnvRemote->release( pEnvRemote );
+}
+
+void RemoteMapping::thisAcquire( uno_Mapping *pMap )
+{
+ RemoteMapping *p = SAL_REINTERPRET_CAST( RemoteMapping * , pMap );
+ if( 1 == osl_incrementInterlockedCount( &(p->m_nRef) ) )
+ {
+ if( RemoteMapping::remoteToUno == pMap->mapInterface )
+ {
+ uno_registerMapping( &pMap ,
+ RemoteMapping::thisFree,
+ p->pEnvRemote ,
+ p->pEnvUno ,
+ p->m_sPurpose.pData );
+ }
+ else
+ {
+ uno_registerMapping( &pMap ,
+ RemoteMapping::thisFree,
+ p->pEnvUno ,
+ p->pEnvRemote ,
+ p->m_sPurpose.pData );
+ }
+
+ }
+}
+
+void RemoteMapping::thisRelease( uno_Mapping *pMap )
+{
+ RemoteMapping *p = SAL_REINTERPRET_CAST( RemoteMapping * , pMap );
+ if (! osl_decrementInterlockedCount( &(p->m_nRef) ))
+ {
+ uno_revokeMapping( pMap );
+ }
+}
+
+
+void RemoteMapping::remoteToUno( uno_Mapping *pMapping,
+ void **ppUnoI,
+ void *pRemoteI,
+ typelib_InterfaceTypeDescription *pTypeDescr )
+{
+ remote_Mapping *pRemoteMapping = ( remote_Mapping * ) pMapping;
+
+ OSL_ASSERT( ppUnoI && pTypeDescr );
+ if (*ppUnoI)
+ {
+ ((uno_Interface *)*ppUnoI)->release( (uno_Interface *)*ppUnoI );
+ *ppUnoI = 0;
+ }
+
+ if (pRemoteI && pTypeDescr)
+ {
+ // get object id of interface to be wrapped
+ rtl_uString * pOid = 0;
+ pRemoteMapping->pEnvRemote->pExtEnv->getObjectIdentifier(
+ pRemoteMapping->pEnvRemote->pExtEnv,
+ &pOid,
+ pRemoteI );
+
+ OSL_ASSERT(pOid);
+ if( ! pOid )
+ {
+ return;
+ }
+
+ // try to get any known interface from target environment
+ pRemoteMapping->pEnvUno->pExtEnv->getRegisteredInterface(
+ pRemoteMapping->pEnvUno->pExtEnv,
+ ppUnoI,
+ pOid,
+ pTypeDescr);
+
+ if ( ! *ppUnoI) // already existing interface
+ {
+ // try to publish a new proxy; proxy may be exchanged during registration
+ *ppUnoI = new Remote2UnoProxy(
+ ( remote_Interface * ) pRemoteI,
+ pOid,
+ pTypeDescr ,
+ pRemoteMapping->pEnvUno,
+ pRemoteMapping->pEnvRemote);
+
+ pRemoteMapping->pEnvUno->pExtEnv->registerProxyInterface(
+ pRemoteMapping->pEnvUno->pExtEnv,
+ ppUnoI,
+ Remote2UnoProxy::thisFree,
+ pOid,
+ pTypeDescr );
+
+ OSL_ASSERT( *ppUnoI );
+ }
+ rtl_uString_release( pOid );
+ }
+}
+
+
+void RemoteMapping::unoToRemote( uno_Mapping *pMapping,
+ void **ppRemoteI,
+ void *pUnoI,
+ typelib_InterfaceTypeDescription *pTypeDescr )
+{
+ remote_Mapping *pRemoteMapping = ( remote_Mapping * ) pMapping;
+ OSL_ASSERT( ppRemoteI && pTypeDescr );
+ if (*ppRemoteI)
+ {
+ ((remote_Interface *)*ppRemoteI)->release( (remote_Interface *)*ppRemoteI);
+ *ppRemoteI = 0;
+ }
+ if (pUnoI && pTypeDescr)
+ {
+ // get object id of interface to be wrapped
+ rtl_uString * pOid = 0;
+ pRemoteMapping->pEnvUno->pExtEnv->getObjectIdentifier(
+ pRemoteMapping->pEnvUno->pExtEnv,
+ &pOid,
+ pUnoI );
+
+ OSL_ASSERT( pOid );
+ if( ! pOid )
+ {
+ return;
+ }
+
+ pRemoteMapping->pEnvRemote->pExtEnv->getRegisteredInterface(
+ pRemoteMapping->pEnvRemote->pExtEnv,
+ (void**)ppRemoteI,
+ pOid,
+ pTypeDescr );
+
+ if( !*ppRemoteI )
+ {
+ // try to publish a new proxy;
+ *ppRemoteI = new Uno2RemoteStub(
+ ( uno_Interface * ) pUnoI,
+ pOid,
+ pTypeDescr,
+ pRemoteMapping->pEnvUno,
+ pRemoteMapping->pEnvRemote );
+
+ // note : ppRemoteI may change during registration
+ pRemoteMapping->pEnvRemote->pExtEnv->registerProxyInterface(
+ pRemoteMapping->pEnvRemote->pExtEnv,
+ (void**) ppRemoteI,
+ Uno2RemoteStub::thisFree,
+ pOid,
+ pTypeDescr );
+ }
+
+ rtl_uString_release( pOid );
+ }
+}
+
+}
diff --git a/bridges/source/remote/static/proxy.cxx b/bridges/source/remote/static/proxy.cxx
new file mode 100644
index 000000000000..3b488b7c2b27
--- /dev/null
+++ b/bridges/source/remote/static/proxy.cxx
@@ -0,0 +1,372 @@
+/*************************************************************************
+ *
+ * $RCSfile: proxy.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <assert.h>
+#ifdef SOLARIS
+#include <alloca.h>
+#else
+#include <malloc.h>
+#endif
+
+#include <bridges/remote/proxy.hxx>
+#include <bridges/remote/context.h>
+
+#include <uno/data.h>
+#include <uno/mapping.hxx>
+#include <uno/environment.h>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include <bridges/remote/bridgeimpl.hxx>
+
+#include "remote_types.hxx"
+
+#ifdef DEBUG
+#include <bridges/remote/counter.hxx>
+static MyCounter thisCounter( "DEBUG : Remote2UnoProxy");
+#endif
+
+using namespace ::bridges_remote;
+using namespace ::com::sun::star::uno;
+
+namespace bridges_remote {
+
+Remote2UnoProxy::Remote2UnoProxy( remote_Interface *pRemoteI,
+ rtl_uString *pOid,
+ typelib_InterfaceTypeDescription *pType,
+ uno_Environment *pEnvUno,
+ uno_Environment *pEnvRemote ) :
+ m_pType( pType ),
+ m_pRemoteI( pRemoteI ),
+ m_pEnvUno( pEnvUno ),
+ m_pEnvRemote( pEnvRemote ),
+ m_sOid( pOid ),
+ m_nRef( 1 ),
+ m_mapRemote2Uno( pEnvRemote, pEnvUno ),
+ m_mapUno2Remote( pEnvUno , pEnvRemote )
+{
+ typelib_typedescription_acquire( (typelib_TypeDescription * ) m_pType );
+ m_pEnvUno->acquire( m_pEnvUno );
+ m_pEnvRemote->acquire( m_pEnvRemote );
+
+ acquire = thisAcquire;
+ release = thisRelease;
+ pDispatcher = ( uno_DispatchMethod ) thisDispatch;
+
+ m_pEnvRemote->pExtEnv->registerInterface(
+ m_pEnvRemote->pExtEnv,
+ (void**)&m_pRemoteI,
+ m_sOid.pData,
+ m_pType );
+ m_pRemoteI->acquire( m_pRemoteI );
+
+#ifdef DEBUG
+ thisCounter.acquire();
+#endif
+}
+
+Remote2UnoProxy::~Remote2UnoProxy()
+{
+ // revoke external ref (oid)
+ m_pEnvRemote->pExtEnv->revokeInterface( m_pEnvRemote->pExtEnv , m_pRemoteI );
+
+ typelib_typedescription_release( (typelib_TypeDescription * )m_pType );
+ m_pRemoteI->release( m_pRemoteI );
+ m_pEnvUno->release( m_pEnvUno );
+ m_pEnvRemote->release( m_pEnvRemote );
+#ifdef DEBUG
+ thisCounter.release();
+#endif
+}
+
+void Remote2UnoProxy::thisFree( uno_ExtEnvironment *pEnvUno , void *pThis )
+{
+ delete (Remote2UnoProxy*) pThis;
+}
+
+void Remote2UnoProxy::thisAcquire( uno_Interface *pThis )
+{
+ Remote2UnoProxy *p = ( Remote2UnoProxy * ) pThis;
+ if( 1 == osl_incrementInterlockedCount( &(p->m_nRef) ) )
+ {
+ p->m_pEnvUno->pExtEnv->registerProxyInterface(
+ p->m_pEnvUno->pExtEnv,
+ (void**)&pThis,
+ Remote2UnoProxy::thisFree,
+ p->m_sOid.pData,
+ p->m_pType );
+ assert( (uno_Interface *)p == pThis );
+ }
+}
+
+void Remote2UnoProxy::thisRelease( uno_Interface *pThis )
+{
+ Remote2UnoProxy *p = ( Remote2UnoProxy * ) pThis;
+ if ( 0 == osl_decrementInterlockedCount( &(p->m_nRef) ))
+ {
+ p->m_pEnvUno->pExtEnv->revokeInterface( p->m_pEnvUno->pExtEnv, p );
+ }
+}
+
+void SAL_CALL remote_release( void *pRemoteI )
+{
+ ((remote_Interface * )pRemoteI)->release( (remote_Interface * ) pRemoteI );
+}
+
+void Remote2UnoProxy::thisDispatch(
+ uno_Interface * pUnoI,
+ typelib_TypeDescription * pType,
+ void * pReturn,
+ void * ppArgs[],
+ uno_Any ** ppException )
+{
+ Remote2UnoProxy *p = ( Remote2UnoProxy * ) pUnoI;
+ RemoteThreadCounter counter( p->m_pEnvRemote );
+
+ typelib_InterfaceMethodTypeDescription *pMethodType = 0;
+ typelib_InterfaceAttributeTypeDescription *pAttributeType = 0;
+ typelib_TypeDescription *pReturnType = 0;
+ typelib_TypeDescription **ppArgType = 0;
+ sal_Int32 nArgCount = 0;
+ sal_Bool *pbIsIn = 0;
+ sal_Bool *pbIsOut = 0;
+ sal_Bool *pbConversionNeeded = 0;
+ sal_Bool bConversionNeededForReturn = 0;
+
+ //--------------------------------
+ // Collect all needed types !
+ //--------------------------------
+ if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pType->eTypeClass )
+ {
+ pAttributeType = ( typelib_InterfaceAttributeTypeDescription * ) pType;
+ if( pReturn )
+ {
+ TYPELIB_DANGER_GET( &pReturnType , pAttributeType->pAttributeTypeRef );
+ bConversionNeededForReturn = remote_relatesToInterface( pReturnType );
+ }
+ else
+ {
+ nArgCount = 1;
+ ppArgType = (typelib_TypeDescription **) alloca( sizeof( void * ) );
+ pbIsIn = ( sal_Bool * ) alloca( sizeof( sal_Bool ) );
+ pbIsOut = ( sal_Bool * ) alloca( sizeof( sal_Bool ) );
+ pbConversionNeeded = ( sal_Bool *) alloca( sizeof( sal_Bool ) );
+
+ pbIsIn[0] = sal_True;
+ pbIsOut[0] = sal_False;
+ ppArgType[0] = 0;
+ TYPELIB_DANGER_GET( &( ppArgType[0] ) , pAttributeType->pAttributeTypeRef );
+ pbConversionNeeded[0] = remote_relatesToInterface( ppArgType[0] );
+
+ }
+ }
+ if( typelib_TypeClass_INTERFACE_METHOD == pType->eTypeClass )
+ {
+ pMethodType = ( typelib_InterfaceMethodTypeDescription * ) pType;
+ TYPELIB_DANGER_GET( &pReturnType , pMethodType->pReturnTypeRef );
+ bConversionNeededForReturn = remote_relatesToInterface( pReturnType );
+ nArgCount = pMethodType->nParams;
+ ppArgType = (typelib_TypeDescription **) alloca( sizeof( void * ) * nArgCount );
+ pbIsIn = (sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount );
+ pbIsOut = (sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount );
+ pbConversionNeeded = ( sal_Bool *) alloca( sizeof( sal_Bool ) * nArgCount );
+ sal_Int32 i;
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ ppArgType[i] = 0;
+ TYPELIB_DANGER_GET( & (ppArgType[i]) , pMethodType->pParams[i].pTypeRef );
+ pbIsIn[i] = pMethodType->pParams[i].bIn;
+ pbIsOut[i] = pMethodType->pParams[i].bOut;
+ pbConversionNeeded[i] = remote_relatesToInterface( ppArgType[i] );
+ }
+ }
+
+ void *pRemoteReturn = 0;
+ if( pReturnType )
+ {
+ if( bConversionNeededForReturn )
+ {
+ pRemoteReturn = alloca( pReturnType->nSize );
+ }
+ else
+ {
+ pRemoteReturn = pReturn;
+ }
+ }
+
+ void ** ppRemoteArgs = 0;
+ if( nArgCount )
+ {
+ ppRemoteArgs = (void**) alloca( sizeof( void * ) * nArgCount );
+ }
+
+ sal_Int32 i;
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ if( pbConversionNeeded[i] )
+ {
+ ppRemoteArgs[i] = alloca( ppArgType[i]->nSize );
+
+ if( pbIsIn[i] ) {
+ uno_copyAndConvertData(
+ ppRemoteArgs[i],
+ ppArgs[i],
+ ppArgType[i],
+ p->m_mapUno2Remote.get() );
+ }
+ }
+ else
+ {
+ ppRemoteArgs[i] = ppArgs[i];
+ }
+ }
+
+ uno_Any any;
+ uno_Any *pAny = &any;
+
+ p->m_pRemoteI->pDispatcher( p->m_pRemoteI,
+ pType,
+ pRemoteReturn,
+ ppRemoteArgs,
+ &pAny );
+
+ if( ! pAny )
+ {
+ if( pReturn && bConversionNeededForReturn )
+ {
+ uno_copyAndConvertData(
+ pReturn ,
+ pRemoteReturn,
+ pReturnType,
+ p->m_mapRemote2Uno.get() );
+ uno_destructData( pRemoteReturn , pReturnType , remote_release );
+ }
+
+ sal_Int32 i;
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ if( pbConversionNeeded[i] )
+ {
+ if( pbIsIn[i] ) {
+ if( pbIsOut[i] ) {
+ uno_destructData( ppArgs[i] ,
+ ppArgType[i] ,
+ 0 );
+ uno_copyAndConvertData( ppArgs[i] ,
+ ppRemoteArgs[i],
+ ppArgType[i],
+ p->m_mapRemote2Uno.get() );
+ }
+ }
+ else // pure out
+ {
+ uno_copyAndConvertData( ppArgs[i] ,
+ ppRemoteArgs[i],
+ ppArgType[i],
+ p->m_mapRemote2Uno.get() );
+ }
+ uno_destructData( ppRemoteArgs[i],
+ ppArgType[i],
+ remote_release );
+ }
+ }
+ *ppException = 0;
+ }
+ else
+ {
+ // -----------------------
+ // an exception occured
+ // -----------------------
+ typelib_TypeDescription *pAnyType = 0;
+ getCppuType( (::com::sun::star::uno::Any*) 0 ).getDescription( &pAnyType );
+ uno_copyAndConvertData( *ppException ,
+ pAny ,
+ pAnyType,
+ p->m_mapRemote2Uno.get() );
+ uno_destructData( pAny , pAnyType , remote_release );
+ typelib_typedescription_release( pAnyType );
+
+ // destruct remote in parameters ( out parameters have not been constructed )
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ if( pbConversionNeeded[i] && pbIsIn[i] )
+ {
+ uno_destructData( ppRemoteArgs[i],
+ ppArgType[i],
+ remote_release );
+ }
+ }
+ }
+
+ //--------------------------
+ // release all acquired types
+ //--------------------------
+ if( pReturnType )
+ {
+ TYPELIB_DANGER_RELEASE( pReturnType );
+ }
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ TYPELIB_DANGER_RELEASE( ppArgType[ i] );
+ }
+
+}
+
+} // end namespace bridge_remote
diff --git a/bridges/source/remote/static/remote.cxx b/bridges/source/remote/static/remote.cxx
new file mode 100644
index 000000000000..948d9a631ae6
--- /dev/null
+++ b/bridges/source/remote/static/remote.cxx
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * $RCSfile: remote.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <assert.h>
+
+#include <bridges/remote/remote.hxx>
+#include <bridges/remote/counter.hxx>
+
+#ifdef DEBUG
+static MyCounter thisCounter( "DEBUG : Remote2RemoteStub");
+#endif
+
+namespace bridges_remote {
+
+Remote2RemoteStub::Remote2RemoteStub( rtl_uString *pOid,
+ typelib_InterfaceTypeDescription *pType,
+ uno_Environment *pEnvRemote,
+ requestClientSideDispatcher dispatch ) :
+ m_pType( (typelib_InterfaceTypeDescription * ) pType ),
+ m_pEnvRemote( pEnvRemote ),
+ m_sOid( pOid ),
+ m_nRef( 1 ),
+ m_dispatch( dispatch )
+{
+ typelib_typedescription_acquire( ( typelib_TypeDescription * ) m_pType );
+ m_pEnvRemote->acquire( m_pEnvRemote );
+
+ acquire = thisAcquire;
+ release = thisRelease;
+ pDispatcher = thisDispatch;
+#ifdef DEBUG
+ thisCounter.acquire();
+#endif
+}
+
+Remote2RemoteStub::~Remote2RemoteStub()
+{
+
+ // send a release via the connection !
+ releaseRemote();
+
+ typelib_typedescription_release( (typelib_TypeDescription * ) m_pType );
+ m_pEnvRemote->release( m_pEnvRemote );
+#ifdef DEBUG
+ thisCounter.release();
+#endif
+}
+
+
+void Remote2RemoteStub::thisFree( uno_ExtEnvironment *pEnvUno , void *pThis )
+{
+ delete (Remote2RemoteStub *) pThis;
+}
+void Remote2RemoteStub::releaseRemote()
+{
+ uno_Any any;
+ uno_Any *pAny = &any;
+
+ typelib_TypeDescription *pReleaseMethod = 0;
+ typelib_typedescriptionreference_getDescription(
+ &pReleaseMethod ,
+ m_pType->ppAllMembers[REMOTE_RELEASE_METHOD_INDEX] );
+ thisDispatch( this,
+ pReleaseMethod,
+ 0,
+ 0,
+ &pAny );
+
+ typelib_typedescription_release( pReleaseMethod );
+}
+
+void Remote2RemoteStub::thisAcquire( remote_Interface *pThis )
+{
+ Remote2RemoteStub *p = ( Remote2RemoteStub * ) pThis;
+ if( 1 == osl_incrementInterlockedCount( &(p->m_nRef) ) )
+ {
+ p->m_pEnvRemote->pExtEnv->registerProxyInterface(
+ p->m_pEnvRemote->pExtEnv,
+ (void**)&pThis,
+ Remote2RemoteStub::thisFree,
+ p->m_sOid.pData,
+ p->m_pType );
+ assert( (remote_Interface *)p == pThis );
+ }
+}
+
+void Remote2RemoteStub::thisRelease( remote_Interface *pThis )
+{
+ Remote2RemoteStub *p = ( Remote2RemoteStub * ) pThis;
+ if (! osl_decrementInterlockedCount( &(p->m_nRef) ))
+ {
+ p->m_pEnvRemote->pExtEnv->revokeInterface( p->m_pEnvRemote->pExtEnv, pThis );
+
+ }
+}
+
+void Remote2RemoteStub::thisDispatch(
+ remote_Interface * pRemoteI,
+ typelib_TypeDescription * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException )
+{
+ Remote2RemoteStub *pThis = ( Remote2RemoteStub * ) pRemoteI;
+
+ pThis->m_dispatch( pThis->m_pEnvRemote,
+ pMemberType,
+ pThis->m_sOid.pData,
+ pThis->m_pType,
+ pReturn,
+ pArgs,
+ ppException );
+}
+
+} // end namespace bridges_remote
diff --git a/bridges/source/remote/static/remote_types.cxx b/bridges/source/remote/static/remote_types.cxx
new file mode 100644
index 000000000000..baa684037551
--- /dev/null
+++ b/bridges/source/remote/static/remote_types.cxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * $RCSfile: remote_types.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "remote_types.hxx"
+
+namespace bridges_remote {
+
+sal_Bool SAL_CALL remote_relatesToInterface2( typelib_TypeDescription * pTypeDescr )
+{
+ switch (pTypeDescr->eTypeClass)
+ {
+ case typelib_TypeClass_SEQUENCE:
+ {
+ switch (((typelib_IndirectTypeDescription *)pTypeDescr)->pType->eTypeClass)
+ {
+ case typelib_TypeClass_SEQUENCE:
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType );
+ sal_Bool bRel = remote_relatesToInterface( pTD );
+ TYPELIB_DANGER_RELEASE( pTD );
+ return bRel;
+ }
+
+ }
+ }
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ // ...optimized... to avoid getDescription() calls!
+ typelib_CompoundTypeDescription * pComp = (typelib_CompoundTypeDescription *)pTypeDescr;
+ typelib_TypeDescriptionReference ** pTypes = pComp->ppTypeRefs;
+ for ( sal_Int32 nPos = pComp->nMembers; nPos--; )
+ {
+ switch (pTypes[nPos]->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE:
+ case typelib_TypeClass_UNION: // might relate to interface
+ case typelib_TypeClass_ANY: // might relate to interface
+ return sal_True;
+ case typelib_TypeClass_SEQUENCE:
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, pTypes[nPos] );
+ sal_Bool bRel = remote_relatesToInterface( pTD );
+ TYPELIB_DANGER_RELEASE( pTD );
+ if (bRel)
+ return sal_True;
+ }
+ }
+ }
+ if (pComp->pBaseTypeDescription)
+ return remote_relatesToInterface( (typelib_TypeDescription *)pComp->pBaseTypeDescription );
+ break;
+ }
+ default:
+ OSL_ASSERT( 0 );
+ }
+ return sal_False;
+}
+
+}
diff --git a/bridges/source/remote/static/remote_types.hxx b/bridges/source/remote/static/remote_types.hxx
new file mode 100644
index 000000000000..745ec6f0e349
--- /dev/null
+++ b/bridges/source/remote/static/remote_types.hxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * $RCSfile: remote_types.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _BRIDGES_REMOTE_TYPES_HXX_
+#define _BRIDGES_REMOTE_TYPES_HXX_
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+
+namespace bridges_remote
+{
+
+inline sal_Bool SAL_CALL remote_relatesToInterface( typelib_TypeDescription *pTypeDescr );
+sal_Bool SAL_CALL remote_relatesToInterface2( typelib_TypeDescription * pTypeDescr );
+
+
+/** Determines whether given type might relate or relates to an interface,
+ i.e. values of this type are interface or may contain interface(s).<br>
+ @param pTypeDescr type description of type
+ @return true if type might relate to an interface, false otherwise
+*/
+inline sal_Bool SAL_CALL remote_relatesToInterface( typelib_TypeDescription * pTypeDescr )
+{
+ switch (pTypeDescr->eTypeClass)
+ {
+ case typelib_TypeClass_SEQUENCE:
+ {
+ switch (((typelib_IndirectTypeDescription *)pTypeDescr)->pType->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE:
+ case typelib_TypeClass_UNION: // might relate to interface
+ case typelib_TypeClass_ANY: // might relate to interface
+ return sal_True;
+ case typelib_TypeClass_SEQUENCE:
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ return remote_relatesToInterface2( pTypeDescr );
+ }
+ }
+ return sal_False;
+ }
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ return remote_relatesToInterface2( pTypeDescr );
+ }
+ case typelib_TypeClass_UNION: // might relate to interface
+ case typelib_TypeClass_ANY: // might relate to interface
+ case typelib_TypeClass_INTERFACE:
+ return sal_True;
+ }
+ return sal_False;
+}
+
+/** Determines whether given type is a cpp simple type, e.g. int, enum.<br>
+ @param pTypeDescr type description of type
+ @return true if type is a cpp simple type, false otherwise
+*/
+inline sal_Bool SAL_CALL remote_isSimpleType( typelib_TypeDescription * pTypeDescr )
+{
+ return (pTypeDescr->eTypeClass <= typelib_TypeClass_ENUM &&
+ pTypeDescr->eTypeClass != typelib_TypeClass_STRING &&
+ pTypeDescr->eTypeClass != typelib_TypeClass_ANY &&
+ pTypeDescr->eTypeClass != typelib_TypeClass_TYPE);
+}
+
+}
+#endif
diff --git a/bridges/source/remote/static/stub.cxx b/bridges/source/remote/static/stub.cxx
new file mode 100644
index 000000000000..aec8a39140fe
--- /dev/null
+++ b/bridges/source/remote/static/stub.cxx
@@ -0,0 +1,370 @@
+/*************************************************************************
+ *
+ * $RCSfile: stub.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifdef SOLARIS
+#include <alloca.h>
+#else
+#include <malloc.h>
+#endif
+
+#include <osl/diagnose.h>
+
+#include <uno/data.h>
+#include <uno/mapping.hxx>
+
+#include <bridges/remote/stub.hxx>
+#include <bridges/remote/proxy.hxx>
+#include <bridges/remote/context.h>
+#include <bridges/remote/bridgeimpl.hxx>
+
+#include "remote_types.hxx"
+
+#ifdef DEBUG
+#include <bridges/remote/counter.hxx>
+static MyCounter thisCounter( "DEBUG : Uno2RemoteStub");
+#endif
+
+using namespace ::com::sun::star::uno;
+
+namespace bridges_remote {
+
+Uno2RemoteStub::Uno2RemoteStub( uno_Interface *pUnoI,
+ rtl_uString *pOid,
+ typelib_InterfaceTypeDescription *pType,
+ uno_Environment *pEnvUno,
+ uno_Environment *pEnvRemote ) :
+ m_pType( pType ),
+ m_pUnoI( pUnoI ),
+ m_pEnvUno( pEnvUno ),
+ m_pEnvRemote( pEnvRemote ),
+ m_sOid( pOid ),
+ m_nRef( 1 ),
+ m_mapRemote2Uno( pEnvRemote, pEnvUno ),
+ m_mapUno2Remote( pEnvUno, pEnvRemote )
+{
+ typelib_typedescription_acquire( (typelib_TypeDescription * )m_pType );
+ m_pEnvUno->acquire( m_pEnvUno );
+ m_pEnvRemote->acquire( m_pEnvRemote );
+
+ acquire = thisAcquire;
+ release = thisRelease;
+ pDispatcher = thisDispatch;
+
+ m_pEnvUno->pExtEnv->registerInterface( m_pEnvUno->pExtEnv,
+ (void **)&m_pUnoI,
+ m_sOid.pData,
+ m_pType );
+ m_pUnoI->acquire( m_pUnoI );
+#ifdef DEBUG
+ thisCounter.acquire();
+#endif
+}
+
+Uno2RemoteStub::~Uno2RemoteStub()
+{
+ m_pEnvUno->pExtEnv->revokeInterface( m_pEnvUno->pExtEnv , m_pUnoI );
+
+ typelib_typedescription_release( (typelib_TypeDescription * )m_pType );
+ m_pUnoI->release( m_pUnoI );
+ m_pEnvUno->release( m_pEnvUno );
+ m_pEnvRemote->release( m_pEnvRemote );
+#ifdef DEBUG
+ thisCounter.release();
+#endif
+}
+
+
+void Uno2RemoteStub::thisFree( uno_ExtEnvironment *pEnvRemote, void *pThis )
+{
+ delete ( Uno2RemoteStub * ) pThis;
+}
+
+void Uno2RemoteStub::thisAcquire( remote_Interface *pThis )
+{
+ Uno2RemoteStub *p = ( Uno2RemoteStub * ) pThis;
+ if( 1 == osl_incrementInterlockedCount( &(p->m_nRef) ) )
+ {
+
+ p->m_pEnvRemote->pExtEnv->registerProxyInterface(
+ p->m_pEnvRemote->pExtEnv,
+ (void**)&pThis,
+ Uno2RemoteStub::thisFree,
+ p->m_sOid.pData,
+ p->m_pType );
+
+ OSL_ASSERT( (remote_Interface*) p == pThis );
+ }
+}
+
+void Uno2RemoteStub::thisRelease( remote_Interface *pThis )
+{
+ Uno2RemoteStub *p = ( Uno2RemoteStub * ) pThis;
+ if (! osl_decrementInterlockedCount( &(p->m_nRef) ))
+ {
+ p->m_pEnvRemote->pExtEnv->revokeInterface( p->m_pEnvRemote->pExtEnv, pThis );
+ }
+}
+
+void Uno2RemoteStub::thisDispatch(
+ remote_Interface * pRemoteI,
+ typelib_TypeDescription * pType,
+ void * pReturn,
+ void * ppArgs[],
+ uno_Any ** ppException )
+{
+ Uno2RemoteStub *p = ( Uno2RemoteStub * ) pRemoteI;
+
+ RemoteThreadCounter counter( p->m_pEnvRemote );
+
+ typelib_InterfaceMethodTypeDescription *pMethodType = 0;
+ typelib_InterfaceAttributeTypeDescription *pAttributeType = 0;
+ typelib_TypeDescription *pReturnType = 0;
+ typelib_TypeDescription **ppArgType = 0;
+ sal_Int32 nArgCount = 0;
+ sal_Bool *pbIsIn = 0;
+ sal_Bool *pbIsOut = 0;
+ sal_Bool bConversionNeededForReturn = sal_False;
+ sal_Bool *pbConversionNeeded = 0;
+
+ sal_Int32 i;
+ //--------------------------------
+ // Collect all needed types !
+ //--------------------------------
+ if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pType->eTypeClass )
+ {
+ pAttributeType = ( typelib_InterfaceAttributeTypeDescription * ) pType;
+ if( pReturn )
+ {
+ TYPELIB_DANGER_GET( &pReturnType , pAttributeType->pAttributeTypeRef );
+ bConversionNeededForReturn = remote_relatesToInterface( pReturnType );
+ }
+ else
+ {
+ nArgCount = 1;
+ ppArgType = (typelib_TypeDescription **) alloca( sizeof( void * ) );
+ pbIsIn = ( sal_Bool * ) alloca( sizeof( sal_Bool ) );
+ pbIsOut = ( sal_Bool * ) alloca( sizeof( sal_Bool ) );
+ pbConversionNeeded = ( sal_Bool * ) alloca( sizeof( sal_Bool ) );
+ pbIsIn[0] = sal_True;
+ pbIsOut[0] = sal_False;
+ ppArgType[0] = 0;
+ TYPELIB_DANGER_GET( &( ppArgType[0] ) , pAttributeType->pAttributeTypeRef );
+ pbConversionNeeded[0] = remote_relatesToInterface( ppArgType[0] );
+ }
+ }
+ if( typelib_TypeClass_INTERFACE_METHOD == pType->eTypeClass )
+ {
+ pMethodType = ( typelib_InterfaceMethodTypeDescription * ) pType;
+ TYPELIB_DANGER_GET( &pReturnType , pMethodType->pReturnTypeRef );
+ bConversionNeededForReturn = remote_relatesToInterface( pReturnType );
+ nArgCount = pMethodType->nParams;
+ ppArgType = (typelib_TypeDescription **) alloca( sizeof( void * ) * nArgCount );
+ pbIsIn = (sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount );
+ pbIsOut = (sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount );
+ pbConversionNeeded = ( sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount );
+
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ ppArgType[i] = 0;
+ TYPELIB_DANGER_GET( & (ppArgType[i]) , pMethodType->pParams[i].pTypeRef );
+ pbIsIn[i] = pMethodType->pParams[i].bIn;
+ pbIsOut[i] = pMethodType->pParams[i].bOut;
+ pbConversionNeeded[i] = remote_relatesToInterface( ppArgType[i] );
+ }
+ }
+
+ // create Mapping
+
+ void *pUnoReturn = 0;
+ void **ppUnoArgs = 0;
+
+ if( pReturnType )
+ {
+ if( bConversionNeededForReturn )
+ {
+ pUnoReturn = alloca( pReturnType->nSize );
+ }
+ else
+ {
+ pUnoReturn = pReturn;
+ }
+ }
+
+ ppUnoArgs = (void **) alloca( nArgCount * sizeof( void * ) );
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ if( pbConversionNeeded[i] )
+ {
+ ppUnoArgs[i] = alloca( ppArgType[i]->nSize );
+ if( pbIsIn[i] )
+ {
+ uno_copyAndConvertData(
+ ppUnoArgs[i],
+ ppArgs[i],
+ ppArgType[i],
+ p->m_mapRemote2Uno.get()
+ );
+ }
+ }
+ else
+ {
+ ppUnoArgs[i] = ppArgs[i];
+ }
+ }
+
+ // do the call
+ uno_Any any;
+ uno_Any *pAny = &any;
+
+ p->m_pUnoI->pDispatcher( p->m_pUnoI,
+ pType,
+ pUnoReturn,
+ ppUnoArgs,
+ &pAny);
+
+ if( ! pAny )
+ {
+ // ------------------
+ // No Exception
+ // ------------------
+
+ // Map return value
+ if( pReturnType && bConversionNeededForReturn )
+ {
+ uno_copyAndConvertData(
+ pReturn ,
+ pUnoReturn,
+ pReturnType,
+ p->m_mapUno2Remote.get() );
+ uno_destructData( pUnoReturn , pReturnType, 0 );
+ }
+
+ // map arguments
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ if( pbConversionNeeded[i] )
+ {
+ if( pbIsIn[i] ) {
+ if( pbIsOut[i] ) {
+ uno_destructData(
+ ppArgs[i] ,
+ ppArgType[i] ,
+ remote_release );
+ uno_copyAndConvertData( ppArgs[i] ,
+ ppUnoArgs[i],
+ ppArgType[i],
+ p->m_mapUno2Remote.get() );
+ }
+ }
+ else // pure out
+ {
+ uno_copyAndConvertData( ppArgs[i] ,
+ ppUnoArgs[i],
+ ppArgType[i],
+ p->m_mapUno2Remote.get() );
+ }
+ uno_destructData( ppUnoArgs[i],
+ ppArgType[i],
+ 0 );
+ }
+ }
+ *ppException = 0;
+ }
+ else
+ {
+ // -----------------------
+ // an exception occured
+ // -----------------------
+ typelib_TypeDescription *pAnyType = 0;
+ getCppuType( (Any*) 0 ).getDescription( &pAnyType );
+ uno_copyAndConvertData( *ppException ,
+ pAny ,
+ pAnyType,
+ p->m_mapUno2Remote.get() );
+ uno_destructData( pAny , pAnyType , 0 );
+ typelib_typedescription_release( pAnyType );
+
+ // destruct uno in parameters ( out parameters have not been constructed )
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ if( pbConversionNeeded[i] && pbIsIn[i] )
+ {
+ uno_destructData( ppUnoArgs[i],
+ ppArgType[i],
+ 0 );
+ }
+ }
+ }
+
+ //--------------------------
+ // release all acquired types
+ //--------------------------
+ if( pReturnType )
+ {
+ TYPELIB_DANGER_RELEASE( pReturnType );
+ }
+ for( i = 0 ; i < nArgCount ; i ++ )
+ {
+ TYPELIB_DANGER_RELEASE( ppArgType[ i] );
+ }
+}
+
+
+} // end namespace bridges_remote
diff --git a/bridges/source/remote/urp/makefile.mk b/bridges/source/remote/urp/makefile.mk
new file mode 100644
index 000000000000..efad07ea82d9
--- /dev/null
+++ b/bridges/source/remote/urp/makefile.mk
@@ -0,0 +1,130 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=bridges
+TARGET=urp_uno
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+#CPPUMAKERFLAGS += -C
+UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb
+
+# output directory (one dir for each project)
+UNOUCROUT=$(OUT)$/inc
+
+# adding to inludepath
+INCPRE+=$(UNOUCROUT)
+
+UNOTYPES= \
+ com.sun.star.uno.XInterface \
+ com.sun.star.uno.TypeClass
+
+
+SLOFILES= \
+ $(SLO)$/urp_environment.obj \
+ $(SLO)$/urp_marshal.obj \
+ $(SLO)$/urp_unmarshal.obj \
+ $(SLO)$/urp_dispatch.obj \
+ $(SLO)$/urp_job.obj \
+ $(SLO)$/urp_reader.obj \
+ $(SLO)$/urp_writer.obj \
+ $(SLO)$/urp_log.obj \
+ $(SLO)$/urp_bridgeimpl.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS=\
+ $(SALLIB)\
+ $(VOSLIB)\
+ $(CPPULIB)
+
+SHL1LIBS=\
+ $(SLB)$/$(TARGET).lib \
+ $(SLB)$/bridges_remote_static.lib
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo LIBRARY $(SHL1TARGET) >$@
+ @echo DESCRIPTION 'URP to UNO binding' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+ @echo EXPORTS >>$@
+ @echo uno_initEnvironment @3 >>$@
+ @echo uno_ext_getMapping @4 >>$@
+
diff --git a/bridges/source/remote/urp/urp_bridgeimpl.cxx b/bridges/source/remote/urp/urp_bridgeimpl.cxx
new file mode 100644
index 000000000000..730a302cdfa4
--- /dev/null
+++ b/bridges/source/remote/urp/urp_bridgeimpl.cxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_bridgeimpl.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <bridges/remote/helper.hxx>
+
+#include "urp_bridgeimpl.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+namespace bridges_urp
+{
+
+/***********
+ * urp_BridgeImpl
+ ***********/
+urp_BridgeImpl::urp_BridgeImpl( sal_Int32 nCacheSize , sal_uInt32 nInitialMarshalerSize ) :
+ m_oidCacheOut( nCacheSize ),
+ m_tidCacheOut( nCacheSize ),
+ m_typeCacheOut( nCacheSize ),
+ m_nCacheSize( nCacheSize ),
+ m_blockMarshaler( this , nInitialMarshalerSize , ::bridges_remote::remote_retrieveOidFromProxy)
+{
+ m_pOidIn = new OUString[ nCacheSize ];
+ m_pTidIn = new ByteSequence[ nCacheSize ];
+ m_pTypeIn = new Type[ nCacheSize ];
+ m_nRemoteThreads = 0;
+}
+
+urp_BridgeImpl::~urp_BridgeImpl()
+{
+ delete [] m_pOidIn;
+ delete [] m_pTidIn;
+ delete [] m_pTypeIn;
+}
+}
diff --git a/bridges/source/remote/urp/urp_bridgeimpl.hxx b/bridges/source/remote/urp/urp_bridgeimpl.hxx
new file mode 100644
index 000000000000..c141c06c0128
--- /dev/null
+++ b/bridges/source/remote/urp/urp_bridgeimpl.hxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_bridgeimpl.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _URP_BRIDGEIMPL_HXX_
+#define _URP_BRIDGEIMPL_HXX_
+
+#include <stdio.h>
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+
+#include <rtl/ustring.hxx>
+#include <rtl/byteseq.hxx>
+
+#include <bridges/remote/bridgeimpl.hxx>
+
+#include "urp_cache.hxx"
+#include "urp_marshal_decl.hxx"
+#include "urp_replycontainer.hxx"
+
+
+namespace bridges_urp
+{
+
+struct equalOUString
+{
+ sal_Int32 operator() ( const ::rtl::OUString &s1, const ::rtl::OUString &s2 ) const
+ {
+ return s1 == s2;
+ }
+};
+
+struct equalType
+{
+ sal_Int32 operator() ( const ::com::sun::star::uno::Type &t1,
+ const ::com::sun::star::uno::Type &t2 ) const
+ {
+ return t1 == t2;
+ }
+};
+
+class OWriterThread;
+class OReaderThread;
+
+struct urp_BridgeImpl :
+ public remote_BridgeImpl
+{
+ urp_BridgeImpl( sal_Int32 nCacheSize , sal_uInt32 nInitialMarshalerSize );
+ ~urp_BridgeImpl();
+
+ ::osl::Mutex m_marshalingMutex;
+ ::osl::Mutex m_disposingMutex;
+ Marshal m_blockMarshaler;
+
+ // Caches for vars, that go from local process to the remote process
+ Cache < ::rtl::OUString , equalOUString > m_oidCacheOut;
+ Cache < ::rtl::ByteSequence , EqualThreadId > m_tidCacheOut;
+ Cache < ::com::sun::star::uno::Type , equalType > m_typeCacheOut;
+
+ ::com::sun::star::uno::Type m_lastOutType;
+ ::rtl::ByteSequence m_lastOutTid;
+ ::rtl::OUString m_lastOutOid;
+
+ // Caches for vars, that come from the remote process to the local process
+ sal_Int32 m_nCacheSize;
+ ::rtl::OUString *m_pOidIn;
+ ::rtl::ByteSequence *m_pTidIn;
+ ::com::sun::star::uno::Type *m_pTypeIn;
+
+ ::com::sun::star::uno::Type m_lastInType;
+ ::rtl::ByteSequence m_lastInTid;
+ ::rtl::OUString m_lastInOid;
+
+ sal_Int32 m_nTimeoutMUSEC;
+ sal_Int32 m_nFlushBlockSize;
+
+ urp_ClientJobContainer m_clientJobContainer;
+
+ OWriterThread *m_pWriter;
+ OReaderThread *m_pReader;
+ FILE *m_pLogFile;
+ ::osl::Condition m_cndWaitForThreads;
+};
+
+}
+#endif
diff --git a/bridges/source/remote/urp/urp_cache.h b/bridges/source/remote/urp/urp_cache.h
new file mode 100644
index 000000000000..e60d70f8d3fa
--- /dev/null
+++ b/bridges/source/remote/urp/urp_cache.h
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_cache.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+namespace bridges_urp
+{
+ template < class t , class tequals >
+ class Cache
+ {
+ public:
+ inline Cache ( sal_uInt16 nMaxEntries );
+ inline ~Cache();
+
+ // puts the value t into the cache. Returns then entry,
+ // that is used for this value.
+ inline sal_uInt16 put( const t & );
+
+ // lookup, if there is an entry for this value
+ // returns 0xffff, when value cannot be found in the list
+ inline sal_uInt16 seek( const t & );
+
+ private:
+ t *m_pCache;
+ ::std::list< sal_uInt16 > m_lstLeastRecentlyUsed;
+ sal_uInt16 m_nMaxEntries;
+ sal_uInt16 m_nEntries;
+ };
+}
diff --git a/bridges/source/remote/urp/urp_cache.hxx b/bridges/source/remote/urp/urp_cache.hxx
new file mode 100644
index 000000000000..c399faa1ca5e
--- /dev/null
+++ b/bridges/source/remote/urp/urp_cache.hxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_cache.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdio.h>
+#include <list>
+
+#include <rtl/ustring.hxx>
+
+#include "urp_threadid.hxx"
+
+#include "urp_cache.h"
+
+namespace bridges_urp
+{
+
+ template < class t , class tequals >
+ inline Cache< t , tequals >::Cache( sal_uInt16 nMaxEntries ) :
+ m_pCache( new t[nMaxEntries] ),
+ m_nMaxEntries( nMaxEntries ),
+ m_nEntries( 0 )
+ {
+
+ }
+
+ template < class t , class tequals >
+ inline Cache< t , tequals >::~Cache( )
+ {
+ delete [] m_pCache;
+ }
+
+
+ template < class t , class tequals >
+ inline sal_uInt16 Cache< t , tequals >::put( const t & value )
+ {
+ sal_uInt16 nEntry = 0xffff;
+ if( m_nEntries < m_nMaxEntries )
+ {
+ // cache has still empty places
+ m_pCache[m_nEntries] = value;
+ nEntry = m_nEntries;
+ m_nEntries ++;
+
+ // add it to the cache
+ m_lstLeastRecentlyUsed.push_front( nEntry );
+ }
+ else
+ {
+ // cache is full, remove an element and insert the new one
+ nEntry = m_lstLeastRecentlyUsed.back();
+ m_lstLeastRecentlyUsed.pop_back();
+ m_lstLeastRecentlyUsed.push_front( nEntry );
+
+ m_pCache[nEntry] = value;
+ }
+ return nEntry;
+ }
+
+ template < class t , class tequals >
+ inline sal_uInt16 Cache< t , tequals >::seek( const t & value )
+ {
+ for( ::std::list< sal_uInt16 >::iterator ii = m_lstLeastRecentlyUsed.begin() ;
+ ii != m_lstLeastRecentlyUsed.end() ;
+ ++ ii )
+ {
+ if( value == m_pCache[*ii] )
+ {
+ sal_uInt16 nEntry = *ii;
+ m_lstLeastRecentlyUsed.erase( ii );
+ m_lstLeastRecentlyUsed.push_front( nEntry );
+ return nEntry;
+ }
+ }
+ return 0xffff;
+ }
+}
diff --git a/bridges/source/remote/urp/urp_dispatch.cxx b/bridges/source/remote/urp/urp_dispatch.cxx
new file mode 100644
index 000000000000..1b492e0e6309
--- /dev/null
+++ b/bridges/source/remote/urp/urp_dispatch.cxx
@@ -0,0 +1,370 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_dispatch.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifdef SOLARIS
+#include <alloca.h>
+#else
+#include <malloc.h>
+#endif
+
+#include <osl/mutex.hxx>
+#include <osl/diagnose.h>
+
+#include <rtl/alloc.h>
+#include <rtl/ustrbuf.hxx>
+
+#include <vos/timer.hxx>
+
+#include <uno/mapping.hxx>
+#include <uno/threadpool.h>
+
+#include <bridges/remote/remote.h>
+#include <bridges/remote/stub.hxx>
+#include <bridges/remote/proxy.hxx>
+#include <bridges/remote/remote.hxx>
+
+#include "urp_bridgeimpl.hxx"
+#include "urp_marshal.hxx"
+#include "urp_dispatch.hxx"
+#include "urp_job.hxx"
+#include "urp_writer.hxx"
+#include "urp_log.hxx"
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+
+namespace bridges_urp
+{
+
+void prepareRuntimeExceptionClientSide( uno_Any **ppException , const OUString &s)
+{
+
+ // TODO : add string to runtimeexception
+ Type type = ::getCppuType( ( ::com::sun::star::uno::RuntimeException *) 0 );
+ uno_type_any_construct( *ppException , 0 , type.getTypeLibType() , 0 );
+}
+
+void SAL_CALL urp_sendCloseConnection( uno_Environment *pEnvRemote )
+{
+ remote_Context *pContext = (remote_Context *) pEnvRemote->pContext;
+ urp_BridgeImpl *pImpl = (urp_BridgeImpl*) ( pContext->m_pBridgeImpl );
+
+ {
+ MutexGuard guard( pImpl->m_marshalingMutex );
+ sal_uInt8 nBitfield = 0;
+
+ // send immeadiatly
+ if( ! pImpl->m_blockMarshaler.empty() )
+ {
+ pImpl->m_pWriter->touch( sal_True );
+ }
+
+ pImpl->m_pWriter->sendEmptyMessage();
+ }
+}
+
+void SAL_CALL urp_sendRequest(
+ uno_Environment *pEnvRemote,
+ typelib_TypeDescription * pMemberType,
+ rtl_uString *pOid,
+ typelib_InterfaceTypeDescription *pInterfaceType,
+ void *pReturn,
+ void *ppArgs[],
+ uno_Any **ppException
+ )
+{
+ remote_Context *pContext = (remote_Context *) pEnvRemote->pContext;
+ urp_BridgeImpl *pImpl = (urp_BridgeImpl*) ( pContext->m_pBridgeImpl );
+
+ uno_threadpool_Handle *pThreadpoolHandle = 0;
+ sal_Bool bOneway = typelib_TypeClass_INTERFACE_METHOD == pMemberType->eTypeClass ?
+ (( typelib_InterfaceMethodTypeDescription * ) pMemberType)->bOneWay :
+ sal_False;
+ sal_Bool bReleaseForTypeDescriptionNecessary = sal_False;
+
+ // get thread id
+ sal_Sequence *pThreadId = 0;
+ uno_getIdOfCurrentThread( &pThreadId );
+ ByteSequence aThreadId = ByteSequence( pThreadId , BYTESEQ_NOACQUIRE );
+
+ ClientJob clientJob = ClientJob( pEnvRemote, pImpl );
+ {
+ MutexGuard guard( pImpl->m_marshalingMutex );
+
+ if( pImpl->m_bDisposed )
+ {
+ prepareRuntimeExceptionClientSide(
+ ppException , OUString( RTL_CONSTASCII_USTRINGPARAM( "URP-Bridge: disposed" )) );
+ return;
+ }
+
+ clientJob.m_ppArgs = ppArgs;
+ clientJob.m_pReturn = pReturn;
+ clientJob.m_ppException = ppException;
+
+ if( typelib_TypeClass_INTERFACE_METHOD == pMemberType->eTypeClass )
+ {
+ clientJob.m_pMethodType = ( typelib_InterfaceMethodTypeDescription * ) pMemberType;
+ }
+
+ if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pMemberType->eTypeClass )
+ {
+ clientJob.m_pAttributeType =
+ ( typelib_InterfaceAttributeTypeDescription * ) pMemberType;
+ }
+
+ // calculate method index
+ sal_Int32 nMethodIndex = 0;
+ if( ! pInterfaceType->aBase.bComplete )
+ {
+ // must be acquired because typedescription may be exchanged
+ typelib_typedescription_acquire((typelib_TypeDescription*) pInterfaceType );
+ bReleaseForTypeDescriptionNecessary = sal_True;
+ typelib_typedescription_complete( (typelib_TypeDescription ** ) &pInterfaceType );
+ }
+ nMethodIndex = pInterfaceType->pMapMemberIndexToFunctionIndex[
+ ((typelib_InterfaceMemberTypeDescription*)pMemberType)->nPosition ];
+
+ if( clientJob.m_pAttributeType && clientJob.m_ppArgs )
+ {
+ // setter
+ nMethodIndex ++;
+ }
+
+ // build up the flag byte
+ sal_Bool bType = sal_False, bOid = sal_False, bTid = sal_False;
+ sal_uInt8 nFlags = 0;
+ if( pImpl->m_lastOutType.getTypeLibType() != pInterfaceType->aBase.pWeakRef &&
+ ! typelib_typedescriptionreference_equals(
+ pImpl->m_lastOutType.getTypeLibType(), pInterfaceType->aBase.pWeakRef ) )
+ {
+ //new type
+ nFlags = nFlags | HDRFLAG_NEWTYPE;
+ bType = sal_True;
+ }
+ if( pImpl->m_lastOutOid.pData != pOid &&
+ rtl_ustr_compare_WithLength( pImpl->m_lastOutOid.pData->buffer,
+ pImpl->m_lastOutOid.pData->length,
+ pOid->buffer,
+ pOid->length ) )
+ {
+ //new object id
+ nFlags = nFlags | HDRFLAG_NEWOID;
+ bOid = sal_True;
+ }
+ if( pImpl->m_lastOutTid.getHandle() != aThreadId.getHandle() &&
+ !(pImpl->m_lastOutTid == aThreadId) )
+ {
+ // new threadid
+ nFlags = nFlags | HDRFLAG_NEWTID;
+ bTid = sal_True;
+ }
+#ifdef BRIDGES_URP_PROT
+ sal_Int32 nLogStart = pImpl->m_blockMarshaler.getPos();
+#endif
+ if( nFlags )
+ {
+ // the flag byte is needed + request
+ nFlags = nFlags | HDRFLAG_LONG | HDRFLAG_REQUEST; //
+ if( nMethodIndex >= 0x100 )
+ {
+ nFlags = nFlags | HDRFLAG_LONGMETHODID;
+ }
+ if( clientJob.m_pMethodType && clientJob.m_pMethodType->bOneWay )
+ {
+ // oneway
+ nFlags = nFlags | HDRFLAG_ONEWAY;
+ }
+ pImpl->m_blockMarshaler.packInt8( &nFlags );
+
+ if( nFlags & HDRFLAG_LONGMETHODID )
+ {
+ sal_uInt16 nMethod = (sal_uInt16 ) nMethodIndex;
+ pImpl->m_blockMarshaler.packInt16( &nMethod );
+ }
+ else
+ {
+ sal_uInt8 nMethod = (sal_uInt8) nMethodIndex;
+ pImpl->m_blockMarshaler.packInt8( &nMethod );
+ }
+ }
+ else
+ {
+ // no flag byte needed, simply marshal the method index
+ if( nMethodIndex >= 64 )
+ {
+ sal_uInt16 nMethod = ( sal_uInt16 ) nMethodIndex;
+ nMethod = nMethod | 0x4000;
+ pImpl->m_blockMarshaler.packInt16( &nMethod );
+ }
+ else
+ {
+ sal_uInt8 nMethod = (sal_uInt8 ) nMethodIndex;
+ pImpl->m_blockMarshaler.packInt8( &nMethod );
+ }
+ }
+
+ // marshal type,oid,tid
+ if( bType )
+ {
+ pImpl->m_lastOutType = pInterfaceType->aBase.pWeakRef;
+ pImpl->m_blockMarshaler.packType( &(pImpl->m_lastOutType) );
+ }
+ if( bOid )
+ {
+ pImpl->m_lastOutOid = pOid;
+ pImpl->m_blockMarshaler.packOid( pImpl->m_lastOutOid );
+ }
+ if( bTid )
+ {
+ pImpl->m_lastOutTid = aThreadId;
+ pImpl->m_blockMarshaler.packTid( pImpl->m_lastOutTid );
+ }
+
+
+ // marshal arguments !
+#ifdef BRIDGES_URP_PROT
+ sal_Int32 nLogHeader = pImpl->m_blockMarshaler.getPos();
+#endif
+ if( clientJob.m_pMethodType )
+ {
+ sal_Int32 i;
+ for( i = 0 ; i < clientJob.m_pMethodType->nParams ; i ++ )
+ {
+ if( clientJob.m_pMethodType->pParams[i].bIn )
+ {
+ typelib_TypeDescription *pType = 0;
+ TYPELIB_DANGER_GET( &pType , clientJob.m_pMethodType->pParams[i].pTypeRef );
+ pImpl->m_blockMarshaler.pack( ppArgs[i] , pType );
+ TYPELIB_DANGER_RELEASE( pType );
+ }
+ }
+ }
+ else if( clientJob.m_pAttributeType && clientJob.m_pReturn )
+ {
+ // nothing to do !
+ }
+ else if( clientJob.m_pAttributeType && clientJob.m_ppArgs )
+ {
+ typelib_TypeDescription *pType = 0;
+ TYPELIB_DANGER_GET( &pType , clientJob.m_pAttributeType->pAttributeTypeRef );
+ pImpl->m_blockMarshaler.pack( clientJob.m_ppArgs[0] , pType );
+ TYPELIB_DANGER_RELEASE( pType );
+ }
+ else
+ {
+ OSL_ASSERT( 0 );
+ }
+
+#ifdef BRIDGES_URP_PROT
+ urp_logCall( pImpl, pImpl->m_blockMarshaler.getPos() - nLogStart,
+ pImpl->m_blockMarshaler.getPos() - nLogHeader, ! bOneway,
+ ((typelib_InterfaceMemberTypeDescription*)pMemberType)->pMemberName );
+#endif
+
+ if( ! bOneway )
+ {
+ pThreadpoolHandle = uno_threadpool_createHandle( (sal_Int64 ) pEnvRemote );
+ pImpl->m_clientJobContainer.add( aThreadId , &clientJob );
+ }
+
+ //---------------------------
+ // Inform the writer thread, that there is some work to do
+ //---------------------------
+ pImpl->m_pWriter->touch( !bOneway );
+
+ // release the guard
+ }
+
+ if(! bOneway)
+ {
+ //---------------------------
+ // Wait for the reply
+ //---------------------------
+ ClientJob * pData = 0;
+ uno_threadpool_enter( pThreadpoolHandle, (void **) &pData );
+
+ if( ! pData )
+ {
+ OSL_VERIFY( &clientJob ==
+ pImpl->m_clientJobContainer.remove( aThreadId ) );
+
+ prepareRuntimeExceptionClientSide(
+ ppException, OUString( RTL_CONSTASCII_USTRINGPARAM( "URP_Bridge : disposed" ) ) );
+ }
+ }
+ else
+ {
+ //----------------
+ // One way call
+ //----------------
+ *ppException = 0;
+ }
+
+ uno_releaseIdFromCurrentThread();
+
+ if( bReleaseForTypeDescriptionNecessary )
+ typelib_typedescription_release( (typelib_TypeDescription *) pInterfaceType );
+}
+
+}
+
+
diff --git a/bridges/source/remote/urp/urp_dispatch.hxx b/bridges/source/remote/urp/urp_dispatch.hxx
new file mode 100644
index 000000000000..630f7c19ce69
--- /dev/null
+++ b/bridges/source/remote/urp/urp_dispatch.hxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_dispatch.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <rtl/ustring.hxx>
+
+#include <typelib/typedescription.h>
+
+#include <uno/any2.h>
+
+
+typedef struct _uno_Environment uno_Environment;
+struct remote_Interface;
+
+
+
+namespace bridges_urp {
+
+ const sal_uInt8 HDRFLAG_LONG = 0x80;
+ const sal_uInt8 HDRFLAG_REQUEST = 0x40;
+ const sal_uInt8 HDRFLAG_EXCEPTIONOCCURED = 0x20;
+ const sal_uInt8 HDRFLAG_NEWTYPE = 0x20;
+ const sal_uInt8 HDRFLAG_NEWOID = 0x10;
+ const sal_uInt8 HDRFLAG_NEWTID = 0x08;
+ const sal_uInt8 HDRFLAG_LONGMETHODID = 0x04;
+ const sal_uInt8 HDRFLAG_ONEWAY = 0x02;
+
+ void SAL_CALL urp_sendCloseConnection( uno_Environment *pEnvRemote );
+
+ void SAL_CALL urp_sendRequest(
+ uno_Environment *pEnvRemote,
+ typelib_TypeDescription * pMemberType,
+ rtl_uString *pOid,
+ typelib_InterfaceTypeDescription *pInterfaceType,
+ void *pReturn,
+ void *ppArgs[],
+ uno_Any **ppException
+ );
+
+}
+
diff --git a/bridges/source/remote/urp/urp_environment.cxx b/bridges/source/remote/urp/urp_environment.cxx
new file mode 100644
index 000000000000..46773c8f427b
--- /dev/null
+++ b/bridges/source/remote/urp/urp_environment.cxx
@@ -0,0 +1,431 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_environment.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <assert.h>
+#include <stdio.h>
+
+#include <osl/interlck.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.h>
+#include <osl/mutex.hxx>
+
+#include <rtl/alloc.h>
+#include <rtl/uuid.h>
+#include <vos/thread.hxx>
+
+#include <uno/environment.h>
+#include <uno/lbnames.h>
+#include <uno/mapping.hxx>
+#include <uno/threadpool.h>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <bridges/remote/proxy.hxx>
+#include <bridges/remote/stub.hxx>
+#include <bridges/remote/context.h>
+#include <bridges/remote/mapping.hxx>
+#include <bridges/remote/counter.hxx>
+#include <bridges/remote/bridgeimpl.hxx>
+#include <bridges/remote/helper.hxx>
+
+#include "urp_bridgeimpl.hxx"
+#include "urp_writer.hxx"
+#include "urp_reader.hxx"
+#include "urp_dispatch.hxx"
+#include "urp_log.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+
+
+#define UNO_LB_URP "urp"
+
+namespace bridges_urp
+{
+
+void test_cache()
+{
+ OUString a = OUString( RTL_CONSTASCII_USTRINGPARAM( "a" ) );
+ OUString b = OUString( RTL_CONSTASCII_USTRINGPARAM( "b" ) );
+ OUString c = OUString( RTL_CONSTASCII_USTRINGPARAM( "c" ) );
+ Cache < OUString , equalOUString > cache ( 2 );
+
+ sal_Int32 n = cache.put( a );
+ sal_Int32 nR = cache.seek( a );
+ OSL_ASSERT( n == nR );
+ OSL_ASSERT( 0 == n );
+
+ n = cache.put( b );
+ OSL_ASSERT( 1 == n );
+
+ cache.put( c );
+
+ OSL_ASSERT( 0xffff == cache.seek( a ) );
+ OSL_ASSERT( 1 == cache.seek( b ) );
+ OSL_ASSERT( 0 == cache.seek( c ) );
+
+ OSL_ASSERT( 1 == cache.put( a ) );
+ OSL_ASSERT( 0xffff == cache.seek( b) );
+ OSL_ASSERT( 1 == cache.seek( a ) );
+ OSL_ASSERT( 0 == cache.seek( c ) );
+}
+
+/*******************
+ * Are we within thread, that calls destructors of static objects ?
+ *******************/
+sal_Bool g_bStaticDestructorsCalled = sal_False;
+struct StaticSingleton
+{
+ ~StaticSingleton()
+ {
+ g_bStaticDestructorsCalled = sal_True;
+ }
+};
+StaticSingleton singleton;
+
+#ifdef DEBUG
+static MyCounter thisCounter( "Remote Environment" );
+#endif
+
+struct RemoteEnvironment
+{
+
+ static void SAL_CALL thisDisposing( uno_Environment *pEnvRemote );
+ static void SAL_CALL thisComputeObjectIdentifier( uno_ExtEnvironment *pEnvRemote,
+ rtl_uString **ppOid,
+ void *pInterface );
+ static void SAL_CALL thisAcquireInterface( uno_ExtEnvironment * pEnvRemote ,
+ void *pInterface );
+ static void SAL_CALL thisReleaseInterface( uno_ExtEnvironment * pEnvRemote,
+ void *pInterface);
+ static void SAL_CALL thisDispose( uno_Environment *pEnvRemote );
+};
+
+void SAL_CALL allThreadsAreGone( uno_Environment * pEnvRemote )
+{
+ remote_Context *pContext = (remote_Context *) pEnvRemote->pContext;
+ urp_BridgeImpl *pImpl = ( urp_BridgeImpl *) pContext->m_pBridgeImpl;
+
+ ::osl::MutexGuard guard( pImpl->m_disposingMutex );
+
+ pImpl->m_cndWaitForThreads.set();
+
+}
+
+void SAL_CALL releaseStubs( uno_Environment *pEnvRemote )
+{
+
+ ((remote_Context * ) pEnvRemote->pContext )->m_pBridgeImpl->m_bReleaseStubsCalled = sal_True;
+
+ remote_Interface **ppInterfaces = 0;
+ sal_Int32 nCount;
+ pEnvRemote->pExtEnv->getRegisteredInterfaces( pEnvRemote->pExtEnv,
+ (void***)&ppInterfaces,
+ &nCount,
+ rtl_allocateMemory );
+
+ sal_Int32 i;
+ for( i = 0 ; i < nCount ; i ++ )
+ {
+ if( ppInterfaces[i]->acquire == bridges_remote::Uno2RemoteStub::thisAcquire )
+ {
+ // these are freed by the environment, so no release necessary
+ pEnvRemote->pExtEnv->revokeInterface( pEnvRemote->pExtEnv, ppInterfaces[i] );
+ }
+ else
+ {
+ ppInterfaces[i]->release( ppInterfaces[i] );
+ }
+ }
+
+ rtl_freeMemory( (void*) ppInterfaces );
+}
+
+void RemoteEnvironment::thisDispose( uno_Environment *pEnvRemote )
+{
+ remote_Context *pContext = (remote_Context *) pEnvRemote->pContext;
+ urp_BridgeImpl *pImpl = ( urp_BridgeImpl *) pContext->m_pBridgeImpl;
+
+ ::osl::ClearableMutexGuard guard( pImpl->m_disposingMutex );
+ if( pContext->m_pBridgeImpl->m_bDisposed &&
+ ( ! pImpl->m_pReader ||
+ osl_getThreadIdentifier(0) ==
+ (oslThreadIdentifier) pImpl->m_pReader->getIdentifier() ) )
+ {
+ return;
+ }
+ // in case, that the static destructors already have been called, no
+ // tiding up is done.
+ if( ! g_bStaticDestructorsCalled && ! pContext->m_pBridgeImpl->m_bDisposed )
+ {
+ // TODO : not threadsafe
+ // synchronization with dispatch methods needed !
+
+ pImpl->m_bDisposed = sal_True;
+
+
+ // from now on, no calls can be delivered via the bridge
+ uno_threadpool_disposeThreads( (sal_Int64) pEnvRemote );
+
+
+ // close the connection
+ urp_sendCloseConnection( pEnvRemote );
+ pImpl->m_pWriter->abort();
+ pContext->m_pConnection->close( pContext->m_pConnection );
+
+ if( osl_getThreadIdentifier(0) ==
+ (oslThreadIdentifier) pImpl->m_pReader->getIdentifier() )
+ {
+ // This is the reader thread. Let the thread destroy itself
+ // the reader thread object must also release the connection at this stage !
+ pImpl->m_pReader->destroyYourself();
+ }
+ else
+ {
+ // wait for the reader thread
+ // the reader thread object must also release the connection,
+ // when terminating !!!!
+ pImpl->m_pReader->join();
+ }
+
+ // wait for the writer thread
+ pImpl->m_pWriter->join();
+
+ // destroy the threads
+ delete pImpl->m_pWriter;
+ pImpl->m_pWriter = 0;
+
+ if( osl_getThreadIdentifier(0) !=
+ (oslThreadIdentifier) pImpl->m_pReader->getIdentifier() )
+ {
+ // This is not the reader thread, so the thread object is deleted
+ delete pImpl->m_pReader;
+ }
+ pImpl->m_pReader = 0;
+
+ // now let the context go !
+ pContext->dispose( pContext );
+
+ if( 0 != pImpl->m_nRemoteThreads )
+ {
+ // Wait for all threads
+ pImpl->m_cndWaitForThreads.reset();
+ guard.clear();
+ pImpl->m_cndWaitForThreads.wait();
+ OSL_ASSERT( ! pImpl->m_nRemoteThreads );
+ }
+ else
+ {
+ guard.clear();
+ }
+
+ // delete the stubs
+ releaseStubs( pEnvRemote );
+ }
+}
+
+
+void RemoteEnvironment::thisDisposing( uno_Environment *pEnvRemote )
+{
+ remote_Context *pContext = (remote_Context * )pEnvRemote->pContext;
+ urp_BridgeImpl *pImpl = ((urp_BridgeImpl*) pContext->m_pBridgeImpl);
+
+ {
+ ::osl::ClearableMutexGuard guard( pImpl->m_disposingMutex );
+ if( ! pImpl->m_bDisposed )
+ {
+ guard.clear();
+ thisDispose( pEnvRemote );
+ }
+ }
+
+ uno_threadpool_stopDisposeThreads( (sal_Int64) pEnvRemote );
+
+ pContext->aBase.release( (uno_Context * ) pContext );
+#ifdef DEBUG
+ thisCounter.release();
+#endif
+}
+
+void RemoteEnvironment::thisComputeObjectIdentifier( uno_ExtEnvironment *pEnvRemote,
+ rtl_uString **ppOid ,
+ void *pInterface)
+{
+ assert( 0 );
+ // should never be called
+}
+
+void RemoteEnvironment::thisAcquireInterface( uno_ExtEnvironment *pEnvRemote, void *pInterface )
+{
+ ((remote_Interface *)pInterface)->acquire( ( remote_Interface *) pInterface );
+}
+
+void RemoteEnvironment::thisReleaseInterface( uno_ExtEnvironment *pEnvRemote, void *pInterface )
+{
+ ((remote_Interface *)pInterface)->release( ( remote_Interface *) pInterface );
+}
+
+} // end namespace bridges_urp
+using namespace bridges_urp;
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pEnvRemote )
+{
+ // set C-virtual methods
+ pEnvRemote->environmentDisposing = RemoteEnvironment::thisDisposing;
+ pEnvRemote->pExtEnv->computeObjectIdentifier = RemoteEnvironment::thisComputeObjectIdentifier;
+ pEnvRemote->pExtEnv->acquireInterface = RemoteEnvironment::thisAcquireInterface;
+ pEnvRemote->pExtEnv->releaseInterface = RemoteEnvironment::thisReleaseInterface;
+ pEnvRemote->dispose = RemoteEnvironment::thisDispose;
+
+ remote_Context *pContext = ( remote_Context * ) pEnvRemote->pContext;
+ pContext->aBase.acquire( ( uno_Context * ) pContext );
+ pContext->getRemoteInstance = ::bridges_remote::remote_sendQueryInterface;
+
+ // Initialize impl struct urp_BridgeImpl
+ sal_Int32 nCacheSize = 256;
+ sal_Int32 nTimeoutMUSEC = 10000;
+ sal_Int32 nFlushBlockSize = 4*1024;
+
+ urp_BridgeImpl *pImpl = new ::bridges_urp::urp_BridgeImpl( nCacheSize, 8192 );
+ pContext->m_pBridgeImpl = pImpl;
+
+ pImpl->m_cndWaitForThreads;
+ pImpl->m_allThreadsAreGone = allThreadsAreGone;
+ pImpl->m_sendRequest = urp_sendRequest;
+ pImpl->m_nFlushBlockSize = nFlushBlockSize;
+ pImpl->m_nTimeoutMUSEC = nTimeoutMUSEC;
+ pImpl->m_nRemoteThreads = 0;
+ pImpl->m_bDisposed = sal_False;
+ pImpl->m_bReleaseStubsCalled = sal_False;
+
+ pImpl->m_pWriter = new ::bridges_urp::OWriterThread( pContext->m_pConnection , pImpl );
+ pImpl->m_pWriter->create();
+
+ pImpl->m_pReader = new ::bridges_urp::OReaderThread( pContext->m_pConnection ,
+ pEnvRemote,
+ pImpl->m_pWriter );
+ pImpl->m_pReader->create();
+
+#ifdef BRIDGES_URP_PROT
+ pImpl->m_pLogFile = 0;
+ char *p = getenv( "PROT_REMOTE" );
+ if( p )
+ {
+ static int counter;
+ OString s(p);
+ s += OString::valueOf( (sal_Int32) counter );
+ pImpl->m_pLogFile = fopen( s.getStr() , "w" );
+ counter++;
+ }
+#endif
+ // start reader and writer threads
+#ifdef DEBUG
+ thisCounter.acquire();
+#endif
+}
+
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_ext_getMapping(
+ uno_Mapping ** ppMapping,
+ uno_Environment * pFrom,
+ uno_Environment * pTo )
+{
+ OSL_ASSERT( ppMapping && pFrom && pTo );
+ if (ppMapping && pFrom && pTo)
+ {
+ if (*ppMapping)
+ ((*ppMapping)->release)( *ppMapping );
+ bridges_remote::RemoteMapping * pMapping = 0;
+
+ ::rtl::OUString sFromName = pFrom->pTypeName;
+ ::rtl::OUString sToName = pTo->pTypeName;
+ ::rtl::OUString sUno = OUString::createFromAscii( UNO_LB_UNO );
+ ::rtl::OUString sRemote = OUString::createFromAscii( UNO_LB_URP );
+ if ( sFromName.equalsIgnoreCase( sRemote ) &&
+ sToName.equalsIgnoreCase( sUno ) )
+ {
+ pMapping = new bridges_remote::RemoteMapping( pTo, /* Uno */
+ pFrom, /*remote*/
+ bridges_remote::RemoteMapping::remoteToUno,
+ OUString() );
+ }
+ else if ( sFromName.equalsIgnoreCase( sUno ) &&
+ sToName.equalsIgnoreCase( sRemote ) )
+ {
+ pMapping = new bridges_remote::RemoteMapping( pFrom ,
+ pTo ,
+ bridges_remote::RemoteMapping::unoToRemote,
+ OUString() );
+ }
+
+ *ppMapping = (uno_Mapping * )pMapping;
+ OUString dummy;
+ uno_registerMapping( ppMapping ,
+ bridges_remote::RemoteMapping::thisFree,
+ pFrom ,
+ pTo ,
+ dummy.pData );
+ }
+}
+
+
diff --git a/bridges/source/remote/urp/urp_job.cxx b/bridges/source/remote/urp/urp_job.cxx
new file mode 100644
index 000000000000..7768e4493b82
--- /dev/null
+++ b/bridges/source/remote/urp/urp_job.cxx
@@ -0,0 +1,540 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_job.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <string.h>
+#include <stdio.h>
+
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+
+#include <rtl/alloc.h>
+
+#include <uno/threadpool.h>
+
+#include <bridges/cpp_uno/type_misc.hxx>
+#include <bridges/remote/proxy.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include "urp_job.hxx"
+#include "urp_bridgeimpl.hxx"
+#include "urp_writer.hxx"
+#include "urp_dispatch.hxx"
+#include "urp_log.hxx"
+#include "urp_marshal.hxx"
+
+using namespace ::std;
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+
+
+namespace bridges_urp
+{
+
+ Job::Job(
+ uno_Environment *pEnvRemote,
+ sal_Sequence *pTid,
+ struct urp_BridgeImpl *pBridgeImpl,
+ Unmarshal *pUnmarshal )
+ : m_pTid( pTid )
+ , m_counter( pEnvRemote )
+ , m_pBridgeImpl( pBridgeImpl )
+ , m_pUnmarshal( pUnmarshal )
+ {
+ if( m_pTid )
+ rtl_byte_sequence_acquire( pTid );
+ }
+
+ Job::~Job()
+ {
+ if( m_pTid )
+ rtl_byte_sequence_release( m_pTid );
+ }
+
+ // static method
+ void Job::doit( void *pThis )
+ {
+ Job *pJob = ( Job * ) pThis;
+ pJob->execute();
+ delete pJob;
+ }
+
+
+ //--------------------------------------------------------------------------------------
+ sal_Bool ClientJob::extract( )
+ {
+ sal_Bool bReturn = sal_True;
+
+ //--------------------------
+ // Handle the reply, unpack data
+ //--------------------------
+ if( m_bExceptionOccured )
+ {
+ bReturn = m_pUnmarshal->unpackAny( *m_ppException );
+ }
+ else
+ {
+ //---------------------------------
+ // alles ist gut
+ //---------------------------------
+ if( m_pMethodType )
+ {
+ if( m_pMethodType->pReturnTypeRef->eTypeClass != typelib_TypeClass_VOID )
+ {
+ typelib_TypeDescription *pType = 0;
+ TYPELIB_DANGER_GET( &pType , m_pMethodType->pReturnTypeRef );
+ m_pUnmarshal->unpack( m_pReturn , pType );
+ TYPELIB_DANGER_RELEASE( pType );
+ }
+
+ // out parameters
+ sal_Int32 i;
+ for( i = 0 ; i < m_pMethodType->nParams ; i ++ )
+ {
+ if( m_pMethodType->pParams[i].bOut )
+ {
+ typelib_TypeDescription *pType = 0;
+ TYPELIB_DANGER_GET( &pType , m_pMethodType->pParams[i].pTypeRef );
+ if( m_pMethodType->pParams[i].bIn )
+ {
+ uno_destructData( m_ppArgs[i] , pType , ::bridges_remote::remote_release );
+ }
+ m_pUnmarshal->unpack( m_ppArgs[i] , pType );
+ TYPELIB_DANGER_RELEASE( pType );
+ }
+ }
+ }
+ else if( m_pAttributeType && m_pReturn )
+ {
+ typelib_TypeDescription *pType = 0;
+ TYPELIB_DANGER_GET( &pType , m_pAttributeType->pAttributeTypeRef );
+ m_pUnmarshal->unpack( m_pReturn , pType );
+ TYPELIB_DANGER_RELEASE( pType );
+ }
+ else if( m_pAttributeType && m_ppArgs )
+ {
+ // nothing to do
+ }
+ else
+ {
+ OSL_ASSERT( 0 );
+ }
+ *m_ppException = 0;
+ }
+ return sal_True;
+ }
+
+ void ClientJob::initiate()
+ {
+ uno_threadpool_putReply( m_pTid , (sal_Int8*) this );
+ }
+
+
+
+ //------------------------------------------------------------------------------------
+ ServerMultiJob::ServerMultiJob(
+ uno_Environment *pEnvRemote,
+ sal_Sequence *pTid,
+ struct urp_BridgeImpl *pBridgeImpl,
+ Unmarshal *pUnmarshal )
+ : Job( pEnvRemote, pTid, pBridgeImpl , pUnmarshal )
+ , m_pEnvRemote( pEnvRemote )
+ , m_pCurrentMem( (sal_Int8*)rtl_allocateMemory( g_nInitialMemorySize ) )
+ , m_nCurrentMemPosition( 0 )
+ , m_nCalls( 0 )
+ {
+ m_pEnvRemote->acquire( m_pEnvRemote );
+ }
+
+ ServerMultiJob::~ServerMultiJob()
+ {
+ sal_Int32 i;
+ for( i = 0 ; i < m_nCalls ; i ++ )
+ {
+ struct MemberTypeInfo *const pMTI = &( m_aTypeInfo[i] );
+ struct ServerJobEntry *const pSJE = &( m_aEntries[i] );
+
+ if( pSJE->m_pRemoteI )
+ pSJE->m_pRemoteI->release( pSJE->m_pRemoteI );
+
+ if( pSJE->m_pOid )
+ rtl_uString_release( pSJE->m_pOid );
+
+ if( pSJE->m_pInterfaceTypeRef )
+ typelib_typedescriptionreference_release( pSJE->m_pInterfaceTypeRef );
+
+ if( pMTI->m_pInterfaceType )
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pMTI->m_pInterfaceType );
+
+ for( sal_Int32 iArgs = 0 ; iArgs < pMTI->m_nArgCount ; iArgs ++ )
+ {
+ if( pMTI->m_ppArgType[iArgs] )
+ TYPELIB_DANGER_RELEASE( pMTI->m_ppArgType [iArgs] );
+ }
+ if( pMTI->m_pReturnType )
+ TYPELIB_DANGER_RELEASE( pMTI->m_pReturnType );
+
+ if( pMTI->m_pMethodType )
+ typelib_typedescription_release( (typelib_TypeDescription*)pMTI->m_pMethodType );
+ if( pMTI->m_pAttributeType )
+ typelib_typedescription_release( (typelib_TypeDescription*)pMTI->m_pAttributeType );
+ }
+
+ rtl_freeMemory( m_pCurrentMem );
+ for( list< sal_Int8 *>::iterator ii = m_lstMem.begin() ; ii != m_lstMem.end() ; ++ii )
+ rtl_freeMemory( *ii );
+
+ if( m_pEnvRemote )
+ m_pEnvRemote->release( m_pEnvRemote );
+
+ }
+
+ void ServerMultiJob::execute()
+ {
+ for( sal_Int32 i = 0; i < m_nCalls ; i ++ )
+ {
+ struct MemberTypeInfo * const pMTI = &( m_aTypeInfo[i] );
+ struct ServerJobEntry * const pSJE = &( m_aEntries[i] );
+
+ if( ! pSJE->m_pRemoteI )
+ {
+ // -------------------
+ // Initial object ?
+ // ------------------
+ // be robust : Sending a release on a not constructed object
+ // provokes an segfault. Make sure, the call
+ // is not a release call.
+ remote_Context *pRemoteC = ((remote_Context*)m_pEnvRemote->pContext);
+ if( ! pMTI->m_bIsReleaseCall && pRemoteC->m_pInstanceProvider )
+ {
+ pRemoteC->m_pInstanceProvider->getInstance(
+ pRemoteC->m_pInstanceProvider,
+ m_pEnvRemote,
+ &(pSJE->m_pRemoteI),
+ pSJE->m_pOid,
+ pMTI->m_pInterfaceType );
+ }
+
+ if( ! pSJE->m_pRemoteI )
+ {
+ // Requested object could not be located in this environment,
+ // throw a runtimeexception
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM( "urp-bridge: unknown object identifier : " ) );
+ sMessage += pSJE->m_pOid;
+
+ // prepare the exception
+ prepareRuntimeException( sMessage , i );
+ // no interface to call on, but unmarshaling must continue to update cache
+ }
+ }
+
+ if( pSJE->m_pException )
+ {
+ // errors during extracting, do nothing
+ }
+ else
+ {
+ pSJE->m_pException = &(pSJE->m_exception );
+
+ if( pMTI->m_bIsReleaseCall )
+ {
+ pSJE->m_pRemoteI->release( pSJE->m_pRemoteI );
+ pSJE->m_pException = 0;
+ }
+ else
+ {
+ pSJE->m_pRemoteI->pDispatcher(
+ pSJE->m_pRemoteI,
+ pMTI->m_pMethodType ? (typelib_TypeDescription*) pMTI->m_pMethodType :
+ (typelib_TypeDescription*) pMTI->m_pAttributeType,
+ pSJE->m_pReturn,
+ pSJE->m_ppArgs,
+ &(pSJE->m_pException) );
+ }
+ }
+
+ // now destruct parameters and marshal replies
+ // Note : when call is synchron => m_nCalls == 1
+ if( pMTI->m_pMethodType && pMTI->m_pMethodType->bOneWay )
+ {
+ // Oneway call, destruct in parameters
+ for( sal_Int32 i = 0 ; i < pMTI->m_pMethodType->nParams ; i ++ )
+ {
+ // usually all parameters must be in parameters, but to be robust ...
+ if( pMTI->m_pbIsIn[i] && !cppu_isSimpleType( pMTI->m_ppArgType[i] ) )
+ {
+ uno_destructData( pSJE->m_ppArgs[i] , pMTI->m_ppArgType[i] , 0 );
+ }
+ }
+
+ if( pSJE->m_pException )
+ {
+ uno_any_destruct( pSJE->m_pException, ::bridges_remote::remote_release );
+ }
+
+ }
+ else
+ {
+ // synchron, get the mutex to marshal reply and send immeadiatly
+ MutexGuard guard( m_pBridgeImpl->m_marshalingMutex );
+
+ sal_Bool bTid = sal_False;
+ sal_uInt8 nFlags = HDRFLAG_LONG;
+ ByteSequence tid = m_pTid;
+ if( !( tid == m_pBridgeImpl->m_lastOutTid ) )
+ {
+ // new threadid
+ nFlags = nFlags | HDRFLAG_NEWTID;
+ bTid = sal_True;
+ }
+
+ if( pSJE->m_pException )
+ {
+ nFlags = nFlags | HDRFLAG_EXCEPTIONOCCURED;
+ }
+#ifdef BRIDGES_URP_PROT
+ sal_Int32 nLogStart = m_pBridgeImpl->m_blockMarshaler.getPos();
+#endif
+ m_pBridgeImpl->m_blockMarshaler.packInt8( &nFlags );
+
+ if( bTid )
+ {
+
+ m_pBridgeImpl->m_lastOutTid = tid;
+ m_pBridgeImpl->m_blockMarshaler.packTid( tid );
+ }
+
+#ifdef BRIDGES_URP_PROT
+ sal_Int32 nLogHeader = m_pBridgeImpl->m_blockMarshaler.getPos();
+#endif
+
+ if( pSJE->m_pException )
+ {
+ //--------------------
+ // an exception was thrown
+ //--------------------
+ m_pBridgeImpl->m_blockMarshaler.packAny( &(pSJE->m_exception) );
+ uno_any_destruct( &(pSJE->m_exception) , ::bridges_remote::remote_release );
+
+ // destroy in parameters
+ for( sal_Int32 i = 0 ; i < pMTI->m_nArgCount ; i ++ )
+ {
+ if( pMTI->m_pbIsIn[i] && ! cppu_isSimpleType( pMTI->m_ppArgType[i] ))
+ {
+ uno_destructData( pSJE->m_ppArgs[i] , pMTI->m_ppArgType[i] ,
+ ::bridges_remote::remote_release );
+ }
+ }
+ }
+ else
+ {
+ //---------------------------
+ // alles ist gut ...
+ //--------------------------
+ if( pMTI->m_pReturnType )
+ {
+ m_pBridgeImpl->m_blockMarshaler.pack(
+ pSJE->m_pReturn, pMTI->m_pReturnType );
+ if( ! cppu_isSimpleType( pMTI->m_pReturnType ) )
+ {
+ uno_destructData( pSJE->m_pReturn , pMTI->m_pReturnType ,
+ ::bridges_remote::remote_release );
+ }
+ }
+ for( sal_Int32 i = 0 ; i < pMTI->m_nArgCount ; i ++ )
+ {
+ if( pMTI->m_pbIsOut[i] )
+ {
+ m_pBridgeImpl->m_blockMarshaler.pack(
+ pSJE->m_ppArgs[i] , pMTI->m_ppArgType[i] );
+ }
+ if( ! cppu_isSimpleType( pMTI->m_ppArgType[i] ) )
+ {
+ uno_destructData( pSJE->m_ppArgs[i], pMTI->m_ppArgType[i] ,
+ ::bridges_remote::remote_release );
+ }
+ }
+ }
+
+#ifdef BRIDGES_URP_PROT
+ {
+ typelib_InterfaceMemberTypeDescription *pMemberType =
+ pMTI->m_pMethodType ?
+ (typelib_InterfaceMemberTypeDescription*)pMTI->m_pMethodType :
+ (typelib_InterfaceMemberTypeDescription*)pMTI->m_pAttributeType;
+
+ urp_logReplying( m_pBridgeImpl ,
+ m_pBridgeImpl->m_blockMarshaler.getPos() - nLogStart,
+ m_pBridgeImpl->m_blockMarshaler.getPos() - nLogHeader,
+ pMemberType->pMemberName );
+ }
+#endif
+
+ if( pSJE->m_pRemoteI )
+ {
+ pSJE->m_pRemoteI->release( pSJE->m_pRemoteI );
+ pSJE->m_pRemoteI = 0;
+ }
+
+ // put it on the wire
+ m_pBridgeImpl->m_pWriter->touch( sal_True );
+ } // MutexGuard marshalingMutex
+ }
+ }
+
+ void ServerMultiJob::prepareRuntimeException( const OUString & sMessage , sal_Int32 nCall )
+ {
+ // -------------------------------
+ // Construct the RuntimeException
+ // -------------------------------
+
+ typelib_TypeDescription *pType = 0;
+ getCppuType( (RuntimeException * ) 0 ).getDescription(&pType );
+
+ OSL_ENSURE( pType , "urp-bridge: couldn't get RuntimeException type" );
+
+ m_aEntries[nCall].m_pException = &(m_aEntries[nCall].m_exception);
+ uno_any_construct( m_aEntries[nCall].m_pException , 0 , pType , 0 );
+
+ typelib_typedescription_release( pType );
+ }
+
+ void ServerMultiJob::initiate()
+ {
+ uno_threadpool_putRequest(
+ m_pTid, this, doit,
+ m_aTypeInfo[0].m_pMethodType && m_aTypeInfo[0].m_pMethodType->bOneWay );
+ }
+
+
+ // this method is called by the dispatcher thread to unmarshal a request
+ sal_Bool ServerMultiJob::extract()
+ {
+ sal_Bool bContinue = sal_True;
+ struct MemberTypeInfo * const pMTI = &(m_aTypeInfo[m_nCalls]);
+ struct ServerJobEntry * const pSJE = &(m_aEntries[m_nCalls]);
+
+ pSJE->m_pException = 0;
+ pSJE->m_ppArgs = 0;
+ pSJE->m_pReturn = 0;
+ pMTI->m_pReturnType = 0;
+
+ if( pMTI->m_nArgCount )
+ {
+ pMTI->m_ppArgType =
+ ( typelib_TypeDescription ** ) getHeap( sizeof(void*) * pMTI->m_nArgCount );
+ pSJE->m_ppArgs = (void**) getHeap( sizeof( void * ) * pMTI->m_nArgCount );
+ pMTI->m_pbIsIn = (sal_Bool *) getHeap( sizeof( sal_Bool ) * pMTI->m_nArgCount );
+ pMTI->m_pbIsOut = (sal_Bool *) getHeap( sizeof( sal_Bool ) * pMTI->m_nArgCount );
+ }
+ if( pMTI->m_pMethodType &&
+ pMTI->m_pMethodType->pReturnTypeRef->eTypeClass != typelib_TypeClass_VOID )
+ {
+ TYPELIB_DANGER_GET( &(pMTI->m_pReturnType), pMTI->m_pMethodType->pReturnTypeRef );
+ }
+ else if( pMTI->m_pAttributeType && ! pMTI->m_nArgCount )
+ {
+ TYPELIB_DANGER_GET( &(pMTI->m_pReturnType) , pMTI->m_pAttributeType->pAttributeTypeRef );
+ }
+
+ // normal method
+ if( pMTI->m_pMethodType )
+ {
+ for( sal_Int32 i = 0 ; i < pMTI->m_nArgCount ; i ++ )
+ {
+ pMTI->m_ppArgType[i] = 0;
+ TYPELIB_DANGER_GET( & ( pMTI->m_ppArgType[i] ) , pMTI->m_pMethodType->pParams[i].pTypeRef);
+ pMTI->m_pbIsIn[i] = pMTI->m_pMethodType->pParams[i].bIn;
+ pMTI->m_pbIsOut[i] = pMTI->m_pMethodType->pParams[i].bOut;
+
+ pSJE->m_ppArgs[i] = getHeap( pMTI->m_ppArgType[i]->nSize );
+ if( pMTI->m_pbIsIn[i] )
+ {
+ // everything needs to be constructed
+ bContinue = m_pUnmarshal->unpack(
+ pSJE->m_ppArgs[i], pMTI->m_ppArgType[i] ) && bContinue;
+ }
+ }
+ }
+ else if( pMTI->m_nArgCount )
+ {
+ // set attribut
+ pMTI->m_ppArgType[0] = 0;
+ pMTI->m_pbIsIn[0] = sal_True;
+ pMTI->m_pbIsOut[0] = sal_False;
+ TYPELIB_DANGER_GET(
+ & ( pMTI->m_ppArgType[0] ) , pMTI->m_pAttributeType->pAttributeTypeRef );
+ pSJE->m_ppArgs[0] = getHeap( pMTI->m_ppArgType[0]->nSize );
+ bContinue = m_pUnmarshal->unpack(
+ pSJE->m_ppArgs[0], pMTI->m_ppArgType[0] ) && bContinue;
+ }
+
+ if( pMTI->m_pReturnType )
+ {
+ pSJE->m_pReturn = getHeap( pMTI->m_pReturnType->nSize );
+ }
+
+ m_nCalls ++;
+ return bContinue;
+ }
+}
+
+
diff --git a/bridges/source/remote/urp/urp_job.hxx b/bridges/source/remote/urp/urp_job.hxx
new file mode 100644
index 000000000000..6a716c036255
--- /dev/null
+++ b/bridges/source/remote/urp/urp_job.hxx
@@ -0,0 +1,276 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_job.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <list>
+#include <typelib/typedescription.hxx>
+#include <uno/any2.h>
+#include <uno/environment.h>
+
+#include "urp_threadid.hxx"
+#include "urp_unmarshal.hxx"
+#include <bridges/remote/bridgeimpl.hxx>
+
+const sal_Int32 MAX_ENTRIES_IN_MULTIJOB = 60;
+const sal_Int32 g_nInitialMemorySize = 6192;
+
+
+namespace bridges_urp
+{
+class Unmarshal;
+struct urp_BridgeImpl;
+
+template < class t >
+inline t mymax( const t &t1 , const t &t2 )
+{
+ return t1 > t2 ? t1 : t2;
+}
+
+class Job
+{
+public:
+ Job( uno_Environment *pEnvRemote,
+ sal_Sequence *pTid,
+ struct urp_BridgeImpl *pBridgeImpl,
+ Unmarshal *pUnmarshal );
+
+ Job( uno_Environment *pEnvRemote,
+ struct urp_BridgeImpl *pBridgeImpl,
+ ::bridges_remote::RemoteThreadCounter_HoldEnvWeak value )
+ : m_counter( pEnvRemote , value )
+ , m_pBridgeImpl( pBridgeImpl )
+ , m_pTid( 0 )
+ {}
+
+ virtual ~Job();
+
+ // doit method is used only for ServerJobs, calls execute and pack
+ static void SAL_CALL doit( void *pThreadSpecificData );
+
+ // is called from the dispatcher thread
+ virtual sal_Bool extract( ) = 0;
+ virtual void initiate() = 0;
+ virtual void execute() = 0;
+
+ inline void setThreadId( sal_Sequence *pId )
+ { rtl_byte_sequence_assign( &m_pTid , pId ); }
+ inline void setUnmarshal( Unmarshal *p )
+ { m_pUnmarshal = p; }
+
+protected:
+ Unmarshal *m_pUnmarshal;
+ struct urp_BridgeImpl *m_pBridgeImpl;
+ sal_Sequence *m_pTid;
+ ::bridges_remote::RemoteThreadCounter m_counter;
+};
+
+class ClientJob : public Job
+{
+public:
+ ClientJob( uno_Environment *pEnvRemote, struct urp_BridgeImpl *pBridgeImpl )
+ : Job( pEnvRemote , pBridgeImpl, ::bridges_remote::RTC_HOLDENVWEAK )
+ , m_ppException( 0 )
+ , m_ppArgs( 0 )
+ , m_pReturn( 0 )
+ , m_pMethodType( 0 )
+ , m_pAttributeType( 0 )
+ {}
+
+ // ~ClientJob
+ // no release for method type and attribute type necessary, because
+ // it was acquired by the caller of urp_sendRequest. The lifetime
+ // of the ClientJob object is always shorter than the urp_sendRequest call.
+ ~ClientJob()
+ {}
+
+ virtual sal_Bool extract( );
+ virtual void initiate();
+ virtual void execute()
+ {}
+
+public:
+ void **m_ppArgs;
+ void *m_pReturn;
+ typelib_InterfaceMethodTypeDescription *m_pMethodType;
+ typelib_InterfaceAttributeTypeDescription *m_pAttributeType;
+
+ uno_Any **m_ppException;
+ sal_Bool m_bExceptionOccured;
+};
+
+
+struct MemberTypeInfo
+{
+ typelib_InterfaceTypeDescription *m_pInterfaceType;
+ typelib_InterfaceMethodTypeDescription *m_pMethodType;
+ typelib_InterfaceAttributeTypeDescription *m_pAttributeType;
+ sal_Int32 m_nArgCount;
+ sal_Bool m_bIsReleaseCall;
+ sal_Bool *m_pbIsIn;
+ sal_Bool *m_pbIsOut;
+ typelib_TypeDescription *m_pReturnType;
+ typelib_TypeDescription **m_ppArgType;
+};
+
+
+struct ServerJobEntry
+{
+ rtl_uString *m_pOid;
+ remote_Interface *m_pRemoteI;
+ typelib_TypeDescriptionReference *m_pInterfaceTypeRef;
+ void **m_ppArgs;
+ void *m_pReturn;
+ uno_Any m_exception;
+ uno_Any *m_pException;
+
+};
+
+class ServerMultiJob : public Job
+{
+public:
+ ServerMultiJob( uno_Environment *pEnvRemote,
+ sal_Sequence *pTid,
+ struct urp_BridgeImpl *pBridgeImpl,
+ Unmarshal *pUnmarshal);
+ ~ServerMultiJob();
+public:
+ virtual sal_Bool extract( );
+ virtual void initiate();
+ virtual void execute();
+
+public:
+ // setMethodType or setAttributeType MUST be called before extract
+ inline void setMethodType( typelib_InterfaceMethodTypeDescription *pMethodType, sal_Bool bIsReleaseCall)
+ {
+ m_aTypeInfo[m_nCalls].m_pMethodType = pMethodType;
+ m_aTypeInfo[m_nCalls].m_pAttributeType = 0;
+ m_aTypeInfo[m_nCalls].m_nArgCount = pMethodType->nParams;
+ m_aTypeInfo[m_nCalls].m_bIsReleaseCall = bIsReleaseCall;
+ }
+
+ inline void setAttributeType( typelib_InterfaceAttributeTypeDescription *pAttributeType, sal_Bool bIsSetter )
+ {
+ m_aTypeInfo[m_nCalls].m_pAttributeType = pAttributeType;
+ m_aTypeInfo[m_nCalls].m_pMethodType = 0;
+ m_aTypeInfo[m_nCalls].m_nArgCount = bIsSetter ? 1 : 0;
+ m_aTypeInfo[m_nCalls].m_bIsReleaseCall = sal_False;
+ }
+
+ inline void setType( const ::com::sun::star::uno::Type &type )
+ {
+ m_aEntries[m_nCalls].m_pInterfaceTypeRef = type.getTypeLibType();
+ typelib_typedescriptionreference_acquire( m_aEntries[m_nCalls].m_pInterfaceTypeRef );
+ TYPELIB_DANGER_GET(
+ (typelib_TypeDescription ** )&(m_aTypeInfo[m_nCalls].m_pInterfaceType) ,
+ type.getTypeLibType() );
+ }
+ // setOid or setInterface MUST be called before extract
+ inline void setOid( const ::rtl::OUString & sOid )
+ {
+ m_aEntries[m_nCalls].m_pOid = sOid.pData;
+ rtl_uString_acquire( m_aEntries[m_nCalls].m_pOid );
+ m_aEntries[m_nCalls].m_pRemoteI = 0;
+ }
+
+ // setOid or setInterface MUST be called
+ inline void setInterface( remote_Interface *pRemoteI )
+ {
+ m_aEntries[m_nCalls].m_pRemoteI = pRemoteI;
+ pRemoteI->acquire( pRemoteI );
+ m_aEntries[m_nCalls].m_pOid = 0;
+ }
+
+ inline sal_Bool isFull()
+ { return m_nCalls >= MAX_ENTRIES_IN_MULTIJOB; }
+
+ inline sal_Int8 *getHeap( sal_Int32 nSizeToAlloc )
+ {
+ if( nSizeToAlloc + m_nCurrentMemPosition > g_nInitialMemorySize )
+ {
+ m_lstMem.push_back( m_pCurrentMem );
+ m_pCurrentMem = (sal_Int8*)
+ rtl_allocateMemory( mymax( nSizeToAlloc , g_nInitialMemorySize ) );
+ m_nCurrentMemPosition = 0;
+ }
+ sal_Int8 *pHeap = m_pCurrentMem + m_nCurrentMemPosition;
+ m_nCurrentMemPosition += nSizeToAlloc;
+
+ // care for alignment
+ if( m_nCurrentMemPosition & 0x7 )
+ {
+ m_nCurrentMemPosition = ( ((sal_uInt32)m_nCurrentMemPosition) & ( 0xffffffff - 0x7 )) + 8;
+ }
+ return pHeap;
+ }
+ void prepareRuntimeException( const ::rtl::OUString &sMessage, sal_Int32 nCall );
+
+private:
+ uno_Environment *m_pEnvRemote;
+ sal_Int32 m_nCalls;
+ ServerJobEntry m_aEntries[MAX_ENTRIES_IN_MULTIJOB];
+ MemberTypeInfo m_aTypeInfo[MAX_ENTRIES_IN_MULTIJOB];
+
+ sal_Int8 *m_pCurrentMem;
+ sal_Int32 m_nCurrentMemPosition;
+
+ // list of memory pointers, that must be freed
+ ::std::list< sal_Int8 * > m_lstMem;
+};
+
+}
diff --git a/bridges/source/remote/urp/urp_log.cxx b/bridges/source/remote/urp/urp_log.cxx
new file mode 100644
index 000000000000..5a0ce0f184c3
--- /dev/null
+++ b/bridges/source/remote/urp/urp_log.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_log.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "urp_bridgeimpl.hxx"
+#include "urp_log.hxx"
+
+using namespace ::rtl;
+namespace bridges_urp
+{
+#ifdef BRIDGES_URP_PROT
+ void urp_logCall( urp_BridgeImpl *pBridgeImpl, sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron ,
+ const ::rtl::OUString &sMethodName )
+ {
+ if( pBridgeImpl->m_pLogFile && getenv( "PROT_REMOTE_ACTIVATE" ) )
+ {
+ OString sOperation = OUStringToOString( sMethodName,RTL_TEXTENCODING_ASCII_US );
+ fprintf( pBridgeImpl->m_pLogFile ,
+ "calling [size=%d(usedata=%d)] [synchron=%d] [name=%s]\n" ,
+ nSize, nUseData, bSynchron, sOperation.pData->buffer );
+ }
+ }
+
+ void urp_logServingRequest( urp_BridgeImpl *pBridgeImpl,
+ sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron ,
+ const ::rtl::OUString &sMethodName )
+ {
+ if( pBridgeImpl->m_pLogFile && getenv( "PROT_REMOTE_ACTIVATE" ) )
+ {
+ OString sOperation = OUStringToOString( sMethodName,RTL_TEXTENCODING_ASCII_US );
+ fprintf(
+ pBridgeImpl->m_pLogFile,
+ "serving request [size=%d(usedata=%d)] [synchron=%d] [name=%s]\n",
+ nSize,
+ nUseData,
+ bSynchron,
+ sOperation.pData->buffer
+ );
+
+ }
+ }
+
+ void urp_logGettingReply( urp_BridgeImpl *pBridgeImpl,
+ sal_Int32 nSize, sal_Int32 nUseData,
+ const ::rtl::OUString &sMethodName )
+ {
+ if( pBridgeImpl->m_pLogFile && getenv( "PROT_REMOTE_ACTIVATE" ) )
+ {
+ OString sOperation = OUStringToOString( sMethodName,RTL_TEXTENCODING_ASCII_US );
+ fprintf( pBridgeImpl->m_pLogFile,
+ "getting reply [size=%d(usedata=%d)][name=%s]\n" ,
+ nSize, nUseData,
+ sOperation.pData->buffer);
+ }
+ }
+
+ void urp_logReplying( urp_BridgeImpl *pBridgeImpl,
+ sal_Int32 nSize , sal_Int32 nUseData,
+ const ::rtl::OUString &sMethodName )
+ {
+ if( pBridgeImpl->m_pLogFile && getenv( "PROT_REMOTE_ACTIVATE" ) )
+ {
+ OString sOperation = OUStringToOString(sMethodName,RTL_TEXTENCODING_ASCII_US);
+ fprintf( pBridgeImpl->m_pLogFile,
+ "replying [size=%d(usedata=%d)] [name=%s]\n",
+ nSize, nUseData,
+ sOperation.pData->buffer);
+ }
+ }
+#endif
+}
diff --git a/bridges/source/remote/urp/urp_log.hxx b/bridges/source/remote/urp/urp_log.hxx
new file mode 100644
index 000000000000..cc697a22ba81
--- /dev/null
+++ b/bridges/source/remote/urp/urp_log.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_log.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+namespace bridges_urp
+{
+#ifndef PRODUCT
+#define BRIDGES_URP_PROT
+#endif
+
+#ifdef BRIDGES_URP_PROT
+ void urp_logCall( urp_BridgeImpl *pBridgeImpl ,
+ sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron ,
+ const ::rtl::OUString &sMethodName );
+
+ void urp_logServingRequest( urp_BridgeImpl *pBridgeImpl,
+ sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron ,
+ const ::rtl::OUString &sMethodName );
+
+ void urp_logGettingReply( urp_BridgeImpl *pBridgeImpl,
+ sal_Int32 nSize, sal_Int32 nUseData,
+ const ::rtl::OUString &sMethodName );
+
+ void urp_logReplying( urp_BridgeImpl *pBridgeImpl,
+ sal_Int32 nSize , sal_Int32 nUseData,
+ const ::rtl::OUString &sMethodName );
+#endif
+}
diff --git a/bridges/source/remote/urp/urp_marshal.cxx b/bridges/source/remote/urp/urp_marshal.cxx
new file mode 100644
index 000000000000..c2a6f6ad2765
--- /dev/null
+++ b/bridges/source/remote/urp/urp_marshal.cxx
@@ -0,0 +1,240 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_marshal.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <string.h>
+#include <osl/diagnose.h>
+
+#include <rtl/alloc.h>
+
+#include <uno/any2.h>
+#include <uno/sequence2.h>
+
+#include "urp_marshal.hxx"
+
+using namespace ::rtl;
+
+using namespace ::com::sun::star::uno;
+
+namespace bridges_urp {
+
+static int g_nDetectLittleEndian = 1;
+char g_bMarshalSystemIsLittleEndian = ((char*)&g_nDetectLittleEndian)[0];
+
+Marshal::Marshal( urp_BridgeImpl *pBridgeImpl,
+ sal_Int32 nBufferSize,
+ urp_extractOidCallback callback) :
+ m_callback( callback ),
+ m_nBufferSize( nBufferSize ),
+ m_base( (sal_Int8*)rtl_allocateMemory( nBufferSize ) ),
+ m_pos( m_base + 5 ),
+ m_nSizeOffset( 0 ),
+ m_pBridgeImpl( pBridgeImpl )
+{}
+
+Marshal::~Marshal( )
+{
+ rtl_freeMemory( m_base );
+}
+
+void Marshal::packOid( const ::rtl::OUString & oid )
+{
+ sal_uInt16 nIndex;
+ if( oid.getLength() )
+ {
+ nIndex = m_pBridgeImpl->m_oidCacheOut.seek( oid );
+ if( 0xffff == nIndex )
+ {
+ nIndex = m_pBridgeImpl->m_oidCacheOut.put( oid );
+ packString( (void*)(&oid.pData) );
+ }
+ else
+ {
+ OUString dummy;
+ packString( &dummy );
+ }
+ }
+ else
+ {
+ // null reference
+ sal_uInt16 nIndex = 0xffff;
+ OUString dummy;
+ packString( &dummy );
+ }
+ packInt16( &nIndex );
+}
+
+void Marshal::packTid( const ByteSequence & threadId )
+{
+ sal_uInt16 nIndex = m_pBridgeImpl->m_tidCacheOut.seek( threadId );
+ if( 0xffff == nIndex )
+ {
+ nIndex = m_pBridgeImpl->m_tidCacheOut.put( threadId );
+ packByteSequence( (sal_Int8*) threadId.getConstArray() ,threadId.getLength());
+ }
+ else
+ {
+ packByteSequence( 0 , 0 );
+ }
+ packInt16( &nIndex );
+}
+
+
+void Marshal::packType( void *pSource )
+{
+ typelib_TypeDescriptionReference *pRef =
+ *(typelib_TypeDescriptionReference ** ) pSource;
+
+ OSL_ASSERT( pRef );
+ Type type( pRef );
+
+ sal_uInt8 nTypeClass = type.getTypeClass();
+
+ if( nTypeClass <= /* any*/ 14 )
+ {
+ packInt8( (sal_Int8*)&nTypeClass );
+ }
+ else
+ {
+ OUString sTypeName;
+ sal_uInt16 nIndex = 0xffff;
+
+ nIndex = m_pBridgeImpl->m_typeCacheOut.seek( type );
+ if( 0xffff == nIndex )
+ {
+ // put it into the cache
+ nIndex = m_pBridgeImpl->m_typeCacheOut.put( type );
+ sTypeName = type.getTypeName();
+ nTypeClass = nTypeClass | 0x80;
+ }
+ packInt8( &nTypeClass );
+ packInt16( &nIndex );
+ if( 0x80 & nTypeClass )
+ {
+ packString( &sTypeName );
+ }
+ }
+}
+
+void Marshal::packRecursive( void *pSource , typelib_TypeDescription *pType )
+{
+ switch( pType->eTypeClass )
+ {
+ case typelib_TypeClass_EXCEPTION:
+ case typelib_TypeClass_STRUCT:
+ {
+ typelib_CompoundTypeDescription * pCompType = (typelib_CompoundTypeDescription*)pType;
+
+ if (pCompType->pBaseTypeDescription)
+ {
+ pack( pSource , (typelib_TypeDescription*) pCompType->pBaseTypeDescription );
+ }
+
+ // then construct members
+ typelib_TypeDescriptionReference ** ppTypeRefs = pCompType->ppTypeRefs;
+ sal_Int32 * pMemberOffsets = pCompType->pMemberOffsets;
+ sal_Int32 nDescr = pCompType->nMembers;
+
+ for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos )
+ {
+ typelib_TypeDescription * pMemberType = 0;
+ TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] );
+ pack( (char*)pSource + pMemberOffsets[nPos] , pMemberType );
+ TYPELIB_DANGER_RELEASE( pMemberType );
+ }
+ break;
+ }
+ case typelib_TypeClass_SEQUENCE:
+ {
+ typelib_IndirectTypeDescription *pIndirectType =
+ ( typelib_IndirectTypeDescription* ) pType;
+
+ const sal_Int32 nElements = (*(uno_Sequence **)pSource)->nElements;
+ char * pSourceElements = (char *)(*(uno_Sequence **)pSource)->elements;
+
+ if( typelib_TypeClass_BYTE == pIndirectType->pType->eTypeClass )
+ {
+ // Byte sequences are optimized
+ packByteSequence( (sal_Int8*)pSourceElements , nElements );
+ }
+ else
+ {
+ typelib_TypeDescription *pElementType = 0;
+ TYPELIB_DANGER_GET( &pElementType, pIndirectType->pType );
+ if( pElementType )
+ {
+ const sal_Int32 nElementSize = pElementType->nSize;
+
+ packCompressedSize( nElements );
+ for ( sal_Int32 i = 0 ; i < nElements; i++ )
+ {
+ pack( pSourceElements + (nElementSize*i) , pElementType );
+ }
+ TYPELIB_DANGER_RELEASE( pElementType );
+ }
+ }
+
+ break;
+ }
+ default:
+ OSL_ASSERT( 0 );
+ }
+}
+
+} // end namespace bridges
diff --git a/bridges/source/remote/urp/urp_marshal.hxx b/bridges/source/remote/urp/urp_marshal.hxx
new file mode 100644
index 000000000000..80426ea9f71e
--- /dev/null
+++ b/bridges/source/remote/urp/urp_marshal.hxx
@@ -0,0 +1,378 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_marshal.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _URP_MARSHAL_HXX_
+#define _URP_MARSHAL_HXX_
+
+/**************************************************************************
+#*
+#* last change $Author: hr $ $Date: 2000-09-18 15:28:50 $
+#* $Revision: 1.1.1.1 $
+#*
+#* $Logfile: $
+#*
+#* Copyright (c) 2000, Sun Microsystems
+#*
+#************************************************************************/
+#include <rtl/ustring.hxx>
+#include <rtl/byteseq.hxx>
+
+#include <com/sun/star/uno/Type.hxx>
+
+#include "urp_bridgeimpl.hxx"
+#include "urp_marshal_decl.hxx"
+
+struct remote_Interface;
+
+
+namespace bridges_urp
+{
+ // methods for accessing marshaling buffer
+ inline void Marshal::finish()
+ {
+ sal_Int32 nSize = ( ((sal_uInt32 )(m_pos - m_base)) -5 );
+ OSL_ASSERT( nSize );
+ sal_Int8 *pos = m_pos;
+ m_pos = m_base;
+ packCompressedSize( nSize );
+ if( m_pos == m_base +1 )
+ {
+ ((sal_uInt8*)m_base)[4] = (sal_uInt8) ((sal_uInt8*)m_base)[0];
+ m_nSizeOffset = 4;
+ }
+ else
+ {
+ m_nSizeOffset = 0;
+ }
+ m_pos = pos;
+ }
+
+ inline void Marshal::restart()
+ {
+ m_pos = m_base +5;
+ m_nSizeOffset = 0;
+ }
+
+ inline sal_Int8 *Marshal::getBuffer()
+ {
+ return m_base + m_nSizeOffset;
+ }
+
+ inline sal_Bool Marshal::empty() const
+ {
+ return ( m_pos -m_base ) == 5;
+ }
+
+ inline sal_Int32 Marshal::getSize()
+ {
+ return (sal_Int32)(m_pos - m_base) - m_nSizeOffset;
+ }
+
+ inline void Marshal::ensureAdditionalMem( sal_Int32 nMemToAdd )
+ {
+ sal_Int32 nDiff = m_pos - m_base;
+ if( nDiff + nMemToAdd > m_nBufferSize )
+ {
+ m_nBufferSize = m_nBufferSize * 2 > nDiff + nMemToAdd ?
+ m_nBufferSize* 2 :
+ nDiff + nMemToAdd;
+
+ m_base = ( sal_Int8 * ) rtl_reallocateMemory( m_base , m_nBufferSize );
+ m_pos = m_base + nDiff;
+ }
+ }
+
+
+ // marshaling methods
+ inline void Marshal::packInt8( void *pSource )
+ {
+ ensureAdditionalMem( 1 );
+ *m_pos = *((sal_Int8*) pSource );
+ m_pos++;
+ }
+
+ inline void Marshal::packInt16( void *pSource )
+ {
+ ensureAdditionalMem( 2 );
+ sal_uInt16 *p = ( sal_uInt16 * ) pSource;
+ if( isSystemLittleEndian() )
+ {
+ m_pos[0] = ((unsigned char *)pSource)[1];
+ m_pos[1] = ((unsigned char *)pSource)[0];
+ }
+ else
+ {
+ m_pos[1] = ((unsigned char *)pSource)[1];
+ m_pos[0] = ((unsigned char *)pSource)[0];
+ }
+ m_pos +=2;
+ }
+
+ inline void Marshal::packByteSequence( sal_Int8 *pData , sal_Int32 nLength )
+ {
+ packCompressedSize( nLength );
+
+ ensureAdditionalMem( nLength );
+ memcpy( m_pos , pData , nLength );
+ m_pos += nLength;
+ }
+
+ inline void Marshal::packString( void *pSource )
+ {
+ rtl_uString *p = *( rtl_uString ** ) pSource;
+
+ // to be optimized !
+ // static buffer in marshal
+ ::rtl::OString o = ::rtl::OUStringToOString( p , RTL_TEXTENCODING_UTF8 );
+ sal_Int32 nLength = o.pData->length;
+ packCompressedSize( nLength );
+
+ ensureAdditionalMem( nLength );
+
+ memcpy( m_pos , o.pData->buffer , nLength );
+ m_pos += nLength;
+ }
+
+ inline void Marshal::packAny( void *pSource )
+ {
+ uno_Any *pAny = (uno_Any * ) pSource;
+
+ // pack the type
+ packType( &( pAny->pType ) );
+ // pack the value
+ typelib_TypeDescription *pType = 0;
+ TYPELIB_DANGER_GET( &pType, pAny->pType );
+ pack( pAny->pData , pType );
+ TYPELIB_DANGER_RELEASE( pType );
+ }
+
+ inline void Marshal::packInt32( void *pSource )
+ {
+ ensureAdditionalMem( 4 );
+ if( isSystemLittleEndian() )
+ {
+ m_pos[0] = ((unsigned char *)pSource)[3];
+ m_pos[1] = ((unsigned char *)pSource)[2];
+ m_pos[2] = ((unsigned char *)pSource)[1];
+ m_pos[3] = ((unsigned char *)pSource)[0];
+ }
+ else {
+ m_pos[3] = ((unsigned char *)pSource)[3];
+ m_pos[2] = ((unsigned char *)pSource)[2];
+ m_pos[1] = ((unsigned char *)pSource)[1];
+ m_pos[0] = ((unsigned char *)pSource)[0];
+ }
+ m_pos +=4;
+ }
+
+
+ inline void Marshal::packCompressedSize( sal_Int32 nSize )
+ {
+ ensureAdditionalMem( 5 );
+
+ if( nSize < 0xff )
+ {
+ *((sal_uInt8*)m_pos) = (sal_uInt8) nSize;
+ m_pos ++;
+ }
+ else
+ {
+ *((sal_uInt8*)m_pos) = 0xff;
+ m_pos ++;
+ packInt32( &nSize );
+ }
+ }
+
+
+ inline void Marshal::pack( void *pSource , typelib_TypeDescription *pType )
+ {
+ switch( pType->eTypeClass )
+ {
+ case typelib_TypeClass_BYTE:
+ {
+ packInt8( pSource );
+ break;
+ }
+ case typelib_TypeClass_BOOLEAN:
+ {
+ ensureAdditionalMem( 1 );
+ *m_pos = ( *((sal_Bool*) pSource ) ) ? 1 : 0;
+ m_pos++;
+ break;
+ }
+
+ case typelib_TypeClass_CHAR:
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ {
+ packInt16( pSource );
+ break;
+ }
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ case typelib_TypeClass_FLOAT:
+ {
+ packInt32( pSource );
+ break;
+ }
+ case typelib_TypeClass_DOUBLE:
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ {
+ ensureAdditionalMem( 8 );
+ if( isSystemLittleEndian() )
+ {
+ m_pos[0] = ((unsigned char *)pSource)[7];
+ m_pos[1] = ((unsigned char *)pSource)[6];
+ m_pos[2] = ((unsigned char *)pSource)[5];
+ m_pos[3] = ((unsigned char *)pSource)[4];
+ m_pos[4] = ((unsigned char *)pSource)[3];
+ m_pos[5] = ((unsigned char *)pSource)[2];
+ m_pos[6] = ((unsigned char *)pSource)[1];
+ m_pos[7] = ((unsigned char *)pSource)[0];
+ }
+ else
+ {
+ m_pos[7] = ((unsigned char *)pSource)[7];
+ m_pos[6] = ((unsigned char *)pSource)[6];
+ m_pos[5] = ((unsigned char *)pSource)[5];
+ m_pos[4] = ((unsigned char *)pSource)[4];
+ m_pos[3] = ((unsigned char *)pSource)[3];
+ m_pos[2] = ((unsigned char *)pSource)[2];
+ m_pos[1] = ((unsigned char *)pSource)[1];
+ m_pos[0] = ((unsigned char *)pSource)[0];
+ }
+ m_pos += 8;
+ break;
+ }
+
+ case typelib_TypeClass_STRING:
+ {
+ packString( pSource );
+ break;
+ }
+ case typelib_TypeClass_TYPE:
+ {
+ packType( pSource );
+ break;
+ }
+ case typelib_TypeClass_ANY:
+ {
+ packAny( pSource );
+ break;
+ }
+ case typelib_TypeClass_ENUM:
+ {
+ sal_uInt32 nValue = *(sal_Int32*)pSource;
+ packCompressedSize( nValue );
+ break;
+ }
+ case typelib_TypeClass_TYPEDEF:
+ {
+ OSL_ASSERT( 0 ); // should never occur
+ break;
+ }
+ case typelib_TypeClass_INTERFACE:
+ {
+ remote_Interface *pRemoteI = *( remote_Interface ** )pSource;
+
+ ::rtl::OUString sOid;
+ sal_uInt16 nIndex = 0xffff;
+ if( pRemoteI )
+ {
+ m_callback( pRemoteI , &(sOid.pData) );
+
+ nIndex = m_pBridgeImpl->m_oidCacheOut.seek( sOid );
+ if( 0xffff == nIndex )
+ {
+ nIndex = m_pBridgeImpl->m_oidCacheOut.put( sOid );
+ }
+ else
+ {
+ // cached !
+ sOid = ::rtl::OUString();
+ }
+ }
+ packString( &sOid );
+ packInt16( &nIndex );
+ break;
+ }
+ case typelib_TypeClass_VOID:
+ {
+ // do nothing
+ break;
+ }
+ case typelib_TypeClass_EXCEPTION:
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_SEQUENCE:
+ {
+ packRecursive( pSource, pType );
+ break;
+ }
+ default:
+ OSL_ASSERT( 0 );
+ }
+ }
+}
+
+
+
+#endif
+
diff --git a/bridges/source/remote/urp/urp_marshal_decl.hxx b/bridges/source/remote/urp/urp_marshal_decl.hxx
new file mode 100644
index 000000000000..50007b48ded8
--- /dev/null
+++ b/bridges/source/remote/urp/urp_marshal_decl.hxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_marshal_decl.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * Copyright according the GNU Public License.
+ *
+ ************************************************************************/
+#ifndef _URP_MARSHAL_DECL_HXX_
+#define _URP_MARSHAL_DECL_HXX_
+
+/**************************************************************************
+#*
+#* last change $Author: hr $ $Date: 2000-09-18 15:28:50 $
+#* $Revision: 1.1.1.1 $
+#*
+#* $Logfile: $
+#*
+#* Copyright (c) 2000, Sun Microsystems
+#*
+#************************************************************************/
+#include <rtl/ustring.hxx>
+#include <rtl/byteseq.hxx>
+
+#include <com/sun/star/uno/Type.hxx>
+
+namespace bridges_urp
+{
+ struct urp_BridgeImpl;
+
+ typedef void ( SAL_CALL * urp_extractOidCallback ) (
+ remote_Interface *pRemoteI,
+ rtl_uString **ppOid );
+
+ extern char g_bMarshalSystemIsLittleEndian;
+ class Marshal
+ {
+ public:
+ Marshal( /* cache access */ struct urp_BridgeImpl *,
+ sal_Int32 m_nBufferSize,
+ urp_extractOidCallback callback = 0
+ );
+ ~Marshal( );
+
+ inline void pack( void *pSource , typelib_TypeDescription *pType );
+
+ void packRecursive( void *pSource, typelib_TypeDescription *pType );
+
+ void packTid( const ::rtl::ByteSequence &id );
+ void packOid( const ::rtl::OUString &oid );
+ void packType( void *pSource );
+
+ inline void packCompressedSize( sal_Int32 nSize );
+ inline void packInt8( void *pSource );
+ inline void packInt16( void *pSource );
+ inline void packInt32( void *pSource );
+ inline void packString( void *pSource );
+ inline void packAny( void *pSource );
+ inline void packByteSequence( sal_Int8 *pBuffer , sal_Int32 nSize );
+
+ // can be called during marshaling, but not between
+ // finish and restart
+ // returns true, when nothing has been marshaled
+ inline sal_Bool empty() const;
+
+ // stops marshaling, inserts size in front of the buffer
+ // getStart and getSize can now be called
+ inline void finish();
+
+ // must be called after finish. After calling restart,
+ // a new marshalling session is started invalidating
+ // the previous bufer
+ inline void restart();
+
+ // is only valid, after finish has been called.
+ // valid until destructed.
+ inline sal_Int8 *getBuffer();
+
+ // is only valid, after finish has been called.
+ // valid until destructed.
+ inline sal_Int32 getSize();
+
+ inline sal_Int32 getPos()
+ { return m_pos - m_base; }
+
+ inline sal_Bool isSystemLittleEndian()
+ { return g_bMarshalSystemIsLittleEndian; }
+
+ private:
+ inline void ensureAdditionalMem( sal_Int32 nMemToAdd );
+ sal_Int32 m_nBufferSize;
+ sal_Int8 *m_base;
+
+ sal_Int8 *m_pos;
+ sal_Int32 m_nSizeOffset;
+ struct urp_BridgeImpl *m_pBridgeImpl;
+ urp_extractOidCallback m_callback;
+ };
+}
+#endif
diff --git a/bridges/source/remote/urp/urp_reader.cxx b/bridges/source/remote/urp/urp_reader.cxx
new file mode 100644
index 000000000000..8ff2ffc31632
--- /dev/null
+++ b/bridges/source/remote/urp/urp_reader.cxx
@@ -0,0 +1,578 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_reader.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**************************************************************************
+ * $Log: not supported by cvs2svn $
+ * Revision 1.7 2000/09/15 13:05:58 jbu
+ * extensive performance optimizations
+ *
+ * Revision 1.6 2000/09/14 15:24:00 willem.vandorp
+ * OpenOffice header added.
+ *
+ * Revision 1.5 2000/08/04 15:32:31 willem.vandorp
+ * Header and footer replaced
+ *
+ * Revision 1.4 2000/07/21 16:33:17 jbu
+ * robustness improved
+ *
+ * Revision 1.3 2000/07/14 13:14:42 jbu
+ * dispose mechanism tided up
+ *
+ * Revision 1.2 2000/07/12 10:11:59 jbu
+ * added logging, attribute bug fixed
+ *
+ * Revision 1.1 2000/07/10 11:36:35 jbu
+ * new remote protocol : urp
+ *
+ *************************************************************************/
+#include <string.h>
+
+#include <osl/diagnose.h>
+
+#include <bridges/remote/connection.h>
+#include <bridges/remote/counter.hxx>
+#include <bridges/remote/context.h>
+#include <bridges/remote/helper.hxx>
+
+#include <uno/environment.h>
+
+#include "urp_reader.hxx"
+#include "urp_dispatch.hxx"
+#include "urp_job.hxx"
+#include "urp_bridgeimpl.hxx"
+#include "urp_log.hxx"
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+
+#ifdef DEBUG
+static MyCounter thisCounter( "DEBUG : ReaderThread" );
+#endif
+
+namespace bridges_urp
+{
+
+ inline sal_Bool getMemberTypeDescription(
+ typelib_InterfaceAttributeTypeDescription **ppAttributeType,
+ typelib_InterfaceMethodTypeDescription **ppMethodType,
+ sal_Bool *pbIsSetter,
+ sal_uInt16 nMethodId ,
+ const Type &typeInterface)
+ {
+ if( typeInterface.getTypeClass() != typelib_TypeClass_INTERFACE )
+ {
+ OSL_ENSURE( 0 , "type is not an interface" );
+ return sal_False;
+ }
+
+ typelib_InterfaceTypeDescription *pInterfaceType = 0;
+ TYPELIB_DANGER_GET(
+ (typelib_TypeDescription **)&pInterfaceType , typeInterface.getTypeLibType() );
+ if( ! pInterfaceType )
+ {
+ OString o = OUStringToOString( typeInterface.getTypeName() , RTL_TEXTENCODING_ASCII_US );
+ OSL_ENSURE( !"urp: unknown type " , o.getStr() );
+ return sal_False;
+ }
+
+ if( ! pInterfaceType->aBase.bComplete )
+ {
+ typelib_typedescription_complete( (typelib_TypeDescription **) &pInterfaceType );
+ }
+
+ if( nMethodId < 0 || nMethodId > pInterfaceType->nAllMembers *2 )
+ {
+ // ( m_nMethodId > m_pInterfaceType->nAllMembers *2) is an essential condition
+ // for the vtable index to be correct
+ OSL_ENSURE( 0 , "vtable index out of range" );
+ return sal_False;
+ }
+
+ // TODO : check the range of m_nMethodId
+ sal_Int32 nMemberIndex = pInterfaceType->pMapFunctionIndexToMemberIndex[ nMethodId ];
+
+ if( !( pInterfaceType->nAllMembers > nMemberIndex && nMemberIndex >= 0 ) )
+ {
+ OSL_ENSURE( 0 , "vtable index out of range" );
+ return sal_False;
+ }
+
+ typelib_InterfaceMemberTypeDescription *pMemberType = 0;
+ typelib_typedescriptionreference_getDescription(
+ (typelib_TypeDescription **) &pMemberType,pInterfaceType->ppAllMembers[nMemberIndex]);
+
+ if(! pMemberType )
+ {
+ OSL_ENSURE( 0 , "unknown method type description" );
+ return sal_False;
+ }
+
+ if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pMemberType->aBase.eTypeClass )
+ {
+ *ppAttributeType = (typelib_InterfaceAttributeTypeDescription *) pMemberType;
+ *pbIsSetter = ! (
+ pInterfaceType->pMapMemberIndexToFunctionIndex[nMemberIndex] == nMethodId );
+ }
+ else
+ {
+ *ppMethodType = (typelib_InterfaceMethodTypeDescription *) pMemberType;
+ }
+
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription * )pInterfaceType );
+ return sal_True;
+ }
+
+OReaderThread::OReaderThread( remote_Connection *pConnection,
+ uno_Environment *pEnvRemote,
+ OWriterThread * pWriterThread ) :
+ m_pConnection( pConnection ),
+ m_pEnvRemote( pEnvRemote ),
+ m_pWriterThread( pWriterThread ),
+ m_bDestroyMyself( sal_False ),
+ m_pBridgeImpl((struct urp_BridgeImpl*)
+ ((remote_Context *)pEnvRemote->pContext)->m_pBridgeImpl ),
+ m_unmarshal( m_pBridgeImpl, m_pEnvRemote, ::bridges_remote::remote_createStub )
+{
+ m_pConnection->acquire( m_pConnection );
+#ifdef DEBUG
+ thisCounter.acquire();
+#endif
+}
+
+
+OReaderThread::~OReaderThread( )
+{
+#ifdef DEBUG
+ thisCounter.release();
+#endif
+}
+
+// may only be called in the callstack of this thread !!!!!
+// run() -> dispose() -> destroyYourself()
+void OReaderThread::destroyYourself()
+{
+ m_bDestroyMyself = sal_True;
+ m_pConnection->release( m_pConnection );
+ m_pConnection = 0;
+}
+
+void OReaderThread::onTerminated()
+{
+ if( m_bDestroyMyself )
+ {
+ delete this;
+ }
+}
+
+
+void OReaderThread::disposeEnvironment()
+{
+ struct remote_Context *pContext =
+ ( struct remote_Context * ) m_pEnvRemote->pContext;
+ if( ! pContext->m_pBridgeImpl->m_bDisposed )
+ {
+ // NOTE : This method may only be called by the run-method.
+ // The remote-environment does not dispose, until the reader thread has gone.
+ // So it is completly OK to hold the environment weakly, and only make a
+ // hard reference during dispose call.
+ m_pEnvRemote->acquire( m_pEnvRemote );
+ m_pEnvRemote->dispose( m_pEnvRemote );
+ m_pEnvRemote->release( m_pEnvRemote );
+ }
+}
+
+void OReaderThread::run()
+{
+ sal_Bool bContinue = sal_True;
+ while( bContinue )
+ {
+ sal_Int32 nSize;
+ sal_uInt8 n8Size;
+ if( 1 != m_pConnection->read( m_pConnection , (sal_Int8*) &n8Size, 1) )
+ {
+ disposeEnvironment();
+ break;
+ }
+ if( 255 == n8Size )
+ {
+ sal_uInt8 buf[4];
+ m_pConnection->read( m_pConnection ,(sal_Int8*)buf, 4);
+
+ nSize = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
+ }
+ else
+ {
+ nSize = ( sal_Int32 ) n8Size;
+ }
+
+ if( nSize < 0 )
+ {
+ // buffer too big
+ // no exception can be thrown, because there is no thread id, which could be
+ // used. -> terminate !
+ OSL_ENSURE( 0 , "urp bridge: invalid message size, terminating connection." );
+ disposeEnvironment();
+ break;
+ }
+
+ if( 0 == nSize )
+ {
+ disposeEnvironment();
+ break;
+ }
+
+ // allocate the necessary memory
+ if( ! m_unmarshal.setSize( nSize ) )
+ {
+ OSL_ENSURE( 0 , "urp bridge: messages size too large, terminating connection" );
+ disposeEnvironment();
+ break;
+ }
+
+ sal_Int32 nRead = m_pConnection->read( m_pConnection , m_unmarshal.getBuffer() , nSize );
+
+ if( nSize != nRead )
+ {
+ // couldn't get the asked amount of bytes, quit
+ // should only occur, when the environment has already been disposed
+ OSL_ENSURE( m_pBridgeImpl->m_bDisposed , "urp bridge: couldn't read complete message, terminating connection." );
+
+ disposeEnvironment();
+ break;
+ }
+
+ ServerMultiJob *pMultiJob = 0;
+ remote_Interface *pLastRemoteI = 0;
+ while( ! m_unmarshal.finished() )
+ {
+#ifdef BRIDGES_URP_PROT
+ sal_uInt32 nLogStart = m_unmarshal.getPos();
+ sal_Bool bIsOneWay = sal_False;
+ OUString sMemberName;
+#endif
+ sal_uInt8 nBitField;
+ sal_Bool bSuccess = m_unmarshal.unpackInt8( &nBitField );
+
+ sal_Bool bRequest = sal_True;
+ sal_uInt16 nMethodId = 0;
+ sal_Bool bType = sal_False, bOid = sal_False, bTid = sal_False;
+ sal_Bool bExceptionOccured = sal_False;
+
+ if( HDRFLAG_LONG & nBitField )
+ {
+ // this is a long header, interpret the byte as bitfield
+ // this is a bitfield
+ bTid = ( HDRFLAG_NEWTID & nBitField );
+
+ if( HDRFLAG_REQUEST & nBitField )
+ {
+ bType = ( HDRFLAG_NEWTYPE & nBitField );
+ bOid = ( HDRFLAG_NEWOID & nBitField );
+
+ // request
+ if( HDRFLAG_LONGMETHODID & nBitField )
+ {
+ // methodid as unsigned short
+ bSuccess = bSuccess && m_unmarshal.unpackInt16( &nMethodId );
+ }
+ else
+ {
+ sal_uInt8 id;
+ bSuccess = bSuccess && m_unmarshal.unpackInt8( &id );
+ nMethodId = (sal_uInt16) id;
+ }
+ }
+ else
+ {
+ // reply
+ bRequest = sal_False;
+ bExceptionOccured = ( HDRFLAG_EXCEPTIONOCCURED & nBitField );
+ }
+ }
+ else
+ {
+ // method request + synchronous-asynchronous default
+ if( 0x40 & nBitField )
+ {
+ sal_uInt8 lower;
+ bSuccess = bSuccess && m_unmarshal.unpackInt8( &lower );
+ nMethodId = ( nBitField & 0x3f ) << 8 | lower;
+ }
+ else
+ {
+ nMethodId = ( nBitField & 0x3f );
+ }
+ }
+
+ if( ! bSuccess )
+ {
+ OSL_ENSURE ( 0 , "urp-bridge : incomplete message, skipping block" );
+ break;
+ }
+
+ // get new type,oid,tid
+ if( bType )
+ {
+ if( ! m_unmarshal.unpackAndDestruct(
+ &m_pBridgeImpl->m_lastInType , getCppuType( &m_pBridgeImpl->m_lastInType ) ) )
+ {
+ OSL_ENSURE( 0 , "urp-bridge : error during unpacking cached data, terminating connection" );
+ disposeEnvironment();
+ return;
+ }
+ if( m_pBridgeImpl->m_lastInType.getTypeClass() != typelib_TypeClass_INTERFACE )
+ {
+ OSL_ENSURE( 0 , "urp-bridge : not an interface type" );
+ disposeEnvironment();
+ return;
+ }
+ }
+ if( bOid )
+ {
+ rtl_uString *pOid = 0;
+ if( m_unmarshal.unpackOid( &pOid ) )
+ {
+ m_pBridgeImpl->m_lastInOid = pOid;
+ }
+ else
+ {
+ OSL_ENSURE( 0 , "urp-bridge : error during unpacking cached data, terminating connection" );
+ disposeEnvironment();
+ return;
+ }
+ }
+ if( bTid )
+ {
+ if( ! m_unmarshal.unpackTid( &(m_pBridgeImpl->m_lastInTid) ) )
+ {
+ OSL_ENSURE( 0 , "urp-bridge : error during unpacking cached data, terminating connection" );
+ disposeEnvironment();
+ return;
+ }
+ }
+
+ Job *pJob;
+ // do the job
+ if( bRequest )
+ {
+ // get the membertypedescription
+
+ typelib_InterfaceMethodTypeDescription *pMethodType = 0;
+ typelib_InterfaceAttributeTypeDescription *pAttributeType = 0;
+ sal_Bool bIsSetter = sal_False;
+
+ if( getMemberTypeDescription( &pAttributeType, &pMethodType, &bIsSetter,
+ nMethodId, m_pBridgeImpl->m_lastInType ) )
+ {
+ if( ! pLastRemoteI || bOid || bType )
+ {
+ // a new interface must be retrieved
+
+ // retrieve the interface NOW from the environment
+ // (avoid race conditions : oneway followed by release )
+ typelib_InterfaceTypeDescription *pInterfaceType = 0;
+
+ TYPELIB_DANGER_GET(
+ (typelib_TypeDescription ** ) &pInterfaceType ,
+ m_pBridgeImpl->m_lastInType.getTypeLibType() );
+ if( !pInterfaceType )
+ {
+ delete pMultiJob;
+ disposeEnvironment();
+ bContinue = sal_False;
+ break;
+ }
+ m_pEnvRemote->pExtEnv->getRegisteredInterface(
+ m_pEnvRemote->pExtEnv, ( void ** ) &pLastRemoteI,
+ m_pBridgeImpl->m_lastInOid.pData, pInterfaceType );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription * )pInterfaceType );
+
+ // NOTE : Instance provider is called in the executing thread
+ // Otherwise, instance provider may block the bridge
+ }
+
+ if( pMultiJob && ! bTid && pMethodType && pMethodType->bOneWay && ! pMultiJob->isFull())
+ {
+ // add to the existing multijob, nothing to do here
+ }
+ else
+ {
+ // create a new multijob
+ if( pMultiJob )
+ {
+ // start a previously existing multijob
+ pMultiJob->initiate();
+ }
+
+ pMultiJob = new ServerMultiJob(
+ m_pEnvRemote, m_pBridgeImpl->m_lastInTid.getHandle(),
+ m_pBridgeImpl, &m_unmarshal );
+ }
+
+ pMultiJob->setType( m_pBridgeImpl->m_lastInType );
+ if( pMethodType )
+ pMultiJob->setMethodType( pMethodType , REMOTE_RELEASE_METHOD_INDEX == nMethodId);
+ else if( pAttributeType )
+ pMultiJob->setAttributeType( pAttributeType, bIsSetter );
+
+ if( pLastRemoteI )
+ pMultiJob->setInterface( pLastRemoteI );
+ else
+ pMultiJob->setOid( m_pBridgeImpl->m_lastInOid );
+
+#ifdef BRIDGES_URP_PROT
+ bIsOneWay = pMethodType && pMethodType->bOneWay;
+ sMemberName = pMethodType ?
+ pMethodType->aBase.pMemberName :
+ pAttributeType->aBase.pMemberName;
+#endif
+ }
+ else
+ {
+ delete pMultiJob;
+ disposeEnvironment();
+ bContinue = sal_False;
+ break;
+ }
+ pJob = pMultiJob;
+ }
+ else
+ {
+ if( pMultiJob )
+ {
+ pMultiJob->initiate();
+ pMultiJob = 0;
+ }
+ if( pLastRemoteI )
+ {
+ pLastRemoteI->release( pLastRemoteI );
+ pLastRemoteI = 0;
+ }
+ ClientJob *pClientJob =
+ m_pBridgeImpl->m_clientJobContainer.remove( m_pBridgeImpl->m_lastInTid );
+ OSL_ASSERT( pClientJob );
+ pClientJob->m_bExceptionOccured = bExceptionOccured;
+
+ pJob = pClientJob;
+ pJob->setThreadId( m_pBridgeImpl->m_lastInTid.getHandle() );
+ pJob->setUnmarshal( &m_unmarshal );
+#ifdef BRIDGES_URP_PROT
+ sMemberName = pClientJob->m_pMethodType ?
+ pClientJob->m_pMethodType->aBase.pMemberName :
+ pClientJob->m_pAttributeType->aBase.pMemberName;
+#endif
+ }
+
+#ifdef BRIDGES_URP_PROT
+ sal_uInt32 nLogHeader = m_unmarshal.getPos();
+#endif
+
+ if( ! pJob->extract( ) )
+ {
+ // severe error during extracting, dispose
+ delete pJob;
+ disposeEnvironment();
+ bContinue = sal_False;
+ break;
+ }
+
+#ifdef BRIDGES_URP_PROT
+ {
+ if( bRequest )
+ {
+ urp_logServingRequest(
+ m_pBridgeImpl, m_unmarshal.getPos() - nLogStart,
+ m_unmarshal.getPos() - nLogHeader,
+ !bIsOneWay,
+ sMemberName );
+ }
+ else
+ {
+ urp_logGettingReply(
+ m_pBridgeImpl, m_unmarshal.getPos() - nLogStart,
+ m_unmarshal.getPos() - nLogHeader, sMemberName );
+ }
+ }
+#endif
+ if( ! pMultiJob )
+ {
+ pJob->initiate();
+ }
+ } // end while( !m_unmarshal.finished() )
+
+ if( pLastRemoteI )
+ pLastRemoteI->release( pLastRemoteI );
+
+ if( pMultiJob )
+ {
+ pMultiJob->initiate();
+ }
+
+ m_unmarshal.restart();
+ }
+
+ if( m_pConnection )
+ {
+ m_pConnection->release( m_pConnection );
+ m_pConnection = 0;
+ }
+}
+}
diff --git a/bridges/source/remote/urp/urp_reader.hxx b/bridges/source/remote/urp/urp_reader.hxx
new file mode 100644
index 000000000000..608327447f73
--- /dev/null
+++ b/bridges/source/remote/urp/urp_reader.hxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_reader.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <vos/thread.hxx>
+
+#include "urp_unmarshal.hxx"
+
+struct remote_Connection;
+typedef struct _uno_Environment uno_Environment;
+
+namespace bridges_urp
+{
+
+class OWriterThread;
+
+class OReaderThread :
+ public ::vos::OThread
+{
+public:
+ OReaderThread( remote_Connection *pConnection ,
+ uno_Environment *pEnvRemote,
+ OWriterThread *pWriterThread );
+ ~OReaderThread();
+
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL onTerminated();
+
+ // may only be called in the callstack of this thread !!!!!
+ // run() -> disposeEnvironment() -> dispose() -> destroyYourself()
+ void destroyYourself();
+
+private:
+
+ void disposeEnvironment();
+ void throwUnmarshalException( const ::rtl::OUString &sMessage );
+
+ remote_Connection *m_pConnection;
+ uno_Environment *m_pEnvRemote;
+ OWriterThread *m_pWriterThread;
+ sal_Bool m_bDestroyMyself;
+ urp_BridgeImpl *m_pBridgeImpl;
+ Unmarshal m_unmarshal;
+};
+
+}
diff --git a/bridges/source/remote/urp/urp_replycontainer.hxx b/bridges/source/remote/urp/urp_replycontainer.hxx
new file mode 100644
index 000000000000..62aa88ce72eb
--- /dev/null
+++ b/bridges/source/remote/urp/urp_replycontainer.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_replycontainer.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <hash_map>
+#include <list>
+
+#include <osl/mutex.hxx>
+#include <osl/diagnose.h>
+
+#include "urp_threadid.hxx"
+
+namespace bridges_urp
+{
+
+ class ClientJob;
+ typedef ::std::hash_map< ::rtl::ByteSequence ,
+ ::std::list < ClientJob * > ,
+ HashThreadId ,
+ EqualThreadId > Id2ClientJobStackMap;
+
+ class urp_ClientJobContainer
+ {
+ public:
+ void add( const ::rtl::ByteSequence &id , ClientJob *p )
+ {
+ ::osl::MutexGuard guard( m_mutex );
+ m_map[id].push_back( p );
+ }
+
+ ClientJob *remove( const ::rtl::ByteSequence & id )
+ {
+ ::osl::MutexGuard guard( m_mutex );
+ Id2ClientJobStackMap::iterator ii = m_map.find( id );
+
+ OSL_ASSERT( ii != m_map.end() );
+
+ ClientJob *p = (*ii).second.back();
+ (*ii).second.pop_back();
+ if( (*ii).second.empty() )
+ {
+ m_map.erase( ii );
+ }
+ return p;
+ }
+
+ private:
+ ::osl::Mutex m_mutex;
+ Id2ClientJobStackMap m_map;
+ };
+
+
+
+}
diff --git a/bridges/source/remote/urp/urp_threadid.hxx b/bridges/source/remote/urp/urp_threadid.hxx
new file mode 100644
index 000000000000..9f149aedf618
--- /dev/null
+++ b/bridges/source/remote/urp/urp_threadid.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_threadid.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _URP_THREADID_HXX_
+#define _URP_THREADID_HXX_
+
+#include <sal/types.h>
+#include <rtl/byteseq.hxx>
+
+namespace bridges_urp
+{
+
+ struct EqualThreadId
+ {
+ sal_Int32 operator () ( const ::rtl::ByteSequence &a , const ::rtl::ByteSequence &b ) const
+ {
+ return a == b;
+ }
+ };
+
+ struct HashThreadId
+ {
+ sal_Int32 operator () ( const ::rtl::ByteSequence &a ) const
+ {
+ if( a.getLength() >= 4 )
+ {
+ return *(sal_Int32*) a.getConstArray();
+ }
+ return 0;
+ }
+ };
+}
+#endif
diff --git a/bridges/source/remote/urp/urp_unmarshal.cxx b/bridges/source/remote/urp/urp_unmarshal.cxx
new file mode 100644
index 000000000000..d5c2c95e12a6
--- /dev/null
+++ b/bridges/source/remote/urp/urp_unmarshal.cxx
@@ -0,0 +1,529 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_unmarshal.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <string.h>
+
+#include <osl/diagnose.h>
+
+#include <rtl/alloc.h>
+
+#include <uno/data.h>
+#include <uno/any2.h>
+#include <uno/sequence2.h>
+
+#include <com/sun/star/uno/Any.hxx>
+
+#include "urp_unmarshal.hxx"
+#include "urp_bridgeimpl.hxx"
+
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+
+namespace bridges_urp
+{
+static int g_nDetectLittleEndian = 1;
+char g_bSystemIsLittleEndian = ((char*)&g_nDetectLittleEndian)[0];
+
+
+Unmarshal::Unmarshal( struct urp_BridgeImpl *pBridgeImpl,
+ uno_Environment *pEnvRemote,
+ remote_createStubFunc callback ) :
+ m_pBridgeImpl( pBridgeImpl ),
+ m_pEnvRemote( pEnvRemote ),
+ m_callback( callback ),
+ m_nBufferSize( 4096 ),
+ m_base( (sal_Int8*) rtl_allocateMemory( m_nBufferSize ) ),
+ m_pos( m_base ),
+ m_nLength( 0 )
+{
+}
+
+Unmarshal::~Unmarshal()
+{
+ rtl_freeMemory( m_base );
+}
+
+sal_Bool Unmarshal::setSize( sal_Int32 nSize )
+{
+ if( nSize > m_nBufferSize )
+ {
+ m_nBufferSize = nSize;
+ m_base = (sal_Int8 * ) rtl_reallocateMemory( (sal_uInt8*) m_base , m_nBufferSize );
+ m_pos = m_base;
+ }
+ m_nLength = nSize;
+ return ( 0 != m_base );
+}
+
+
+// sal_Bool Unmarshal::unpack( void *pDest, const ::com::sun::star::uno::Type &rType)
+// {
+// typelib_TypeDescription * pDataTD = 0;
+// TYPELIB_DANGER_GET( &pDataTD, rType.getTypeLibType() );
+// sal_Bool b = unpack( pDest, pDataTD );
+// TYPELIB_DANGER_RELEASE( pDataTD );
+// return b;
+// }
+
+sal_Bool Unmarshal::unpackAndDestruct( void *pDest, const ::com::sun::star::uno::Type &rType)
+{
+ typelib_TypeDescription * pDataTD = 0;
+ TYPELIB_DANGER_GET( &pDataTD, rType.getTypeLibType() );
+ uno_destructData( pDest , pDataTD , 0 );
+ sal_Bool b = unpack( pDest, pDataTD );
+ TYPELIB_DANGER_RELEASE( pDataTD );
+ return b;
+}
+
+sal_Bool Unmarshal::unpackAndDestruct( void *pDest, typelib_TypeDescription *pType)
+{
+ uno_destructData( pDest , pType , 0 );
+ return unpack( pDest, pType );
+}
+
+
+
+// special unpacks
+sal_Bool Unmarshal::unpackTid( ::rtl::ByteSequence *pId )
+{
+ sal_Int32 nSize;
+ sal_Bool bReturn = unpackCompressedSize( &nSize );
+ if( bReturn )
+ {
+ if( nSize )
+ {
+ *pId = ByteSequence( m_pos , nSize );
+ m_pos += nSize;
+ sal_uInt16 nIndex;
+ bReturn = unpackInt16( &nIndex );
+ if( nIndex < m_pBridgeImpl->m_nCacheSize )
+ {
+ m_pBridgeImpl->m_pTidIn[nIndex] = *pId;
+ }
+ else if( 0xffff != nIndex )
+ {
+ bReturn = sal_False;
+ *pId = ByteSequence();
+ OSL_ENSURE( 0 , "unknown thread id" );
+ }
+ }
+ else
+ {
+ sal_uInt16 nIndex;
+ bReturn = unpackInt16( &nIndex );
+ if( nIndex < m_pBridgeImpl->m_nCacheSize )
+ {
+ *pId = m_pBridgeImpl->m_pTidIn[nIndex];
+ }
+ else
+ {
+ bReturn = sal_False;
+ *pId = ByteSequence();
+ OSL_ENSURE( 0 , "unknown thread id" );
+ }
+ }
+ }
+ return bReturn;
+}
+
+sal_Bool Unmarshal::unpackOid( rtl_uString **ppOid )
+{
+ sal_Bool bReturn = sal_True;
+ sal_uInt16 nCacheIndex;
+
+ bReturn = bReturn && unpackString( ppOid );
+ bReturn = bReturn && unpackInt16( &nCacheIndex );
+
+ if( bReturn &&
+ ! ( 0xffff == nCacheIndex && 0 == (*ppOid)->length ) /* null reference */ )
+ {
+ if( (*ppOid)->length )
+ {
+ // new unknown reference
+ if( 0xffff != nCacheIndex )
+ {
+ // oid should be cached ?
+ if( nCacheIndex < m_pBridgeImpl->m_nCacheSize )
+ {
+ m_pBridgeImpl->m_pOidIn[nCacheIndex] = *ppOid;
+ }
+ else
+ {
+ bReturn = sal_False;
+ }
+ }
+ }
+ else
+ {
+ // reference in cache !
+ if( nCacheIndex < m_pBridgeImpl->m_nCacheSize )
+ {
+ rtl_uString_assign( ppOid , m_pBridgeImpl->m_pOidIn[nCacheIndex].pData );
+ }
+ else
+ {
+ bReturn = sal_False;
+ }
+ }
+ }
+
+ return bReturn;
+}
+
+template < class t >
+inline sal_Int32 convertFromPackedInt( t* pTarget , const sal_uInt8 *pSource , sal_Int32 nMaxToGo )
+{
+ *pTarget = 0;
+ sal_Int32 i = 0;
+ do
+ {
+ *pTarget |= ( ( sal_Int64) (pSource[i] & 0x7f) ) << ( i * 7 );
+ i ++;
+ } while ( i < nMaxToGo && (pSource[i-1] & 0x80) );
+
+ return i;
+}
+
+
+sal_Bool Unmarshal::unpackType( void *pDest )
+{
+ *(typelib_TypeDescriptionReference **) pDest = 0;
+
+ sal_uInt8 nTypeClass;
+ sal_Bool bReturn = unpackInt8( &nTypeClass );
+
+ Type type;
+ if( bReturn )
+ {
+ if( nTypeClass <= 14 /* any */ )
+ {
+ switch( nTypeClass )
+ {
+ case typelib_TypeClass_VOID:
+ {
+ type = getVoidCppuType( );
+ break;
+ }
+ case typelib_TypeClass_CHAR:
+ {
+ type = getCharCppuType( );
+ break;
+ }
+ case typelib_TypeClass_BOOLEAN:
+ {
+ type = getBooleanCppuType();
+ break;
+ }
+ case typelib_TypeClass_BYTE:
+ {
+ type = getCppuType( (sal_Int8 *) 0);
+ break;
+ }
+ case typelib_TypeClass_SHORT:
+ {
+ type = getCppuType( ( sal_Int16 *)0 );
+ break;
+ }
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ {
+ type = getCppuType( (sal_uInt16 *)0 );
+ break;
+ }
+ case typelib_TypeClass_LONG:
+ {
+ type = getCppuType( ( sal_Int32 *) 0 );
+ break;
+ }
+ case typelib_TypeClass_UNSIGNED_LONG:
+ {
+ type = getCppuType( ( sal_uInt32 *) 0 );
+ break;
+ }
+ case typelib_TypeClass_HYPER:
+ {
+ type = getCppuType( ( sal_Int64 *) 0 );
+ break;
+ }
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ {
+ type = getCppuType( ( sal_uInt64 *) 0 );
+ break;
+ }
+ case typelib_TypeClass_FLOAT:
+ {
+ type = getCppuType( ( float *) 0 );
+ break;
+ }
+ case typelib_TypeClass_DOUBLE:
+ {
+ type = getCppuType( (double*) 0 );
+ break;
+ }
+ case typelib_TypeClass_STRING:
+ {
+ type = getCppuType( (OUString *) 0 );
+ break;
+ }
+ case typelib_TypeClass_TYPE:
+ {
+ type = getCppuType( (Type *) 0 );
+ break;
+ }
+ case typelib_TypeClass_ANY:
+ {
+ type = getCppuType( (Any *) 0 );
+ break;
+ }
+ }
+ }
+ else
+ {
+ sal_uInt16 nCacheIndex;
+ bReturn = bReturn && unpackInt16( &nCacheIndex );
+
+ if( bReturn )
+ {
+ if( nTypeClass & 0x80 )
+ {
+ // new type
+ rtl_uString *pString = 0;
+ bReturn = bReturn && unpackString( &pString );
+ if( bReturn )
+ {
+ type = Type( (enum TypeClass )(nTypeClass & 0x7f) , pString );
+ if( nCacheIndex != 0xffff )
+ {
+ if( nCacheIndex < m_pBridgeImpl->m_nCacheSize )
+ {
+ m_pBridgeImpl->m_pTypeIn[nCacheIndex] = type;
+ }
+ else
+ {
+ bReturn = sal_False;
+ }
+ }
+ }
+ if( pString )
+ {
+ rtl_uString_release( pString );
+ }
+ }
+ else
+ {
+ if( nCacheIndex < m_pBridgeImpl->m_nCacheSize )
+ {
+ type = m_pBridgeImpl->m_pTypeIn[nCacheIndex];
+ }
+ else
+ {
+ bReturn = sal_False;
+ }
+ }
+ }
+ }
+ }
+ *(typelib_TypeDescriptionReference**)pDest = type.getTypeLibType();
+ typelib_typedescriptionreference_acquire( *(typelib_TypeDescriptionReference**)pDest );
+ return bReturn;
+}
+
+sal_Bool Unmarshal::unpackAny( void *pDest )
+{
+ uno_Any *pAny = ( uno_Any * )pDest;
+
+ pAny->pType = 0;
+ // Type is acquired with typelib_typedescription_acquire
+
+ sal_Bool bReturn = unpackType( &(pAny->pType) );
+
+ typelib_TypeDescription *pType = 0;
+ if( bReturn && pAny->pType )
+ {
+ typelib_typedescriptionreference_getDescription( &pType , pAny->pType );
+
+ if( pType )
+ {
+ pAny->pData = rtl_allocateMemory( pType->nSize );
+ bReturn = unpack( pAny->pData , pType );
+ }
+ }
+
+ if( pType )
+ {
+ typelib_typedescription_release( pType );
+ }
+ else
+ {
+ pAny->pData = 0;
+ Type type; // void
+ pAny->pType = type.getTypeLibType();
+ typelib_typedescriptionreference_acquire( pAny->pType );
+
+ bReturn = sal_False;
+ }
+ return bReturn;
+}
+
+
+sal_Bool Unmarshal::unpackRecursive( void *pDest , typelib_TypeDescription *pType )
+{
+ sal_Bool bReturn = sal_True;
+
+ switch( pType->eTypeClass )
+ {
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_CompoundTypeDescription * pCompType =
+ (typelib_CompoundTypeDescription *)pType;
+
+ if (pCompType->pBaseTypeDescription)
+ {
+ bReturn =
+ unpack( pDest , (typelib_TypeDescription * ) pCompType->pBaseTypeDescription );
+ }
+
+ // then construct members
+ typelib_TypeDescriptionReference ** ppTypeRefs = pCompType->ppTypeRefs;
+ sal_Int32 * pMemberOffsets = pCompType->pMemberOffsets;
+ sal_Int32 nDescr = pCompType->nMembers;
+
+ // at least assume 1 byte per member
+ bReturn = bReturn && ! checkOverflow( nDescr * 1 );
+ for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos )
+ {
+ typelib_TypeDescription * pMemberType = 0;
+ TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] );
+ // Even if bReturn is false, all values must be default constructed !
+ if( bReturn )
+ {
+ bReturn = unpack( (char*)pDest + pMemberOffsets[nPos] , pMemberType ) && bReturn;
+ }
+ else
+ {
+ uno_constructData( (char*)pDest + pMemberOffsets[nPos] , pMemberType );
+ }
+ TYPELIB_DANGER_RELEASE( pMemberType );
+ }
+ break;
+ }
+ case typelib_TypeClass_SEQUENCE:
+ {
+ sal_Int32 nLen;
+ bReturn = unpackCompressedSize( &nLen );
+
+ // urp protocol does not allow to use the elementsize as a guess, if enough data
+ // is available. However, at least one byte per member must be within the message
+ bReturn = bReturn && ! checkOverflow( 1 * nLen );
+ uno_Sequence *pSequence = 0;
+ if( nLen && bReturn )
+ {
+ typelib_TypeDescriptionReference * pETRef =
+ ((typelib_IndirectTypeDescription *)pType)->pType;
+
+ typelib_TypeDescription * pET = 0;
+ typelib_typedescriptionreference_getDescription( &pET , pETRef );
+
+ if( pET )
+ {
+ sal_Int32 nElementSize = pET->nSize;
+
+ pSequence = (uno_Sequence *)rtl_allocateMemory(
+ SAL_SEQUENCE_HEADER_SIZE + nElementSize * nLen );
+ pSequence->nRefCount = 1;
+ pSequence->nElements = nLen;
+
+ if( typelib_TypeClass_BYTE == pET->eTypeClass )
+ {
+ memcpy( pSequence->elements , m_pos , nLen );
+ m_pos += nLen;
+ }
+ else
+ {
+ for( sal_Int32 i = 0 ; i < nLen ; i ++ )
+ {
+ bReturn = unpack( ((char*)pSequence->elements)+ i*nElementSize,pET ) && bReturn;
+ }
+ }
+ typelib_typedescription_release( pET );
+ }
+ else
+ {
+ bReturn = sal_False;
+ uno_constructData( &pSequence , pType );
+ }
+ }
+ else
+ {
+ uno_constructData( &pSequence , pType );
+ }
+
+ *((uno_Sequence **)pDest) = pSequence;
+ break;
+ }
+ default:
+ OSL_ASSERT( 0 );
+ }
+ return bReturn;
+}
+
+}
+
diff --git a/bridges/source/remote/urp/urp_unmarshal.hxx b/bridges/source/remote/urp/urp_unmarshal.hxx
new file mode 100644
index 000000000000..b0242814a241
--- /dev/null
+++ b/bridges/source/remote/urp/urp_unmarshal.hxx
@@ -0,0 +1,392 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_unmarshal.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _URP_UNMARSHAL_HXX_
+#define _URP_UNMARSHAL_HXX_
+
+#include <rtl/byteseq.hxx>
+
+#include <bridges/remote/context.h>
+
+#include <com/sun/star/uno/Type.hxx>
+
+typedef struct _uno_Environment uno_Environment;
+struct remote_Interface;
+
+namespace bridges_urp
+{
+
+ extern char g_bSystemIsLittleEndian;
+class ThreadId;
+struct urp_BridgeImpl;
+class Unmarshal
+{
+public:
+ Unmarshal(
+ struct urp_BridgeImpl *,
+ uno_Environment *pEnvRemote,
+ remote_createStubFunc callback );
+ ~Unmarshal();
+
+ sal_Bool unpackAndDestruct( void *pDest , const ::com::sun::star::uno::Type &rType );
+ sal_Bool unpackAndDestruct( void *pDest , typelib_TypeDescription *pType );
+ sal_Bool unpackRecursive( void *pDest , typelib_TypeDescription *pType );
+ sal_Bool finished()
+ { return m_base + m_nLength == m_pos; }
+ sal_uInt32 getPos()
+ { return (sal_uInt32 ) (m_pos - m_base); }
+
+ sal_Bool setSize( sal_Int32 nSize );
+
+ inline sal_Bool unpackCompressedSize( sal_Int32 *pData );
+ inline sal_Bool unpack( void *pDest, typelib_TypeDescription *pType );
+ inline sal_Bool unpackInt8( void *pDest );
+ inline sal_Bool unpackString( void *pDest );
+ inline sal_Bool unpackInt16( void *pDest );
+ inline sal_Bool unpackInt32( void *pDest );
+ sal_Bool unpackType( void *pDest );
+
+ sal_Bool unpackAny( void *pDest );
+ sal_Bool unpackOid( rtl_uString **ppOid );
+ sal_Bool unpackTid( ::rtl::ByteSequence *pId );
+
+ void restart()
+ { m_pos = m_base; }
+
+ sal_Int8 *getBuffer()
+ { return m_base; }
+ inline sal_Bool isSystemLittleEndian()
+ { return g_bSystemIsLittleEndian; }
+
+private:
+ inline sal_Bool checkOverflow( sal_Int32 nNextMem );
+
+ sal_Int32 m_nBufferSize;
+ sal_Int8 *m_base;
+ sal_Int8 *m_pos;
+
+ sal_Int32 m_nLength;
+
+ remote_createStubFunc m_callback;
+ uno_Environment *m_pEnvRemote;
+ urp_BridgeImpl *m_pBridgeImpl;
+};
+
+inline sal_Bool Unmarshal::checkOverflow( sal_Int32 nNextMem )
+{
+ return nNextMem < 0 ||
+ (((sal_uInt32)( m_pos - m_base )) + nNextMem ) > m_nLength;
+}
+
+
+inline sal_Bool Unmarshal::unpackInt8( void *pDest )
+{
+ sal_Bool bReturn = ! checkOverflow( 1 );
+ if( bReturn )
+ {
+ *((sal_Int8*)pDest ) = *m_pos;
+ m_pos++;
+ }
+ else
+ {
+ *((sal_Int8*)pDest ) = 0;
+ }
+ return bReturn;
+}
+
+inline sal_Bool Unmarshal::unpackInt32( void *pDest )
+{
+ sal_uInt32 *p = ( sal_uInt32 * ) pDest;
+ sal_Bool bReturn = ! checkOverflow(4);
+ if( bReturn )
+ {
+ if( isSystemLittleEndian() )
+ {
+ ((sal_Int8*) p )[3] = m_pos[0];
+ ((sal_Int8*) p )[2] = m_pos[1];
+ ((sal_Int8*) p )[1] = m_pos[2];
+ ((sal_Int8*) p )[0] = m_pos[3];
+ }
+ else
+ {
+ ((sal_Int8*) p )[3] = m_pos[3];
+ ((sal_Int8*) p )[2] = m_pos[2];
+ ((sal_Int8*) p )[1] = m_pos[1];
+ ((sal_Int8*) p )[0] = m_pos[0];
+ }
+ m_pos += 4;
+ }
+ else
+ {
+ *p = 0;
+ }
+ return bReturn;
+}
+
+inline sal_Bool Unmarshal::unpackInt16( void *pDest )
+{
+ sal_uInt16 *p = ( sal_uInt16 * ) pDest;
+
+ sal_Bool bReturn = ! checkOverflow( 2 );
+ if( bReturn )
+ {
+ if( isSystemLittleEndian() )
+ {
+ ((sal_Int8*) p )[1] = m_pos[0];
+ ((sal_Int8*) p )[0] = m_pos[1];
+ }
+ else
+ {
+ ((sal_Int8*) p )[1] = m_pos[1];
+ ((sal_Int8*) p )[0] = m_pos[0];
+ }
+ m_pos ++;
+ m_pos ++;
+ }
+ else
+ {
+ *p = 0;
+ }
+ return bReturn;
+}
+
+inline sal_Bool Unmarshal::unpackString( void *pDest )
+{
+ sal_Int32 nLength;
+ sal_Bool bReturn = unpackCompressedSize( &nLength );
+
+ bReturn = bReturn && ! checkOverflow( nLength );
+ if( bReturn )
+ {
+ *(rtl_uString **) pDest = 0;
+ rtl_string2UString( (rtl_uString**) pDest, (const sal_Char * )m_pos , nLength,
+ RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS );
+ m_pos += nLength;
+ }
+ else
+ {
+ *(rtl_uString ** ) pDest = 0;
+ rtl_uString_new( (rtl_uString **) pDest );
+ }
+ return bReturn;
+}
+
+
+sal_Bool Unmarshal::unpackCompressedSize( sal_Int32 *pData )
+{
+ sal_uInt8 n8Size;
+ sal_Bool bReturn = unpackInt8( &n8Size );
+ if( bReturn )
+ {
+ if( n8Size == 0xff )
+ {
+ unpackInt32( pData );
+ }
+ else
+ {
+ *pData = (sal_Int32 ) n8Size;
+ }
+ }
+ return bReturn;
+}
+
+inline sal_Bool Unmarshal::unpack( void *pDest , typelib_TypeDescription *pType )
+{
+ sal_Bool bReturn = sal_True;
+ switch( pType->eTypeClass )
+ {
+ case typelib_TypeClass_VOID:
+ // do nothing
+ break;
+ case typelib_TypeClass_BYTE:
+ {
+ bReturn = unpackInt8( pDest );
+ break;
+ }
+ case typelib_TypeClass_BOOLEAN:
+ {
+ bReturn = ! checkOverflow( 1 );
+ if( bReturn )
+ {
+ *((sal_Bool*)pDest) = (sal_Bool ) ( *m_pos);
+ m_pos ++;
+ }
+ else
+ {
+ *((sal_Bool*)pDest) = 0;
+ }
+ break;
+ }
+
+ case typelib_TypeClass_CHAR:
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ {
+ unpackInt16( pDest );
+ break;
+ }
+ case typelib_TypeClass_FLOAT:
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ {
+ bReturn = unpackInt32( pDest );
+ break;
+ }
+ case typelib_TypeClass_DOUBLE:
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ {
+ sal_uInt64 *p = ( sal_uInt64 * ) pDest;
+ *p = 0;
+ bReturn = ! checkOverflow( 8 );
+ if( bReturn )
+ {
+ if( isSystemLittleEndian() )
+ {
+ ((sal_Int8*) p )[7] = m_pos[0];
+ ((sal_Int8*) p )[6] = m_pos[1];
+ ((sal_Int8*) p )[5] = m_pos[2];
+ ((sal_Int8*) p )[4] = m_pos[3];
+ ((sal_Int8*) p )[3] = m_pos[4];
+ ((sal_Int8*) p )[2] = m_pos[5];
+ ((sal_Int8*) p )[1] = m_pos[6];
+ ((sal_Int8*) p )[0] = m_pos[7];
+ }
+ else
+ {
+ ((sal_Int8*) p )[0] = m_pos[0];
+ ((sal_Int8*) p )[1] = m_pos[1];
+ ((sal_Int8*) p )[2] = m_pos[2];
+ ((sal_Int8*) p )[3] = m_pos[3];
+ ((sal_Int8*) p )[4] = m_pos[4];
+ ((sal_Int8*) p )[5] = m_pos[5];
+ ((sal_Int8*) p )[6] = m_pos[6];
+ ((sal_Int8*) p )[7] = m_pos[7];
+ }
+ m_pos += 8;
+ }
+ break;
+ }
+ case typelib_TypeClass_STRING:
+ {
+ unpackString( pDest );
+ break;
+ }
+ case typelib_TypeClass_ANY:
+ {
+ bReturn = unpackAny( pDest );
+ break;
+ }
+ case typelib_TypeClass_ENUM:
+ {
+ bReturn = unpackCompressedSize( (sal_Int32 *) pDest );
+ break;
+ }
+ case typelib_TypeClass_INTERFACE:
+ {
+ *(remote_Interface**)pDest = 0;
+
+ rtl_uString *pString = 0;
+ bReturn = unpackOid( &pString ) && bReturn;
+
+ if( bReturn && pString && pString->length )
+ {
+ m_callback( (remote_Interface**) pDest ,
+ pString,
+ pType->pWeakRef ,
+ m_pEnvRemote );
+ }
+ if( pString )
+ {
+ rtl_uString_release( pString );
+ }
+ break;
+ }
+ case typelib_TypeClass_TYPE:
+ {
+ bReturn = unpackType( pDest );
+ break;
+ }
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ case typelib_TypeClass_SEQUENCE:
+ {
+ bReturn = unpackRecursive( pDest, pType );
+ break;
+ }
+
+ case typelib_TypeClass_UNION:
+ case typelib_TypeClass_ARRAY:
+ case typelib_TypeClass_SERVICE:
+ case typelib_TypeClass_MODULE:
+ case typelib_TypeClass_INTERFACE_METHOD:
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ case typelib_TypeClass_UNKNOWN:
+ default:
+ OSL_ASSERT( 0 );
+ }
+
+
+ return bReturn;
+}
+
+}
+
+#endif
diff --git a/bridges/source/remote/urp/urp_writer.cxx b/bridges/source/remote/urp/urp_writer.cxx
new file mode 100644
index 000000000000..247083b66912
--- /dev/null
+++ b/bridges/source/remote/urp/urp_writer.cxx
@@ -0,0 +1,201 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_writer.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <assert.h>
+#include <stdio.h>
+
+#include <vos/thread.hxx>
+
+#include <osl/mutex.hxx>
+#include <osl/conditn.h>
+
+#include <bridges/remote/connection.h>
+#include <bridges/remote/remote.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <bridges/remote/counter.hxx>
+
+#include "urp_writer.hxx"
+#include "urp_bridgeimpl.hxx"
+#include "urp_marshal.hxx"
+
+#ifdef DEBUG
+static MyCounter thisCounter( "DEBUG : WriterThread" );
+#endif
+
+using namespace ::osl;
+
+namespace bridges_urp {
+
+OWriterThread::OWriterThread( remote_Connection *pConnection, urp_BridgeImpl *pBridgeImpl) :
+ m_pConnection( pConnection ),
+ m_bAbort( sal_False ),
+ m_pBridgeImpl( pBridgeImpl )
+{
+ m_oslCondition = osl_createCondition();
+ osl_resetCondition( m_oslCondition );
+ m_pConnection->acquire( m_pConnection );
+
+#ifdef DEBUG
+ thisCounter.acquire();
+#endif
+}
+
+OWriterThread::~OWriterThread()
+{
+ osl_destroyCondition( m_oslCondition );
+ m_pConnection->release( m_pConnection );
+#ifdef DEBUG
+ thisCounter.release();
+#endif
+}
+
+
+// touch is called with locked m_marshalingMutex
+void OWriterThread::touch( sal_Bool bImmediately )
+{
+ if( bImmediately || m_pBridgeImpl->m_blockMarshaler.getPos() > m_pBridgeImpl->m_nFlushBlockSize )
+ {
+ write();
+ }
+}
+
+
+void OWriterThread::abort()
+{
+ m_bAbort = sal_True;
+ osl_setCondition( m_oslCondition );
+ join();
+}
+
+
+// must be called with locked marshaling mutex
+void OWriterThread::write()
+{
+ if( ! m_pBridgeImpl->m_blockMarshaler.empty() )
+ {
+ m_pBridgeImpl->m_blockMarshaler.finish();
+
+ sal_Int32 nLength = m_pBridgeImpl->m_blockMarshaler.getSize();
+ sal_Int8 *pBuf = m_pBridgeImpl->m_blockMarshaler.getBuffer();
+
+ if( nLength != m_pConnection->write( m_pConnection, pBuf, nLength ))
+ {
+ m_pBridgeImpl->m_blockMarshaler.restart();
+ return;
+ }
+ m_pConnection->flush( m_pConnection );
+ m_pBridgeImpl->m_blockMarshaler.restart();
+ }
+}
+
+void OWriterThread::sendEmptyMessage()
+{
+ // must be called with locked marshaling mutex
+ sal_Int8 n = 0;
+ if( m_pConnection )
+ {
+ m_pConnection->write( m_pConnection , &n , 1 );
+ }
+}
+
+void OWriterThread::run()
+{
+ while( sal_True )
+ {
+ // Wait for some work to do
+// osl_waitCondition( m_oslCondition , 0 );
+// if( m_bAbort )
+// {
+// break;
+// }
+
+// if( m_bWaitForTimeout )
+// {
+ // wait for timeout
+// printf( "Waiting for timeout ....\n" );
+ TimeValue value = { 0 , 1000 * m_pBridgeImpl->m_nTimeoutMUSEC };
+ osl_resetCondition( m_oslCondition );
+ osl_waitCondition( m_oslCondition , &value );
+// }
+
+ {
+ // write to the socket
+ MutexGuard guard( m_pBridgeImpl->m_marshalingMutex );
+ m_bWaitForTimeout = sal_False;
+ if( ! m_pBridgeImpl->m_blockMarshaler.empty() )
+ {
+// printf( "Sending with timeout\n" );
+ write();
+ }
+ osl_resetCondition( m_oslCondition );
+ }
+ if( m_bAbort )
+ {
+ break;
+ }
+
+ }
+}
+
+
+}
+
diff --git a/bridges/source/remote/urp/urp_writer.hxx b/bridges/source/remote/urp/urp_writer.hxx
new file mode 100644
index 000000000000..1916a67554eb
--- /dev/null
+++ b/bridges/source/remote/urp/urp_writer.hxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp_writer.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <osl/conditn.h>
+#include <vos/thread.hxx>
+
+struct remote_Connection;
+
+namespace bridges_urp
+{
+
+ struct urp_BridgeImpl;
+ class OWriterThread :
+ public ::vos::OThread
+ {
+ public:
+ OWriterThread( remote_Connection *pConnection,
+ urp_BridgeImpl *m_pBridgeImpl);
+ ~OWriterThread( );
+
+ virtual void SAL_CALL run();
+
+ void touch( sal_Bool bImmediately );
+ void sendEmptyMessage();
+
+ void abort();
+
+ private:
+ void write();
+ oslCondition m_oslCondition;
+
+ sal_Bool m_bAbort;
+ sal_Bool m_bWaitForTimeout;
+ remote_Connection *m_pConnection;
+ urp_BridgeImpl *m_pBridgeImpl;
+ };
+
+
+}
+
diff --git a/bridges/test/makefile.mk b/bridges/test/makefile.mk
new file mode 100644
index 000000000000..6773ce71c746
--- /dev/null
+++ b/bridges/test/makefile.mk
@@ -0,0 +1,279 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=bridges
+TARGET=test
+LIBTARGET=NO
+TARGETTYPE=CUI
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+ALLIDLFILES = test_bridge.idl
+#CPPUMAKERFLAGS += -C
+
+
+UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb $(BIN)$/test.rdb
+
+# output directory (one dir for each project)
+UNOUCROUT=$(OUT)$/inc
+
+# adding to inludeoath
+INCPRE+=$(UNOUCROUT)
+CFLAGS += -I..$/source$/remote$/urp
+
+UNOTYPES = \
+ com.sun.star.uno.XWeak\
+ com.sun.star.uno.XNamingService\
+ com.sun.star.uno.XAggregation \
+ com.sun.star.uno.TypeClass\
+ com.sun.star.io.XInputStream\
+ com.sun.star.io.XOutputStream\
+ com.sun.star.lang.XInitialization \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.lang.XTypeProvider \
+ com.sun.star.frame.XComponentLoader\
+ com.sun.star.registry.XSimpleRegistry \
+ com.sun.star.loader.XImplementationLoader \
+ com.sun.star.registry.XImplementationRegistration \
+ com.sun.star.corba.giop.TargetAddress \
+ com.sun.star.corba.giop.TargetAddressGroup \
+ com.sun.star.lang.XComponent \
+ com.sun.star.bridge.XBridgeFactory\
+ com.sun.star.connection.XAcceptor\
+ com.sun.star.connection.XConnector\
+ com.sun.star.beans.Property\
+ com.sun.star.corba.giop.RequestHeader_1_2\
+ com.sun.star.container.XSet\
+ com.sun.star.text.XTextDocument\
+ com.sun.star.lang.XServiceInfo\
+ test.XTestFactory \
+ com.sun.star.test.performance.XPerformanceTest \
+ com.sun.star.lang.XMain
+
+#UNOTYPES= com.sun.star.corba.giop.MsgType_1_1
+#UNOTYPES= com.sun.star.uno.XInterface \
+# com.sun.star.uno.TypeClass \
+# com.sun.star.corba.CorbaString8
+#com.sun.star.corba.giop.RequestHeader_1_1
+
+JARFILES = jurt.jar sandbox.jar unoil.jar
+
+
+
+# GENJAVACLASSFILES = \
+# $(CLASSDIR)$/test$/TestTypes.class \
+# $(CLASSDIR)$/test$/TestBridgeException.class \
+# $(CLASSDIR)$/test$/XCallMe.class \
+# $(CLASSDIR)$/test$/XInterfaceTest.class \
+# $(CLASSDIR)$/test$/XTestFactory.class \
+
+
+# JAVACLASSFILES= \
+# $(CLASSDIR)$/testclient.class
+
+
+
+# TYPES={$(subst,.class, $(subst,$/,. $(subst,$(CLASSDIR)$/,-T $(GENJAVACLASSFILES))))}
+# GENJAVAFILES = {$(subst,.class,.java $(subst,$/class, $(GENJAVACLASSFILES)))}
+# JAVAFILES= $(subst,$(CLASSDIR)$/, $(subst,.class,.java $(JAVACLASSFILES))) $(GENJAVAFILES)
+
+
+OBJFILES= \
+ $(OBJ)$/testserver.obj \
+ $(OBJ)$/testclient.obj \
+ $(OBJ)$/testcomp.obj \
+ $(OBJ)$/testsameprocess.obj \
+ $(OBJ)$/testoffice.obj
+
+
+# APP1TARGET= testmarshal
+# APP1OBJS= $(OBJ)$/testmarshal.obj \
+# $(SLO)$/urp_marshal.obj\
+# $(SLO)$/urp_unmarshal.obj \
+# $(SLO)$/urp_bridgeimpl.obj \
+# $(SLB)$/bridges_remote_static.lib
+
+# # $(SLO)$/marshal.obj\
+# # $(SLO)$/unmarshal.obj\
+
+# .IF "$(OS)" == "LINUX"
+# APP1STDLIBS+= -lstdc++
+# .ENDIF
+
+#APP1LIBS+= \
+# $(SLB)$/bridges_marshal.lib
+# APP1STDLIBS+= \
+# $(UNOLIB) \
+# $(CPPULIB) \
+# $(CPPUHELPERLIB) \
+# $(VOSLIB) \
+# $(SALLIB) \
+# $(LIBCIMT)
+
+# APP1DEF= $(MISC)$/$(APP1TARGET).def
+
+APP2TARGET= testserver
+APP2OBJS= $(OBJ)$/testserver.obj \
+ $(OBJ)$/testcomp.obj
+
+.IF "$(OS)" == "LINUX"
+APP2STDLIBS+= -lstdc++
+.ENDIF
+
+APP2STDLIBS+= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(LIBCIMT)
+
+#APP2DEF= $(MISC)$/$(APP2TARGET).def
+
+APP3TARGET= testclient
+APP3OBJS= $(OBJ)$/testclient.obj \
+ $(OBJ)$/testcomp.obj
+
+.IF "$(OS)" == "LINUX"
+APP3STDLIBS+= -lstdc++
+.ENDIF
+
+APP3STDLIBS+= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(LIBCIMT)
+# imsci_uno.lib
+
+#APP3DEF= $(MISC)$/$(APP3TARGET).def
+
+#----------------------------------
+
+APP4TARGET= testsameprocess
+APP4OBJS= $(OBJ)$/testsameprocess.obj \
+ $(OBJ)$/testcomp.obj
+
+.IF "$(OS)" == "LINUX"
+APP4STDLIBS+= -lstdc++
+.ENDIF
+
+APP4STDLIBS+= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(LIBCIMT)
+
+APP4DEF= $(MISC)$/$(APP4TARGET).def
+
+#----------------------------------
+
+APP5TARGET= testoffice
+APP5OBJS= $(OBJ)$/testoffice.obj \
+ $(OBJ)$/testcomp.obj
+
+.IF "$(OS)" == "LINUX"
+APP5STDLIBS+= -lstdc++
+.ENDIF
+
+APP5STDLIBS+= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)\
+ $(SALLIB) \
+ $(VOSLIB)\
+ $(LIBCIMT)
+
+APP5DEF= $(MISC)$/$(APP5TARGET).def
+
+
+# --- Targets ------------------------------------------------------
+
+#.IF "$(depend)" == ""
+ALL : $(BIN)$/test.rdb \
+ $(GENJAVAFILES) \
+ ALLTAR
+
+#.ELSE
+#ALL: ALLDEP
+#.ENDIF
+
+.INCLUDE : target.mk
+
+$(BIN)$/test.rdb: $(ALLIDLFILES)
+ +unoidl -I$(PRJ) -I$(SOLARIDLDIR) -Burd -OH$(BIN) $?
+ +regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)}
+ touch $@
+
+# $(GENJAVAFILES) : $(RDB)
+# +javamaker -BUCR -O$(OUT) $(TYPES) $(UNOUCRRDB)
+
diff --git a/bridges/test/test_bridge.idl b/bridges/test/test_bridge.idl
new file mode 100644
index 000000000000..99cfb18f00ff
--- /dev/null
+++ b/bridges/test/test_bridge.idl
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * $RCSfile: test_bridge.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/uno/Exception.idl>
+
+module test
+{
+
+struct TestTypes
+{
+ boolean Bool;
+ char Char;
+ byte Byte;
+ short Short;
+ unsigned short UShort;
+ long Long;
+ unsigned long ULong;
+ hyper Hyper;
+ unsigned hyper UHyper;
+ float Float;
+ double Double;
+// test::TestEnum Enum;
+ string String;
+ com::sun::star::uno::XInterface Interface;
+ any Any;
+};
+
+exception TestBridgeException : com::sun::star::uno::Exception
+{
+
+};
+
+[ uik(FE9FF5C0-95B4-11d3-9F330010-5A677293), ident("XCallMe", 1.0) ]
+interface XCallMe : com::sun::star::uno::XInterface
+{
+ void call( [in] string s , [in] long nToDo ) raises( TestBridgeException );
+ [oneway] void callOneway( [in] string s , [in] long nToDo );
+ [attribute] string sAttribute;
+ void callAgain( [in] XCallMe callAgain, [in] long nToCall );
+ TestTypes transport( [in] TestTypes types );
+ [oneway] void drawLine( [in] long x1 , [in] long y1, [in] long x2, [in] long y2 );
+};
+
+[uik(FE9FF5C1-95B4-11d3-9F330010-5A677293), ident("XInterfaceTest", 1.0)]
+interface XInterfaceTest : com::sun::star::uno::XInterface
+{
+ void setIn( [in] XCallMe callback );
+ void setInOut( [inout] XCallMe callback );
+ void getOut( [out] XCallMe callback );
+ XCallMe get();
+};
+
+[ uik(FE9FF5C1-95B4-11d3-9F330010-5A677293), ident("XTestFactory", 1.0) ]
+interface XTestFactory : com::sun::star::uno::XInterface
+{
+ XCallMe createCallMe();
+ XInterfaceTest createInterfaceTest();
+};
+
+
+};
diff --git a/bridges/test/testclient.cxx b/bridges/test/testclient.cxx
new file mode 100644
index 000000000000..74c941584097
--- /dev/null
+++ b/bridges/test/testclient.cxx
@@ -0,0 +1,293 @@
+/*************************************************************************
+ *
+ * $RCSfile: testclient.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <string.h>
+#include <assert.h>
+
+#include <osl/mutex.hxx>
+#include <osl/module.h>
+#include <osl/thread.h>
+#include <osl/conditn.h>
+#include <osl/diagnose.h>
+
+#include <uno/mapping.hxx>
+
+#include <cppuhelper/servicefactory.hxx>
+
+#include <com/sun/star/connection/XConnector.hpp>
+
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMain.hpp>
+
+#include <com/sun/star/test/performance/XPerformanceTest.hpp>
+
+#include <cppuhelper/weak.hxx>
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#include <test/XTestFactory.hpp>
+
+
+using namespace ::test;
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::bridge;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::connection;
+using namespace ::com::sun::star::test::performance;
+
+#include "testcomp.h"
+
+
+#ifdef SOLARIS
+extern "C" void ChangeGlobalInit();
+#endif
+
+
+#ifdef UNX
+#define REG_PREFIX "lib"
+#define DLL_POSTFIX ".so"
+#else
+#define REG_PREFIX ""
+#define DLL_POSTFIX ".dll"
+#endif
+
+
+#include <vos/socket.hxx>
+
+void doPerformanceTest( const Reference < XPerformanceTest > & xBench )
+{
+ printf( "not implemented\n" );
+// sal_Int32 i,nLoop = 2000;
+// sal_Int32 tStart, tEnd , tEnd2;
+// //------------------------------------
+// // oneway calls
+// i = nLoop;
+// tStart = GetTickCount();
+// while (i--)
+// xBench->async();
+// tEnd = GetTickCount();
+// xBench->sync();
+// tEnd2 = GetTickCount();
+// printf( "%d %d %d\n" , nLoop, tEnd - tStart , tEnd2 -tStart );
+// // synchron calls
+// i = nLoop;
+// tStart = GetTickCount();
+// while (i--)
+// xBench->sync();
+// tEnd = GetTickCount();
+// printf( "%d %d \n" , nLoop, tEnd - tStart );
+
+}
+
+void testLatency( const Reference < XConnection > &r , sal_Bool bReply )
+{
+ sal_Int32 nLoop = 10000;
+ TimeValue aStartTime, aEndTime;
+ osl_getSystemTime( &aStartTime );
+
+ sal_Int32 i;
+ for( i = 0 ; i < nLoop ; i++ )
+ {
+ Sequence< sal_Int8 > s1( 200 );
+ r->write( s1 );
+ r->read( s1 , 12 );
+ r->read( s1 , 48 );
+ }
+ osl_getSystemTime( &aEndTime );
+
+ double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0);
+ double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0);
+
+ printf( "System latency per call : %g\n" , (( fEnd-fStart )/2.) / ((double)(nLoop)) );
+}
+
+void main( int argc, char *argv[] )
+{
+ sal_Bool bUseNew = ( 3 == argc );
+#ifdef SOLARIS
+ ChangeGlobalInit(); // Switch on threads !
+#endif
+ if( argc < 2 )
+ {
+ printf(
+ "usage : testclient [-r] connectionstring\n"
+ " -r reverse call me test (server calls client)"
+ );
+ return;
+ }
+
+ OUString sConnectionString;
+ OUString sProtocol;
+ sal_Bool bLatency = sal_False;
+ sal_Bool bReverse = sal_False;
+
+ parseCommandLine( argv , &sConnectionString , &sProtocol , &bLatency , &bReverse );
+
+ {
+ Reference< XMultiServiceFactory > rSMgr = createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("client.rdb")) );
+
+
+ Reference < XConnector > rConnector(
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("connectr")),
+ rSMgr ),
+ UNO_QUERY );
+
+
+ try
+ {
+ Reference < XConnection > rConnection =
+ rConnector->connect( sConnectionString );
+
+ printf( "%s\n" , OUStringToOString( rConnection->getDescription(),
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+
+
+ if( bLatency )
+ {
+ testLatency( rConnection , sal_False );
+ testLatency( rConnection , sal_True );
+ }
+ else
+ {
+ // just ensure that it is registered
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.Bridge.iiop")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("iiopbrdg")),
+ rSMgr );
+
+ Reference < XBridgeFactory > rFactory(
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("brdgfctr")),
+ rSMgr ),
+ UNO_QUERY );
+
+ if( rFactory.is() )
+ {
+
+ Reference < XBridge > rBridge = rFactory->createBridge(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bla blub")),
+ sProtocol,
+ rConnection,
+ new OInstanceProvider );
+ {
+ // test the factory
+ Reference < XBridge > rBridge2 = rFactory->getBridge( OUString( RTL_CONSTASCII_USTRINGPARAM("bla blub")) );
+ assert( rBridge2.is() );
+ assert( rBridge2->getDescription() == rBridge->getDescription( ) );
+ assert( rBridge2->getName() == rBridge->getName() );
+ assert( rBridge2 == rBridge );
+ }
+
+
+ Reference < XInterface > rInitialObject = rBridge->getInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bridges-testobject")) );
+
+ if( rInitialObject.is() )
+ {
+ printf( "got the remote object\n" );
+ if( ! bReverse )
+ {
+ // Reference < XComponent > rPerfTest( rInitialObject , UNO_QUERY );
+// if( rPerfTest.is() )
+// {
+// // doPerformanceTest( rPerfTest );
+// }
+// else
+// {
+ testRemote( rInitialObject );
+// }
+ }
+ }
+// Reference < XComponent > rComp( rBridge , UNO_QUERY );
+// rComp->dispose();
+
+ rInitialObject = Reference < XInterface > ();
+ printf( "Waiting...\n" );
+ TimeValue value={bReverse ?1000 :2,0};
+ osl_waitThread( &value );
+ printf( "Closing...\n" );
+ }
+
+ Reference < XBridge > rBridge = rFactory->getBridge( OUString( RTL_CONSTASCII_USTRINGPARAM("bla blub")) );
+// assert( ! rBridge.is() );
+ }
+
+ }
+ catch( Exception &e )
+ {
+ OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US );
+ printf( "Login failed, got an Exception !\n%s\n" , o.pData->buffer );
+ }
+
+
+ Reference < XComponent > rComp( rSMgr , UNO_QUERY );
+ rComp->dispose();
+ }
+ printf( "Closed\n" );
+}
+
diff --git a/bridges/test/testclient.java b/bridges/test/testclient.java
new file mode 100644
index 000000000000..2a8908bd3dde
--- /dev/null
+++ b/bridges/test/testclient.java
@@ -0,0 +1,190 @@
+/*************************************************************************
+ *
+ * $RCSfile: testclient.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.IBridge;
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.bridge.XInstanceProvider;
+
+import test.XCallMe;
+import test.XTestFactory;
+
+
+class MyInstanceProvider implements XInstanceProvider
+{
+ public Object getInstance( String sName )
+ {
+ System.out.println( "getInstance called" );
+ return new MyTestFactory();
+ }
+
+}
+
+
+class MyTestFactory implements XTestFactory
+{
+ public XCallMe createCallMe( ) throws com.sun.star.uno.RuntimeException
+ {
+ return new MyCallMe();
+ }
+
+ public test.XInterfaceTest createInterfaceTest( ) throws com.sun.star.uno.RuntimeException
+ {
+ return null;
+ }
+
+}
+class MyCallMe implements XCallMe
+{
+ public String getsAttribute() throws com.sun.star.uno.RuntimeException
+ {
+ return "";
+ }
+ public void setsAttribute( String _sattribute ) throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ // Methods
+ public void call( /*IN*/String s, /*IN*/int nToDo ) throws test.TestBridgeException, com.sun.star.uno.RuntimeException
+ {
+
+ }
+ public void callOneway( /*IN*/String s, /*IN*/int nToDo ) throws com.sun.star.uno.RuntimeException
+ {
+ System.out.println( "entering callOneway" );
+// this.wait( 5 );
+ try {
+ Thread.currentThread().sleep( 4000 );
+ }
+ catch ( java.lang.Exception e )
+ {
+ System.out.println( e );
+ }
+ System.out.println( "leaving callOneway" );
+ }
+ public void callAgain( /*IN*/XCallMe callAgain, /*IN*/int nToCall ) throws com.sun.star.uno.RuntimeException
+ {
+
+ }
+ public test.TestTypes transport( /*IN*/test.TestTypes types ) throws com.sun.star.uno.RuntimeException
+ {
+ return new test.TestTypes();
+ }
+
+}
+
+public class testclient
+{
+ static void main( String[] args )
+ {
+ try {
+
+ com.sun.star.comp.servicemanager.ServiceManager smgr =
+ new com.sun.star.comp.servicemanager.ServiceManager();
+ smgr.addFactories( new String[] { "com.sun.star.comp.connections.Connector" });
+
+ Object x = smgr.createInstance("com.sun.star.connection.Connector");
+ if( x == null )
+ {
+ System.out.println( "couldn't create connector\n" );
+ return;
+ }
+
+
+ XConnector xConnector =
+ ( XConnector ) UnoRuntime.queryInterface( XConnector.class , x );
+
+ XConnection xConnection = xConnector.connect(args[0]);
+
+ if( null != xConnection )
+ {
+ System.out.println( "after connect" );
+ String rootOid = "OfficeDaemon.Factory";
+ com.sun.star.uno.IBridge bridge = (IBridge ) UnoRuntime.getBridgeByName(
+ "java",
+ null,
+ "remote",
+ null,
+ new Object[]{"iiop", xConnection, new MyInstanceProvider()});
+
+ System.out.println( "after building bridge" );
+// Object rInitialObject = m_bridge.mapInterfaceFrom(rootOid, XInterface.class);
+// XTestFactory rFactory = (XTestFactory )
+// UnoRuntime.queryInterface(XTestFactory.class,rInitialObject );
+
+// XCallMe callMerFactory->
+ Thread.currentThread().sleep( 100000 );
+ }
+ }
+ catch( com.sun.star.uno.Exception e)
+ {
+ System.out.println( "Exception thrown" );
+ }
+ catch( java.lang.Exception e)
+ {
+ System.out.println( "java.lang.Exception thrown" );
+ }
+
+ System.out.println( "exiting" );
+ }
+}
diff --git a/bridges/test/testcomp.cxx b/bridges/test/testcomp.cxx
new file mode 100644
index 000000000000..f4d74cc12494
--- /dev/null
+++ b/bridges/test/testcomp.cxx
@@ -0,0 +1,875 @@
+/*************************************************************************
+ *
+ * $RCSfile: testcomp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <uno/threadpool.h>
+
+#include <osl/mutex.hxx>
+#include <osl/diagnose.h>
+
+#include <test/XTestFactory.hpp>
+#include <cppuhelper/servicefactory.hxx>
+
+#include <com/sun/star/bridge/XInstanceProvider.hpp>
+
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+
+#include <com/sun/star/test/performance/XPerformanceTest.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <cppuhelper/weak.hxx>
+
+using namespace ::test;
+using namespace ::rtl;
+using namespace ::test;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::bridge;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::test::performance;
+
+#include "testcomp.h"
+
+
+void parseCommandLine( char *argv[] ,
+ ::rtl::OUString *pConnection , ::rtl::OUString *pProtocol ,
+ sal_Bool *pbLatency , sal_Bool *pbReverse)
+{
+ sal_Int32 nArgIndex = 1;
+ if( ! strcmp( argv[1] , "-r" ) )
+ {
+ nArgIndex = 2;
+ *pbReverse = sal_True;
+ }
+ else if( ! strcmp( argv[1] , "-latency" ) )
+ {
+ *pbLatency = sal_True;
+ nArgIndex = 2;
+ }
+
+ OUString sTemp = OUString::createFromAscii( argv[nArgIndex] );
+ sal_Int32 nIndex = sTemp.indexOf( ';' );
+ if( -1 == nIndex )
+ {
+ *pConnection = sTemp;
+ *pProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "iiop" ) );
+ }
+ else
+ {
+ *pConnection = sTemp.copy( 0 , nIndex );
+ *pProtocol = sTemp.copy( nIndex+1, sTemp.getLength() - (nIndex+1) );
+ }
+}
+
+Any OInstanceProvider::queryInterface( const Type & aType )
+{
+ Any a = ::cppu::queryInterface( aType ,
+ SAL_STATIC_CAST( XInstanceProvider * , this ) );
+ if( a.hasValue() )
+ {
+ return a;
+ }
+ return OWeakObject::queryInterface( aType );
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ OInstanceProvider::getInstance( const ::rtl::OUString& sObjectName )
+ throw(::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ // Tries to get the PerformanceTestObject
+ if( sObjectName == OUString( RTL_CONSTASCII_USTRINGPARAM( "TestRemoteObject" ) ) )
+ {
+ return m_rSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.test.performance.PerformanceTestObject") ) );
+ }
+ return Reference < XInterface > ( (::cppu::OWeakObject * ) new OTestFactory() );
+}
+
+class ServiceImpl
+ : public XServiceInfo
+ , public XPerformanceTest
+{
+ OUString _aDummyString;
+ Any _aDummyAny;
+ Sequence< Reference< XInterface > > _aDummySequence;
+ ComplexTypes _aDummyStruct;
+ RuntimeException _aDummyRE;
+
+ sal_Int32 _nRef;
+
+public:
+ ServiceImpl()
+ : _nRef( 0 )
+ {}
+ ServiceImpl( const Reference< XMultiServiceFactory > & xMgr )
+ : _nRef( 0 )
+ {}
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException)
+ {
+ // execution time remains appr. constant any time
+ Any aRet;
+ if (aType == ::getCppuType( (const Reference< XInterface > *)0 ))
+ {
+ void * p = (XInterface *)(XPerformanceTest *)this;
+ aRet.setValue( &p, ::getCppuType( (const Reference< XInterface > *)0 ) );
+ }
+ if (aType == ::getCppuType( (const Reference< XPerformanceTest > *)0 ))
+ {
+ void * p = (XPerformanceTest *)this;
+ aRet.setValue( &p, ::getCppuType( (const Reference< XPerformanceTest > *)0 ) );
+ }
+ if (! aRet.hasValue())
+ {
+ void * p = (XPerformanceTest *)this;
+ Any aDummy( &p, ::getCppuType( (const Reference< XPerformanceTest > *)0 ) );
+ }
+ return aRet;
+ }
+ virtual void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException)
+ { osl_incrementInterlockedCount( &_nRef ); }
+ virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException)
+ { if (! osl_decrementInterlockedCount( &_nRef )) delete this; }
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException);
+
+ // Attributes
+ virtual sal_Int32 SAL_CALL getLong_attr() throw(::com::sun::star::uno::RuntimeException)
+ { return 0; }
+ virtual void SAL_CALL setLong_attr( sal_Int32 _attributelong ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual sal_Int64 SAL_CALL getHyper_attr() throw(::com::sun::star::uno::RuntimeException)
+ { return 0; }
+ virtual void SAL_CALL setHyper_attr( sal_Int64 _attributehyper ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual float SAL_CALL getFloat_attr() throw(::com::sun::star::uno::RuntimeException)
+ { return 0.0; }
+ virtual void SAL_CALL setFloat_attr( float _attributefloat ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual double SAL_CALL getDouble_attr() throw(::com::sun::star::uno::RuntimeException)
+ { return 0.0; }
+ virtual void SAL_CALL setDouble_attr( double _attributedouble ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual OUString SAL_CALL getString_attr() throw(::com::sun::star::uno::RuntimeException)
+ { return _aDummyString; }
+ virtual void SAL_CALL setString_attr( const ::rtl::OUString& _attributestring ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual Reference< XInterface > SAL_CALL getInterface_attr() throw(::com::sun::star::uno::RuntimeException)
+ { return Reference< XInterface >(); }
+ virtual void SAL_CALL setInterface_attr( const Reference< XInterface >& _attributeinterface ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual Any SAL_CALL getAny_attr() throw(::com::sun::star::uno::RuntimeException)
+ { return _aDummyAny; }
+ virtual void SAL_CALL setAny_attr( const Any& _attributeany ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual Sequence< Reference< XInterface > > SAL_CALL getSequence_attr() throw(::com::sun::star::uno::RuntimeException)
+ { return _aDummySequence; }
+ virtual void SAL_CALL setSequence_attr( const Sequence< Reference< XInterface > >& _attributesequence ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual ComplexTypes SAL_CALL getStruct_attr() throw(::com::sun::star::uno::RuntimeException)
+ { return _aDummyStruct; }
+ virtual void SAL_CALL setStruct_attr( const ::com::sun::star::test::performance::ComplexTypes& _attributestruct ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+
+ // Methods
+ virtual sal_Int32 SAL_CALL getLong() throw(::com::sun::star::uno::RuntimeException)
+ { return 0; }
+ virtual void SAL_CALL setLong( sal_Int32 _long ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual sal_Int64 SAL_CALL getHyper() throw(::com::sun::star::uno::RuntimeException)
+ { return 0; }
+ virtual void SAL_CALL setHyper( sal_Int64 _hyper ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual float SAL_CALL getFloat() throw(::com::sun::star::uno::RuntimeException)
+ { return 0; }
+ virtual void SAL_CALL setFloat( float _float ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual double SAL_CALL getDouble() throw(::com::sun::star::uno::RuntimeException)
+ { return 0; }
+ virtual void SAL_CALL setDouble( double _double ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual OUString SAL_CALL getString() throw(::com::sun::star::uno::RuntimeException)
+ { return _aDummyString; }
+ virtual void SAL_CALL setString( const ::rtl::OUString& _string ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual Reference< XInterface > SAL_CALL getInterface() throw(::com::sun::star::uno::RuntimeException)
+ { return Reference< XInterface >(); }
+ virtual void SAL_CALL setInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _interface ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual Any SAL_CALL getAny() throw(::com::sun::star::uno::RuntimeException)
+ { return _aDummyAny; }
+ virtual void SAL_CALL setAny( const ::com::sun::star::uno::Any& _any ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual Sequence< Reference< XInterface > > SAL_CALL getSequence() throw(::com::sun::star::uno::RuntimeException)
+ { return _aDummySequence; }
+ virtual void SAL_CALL setSequence( const Sequence< Reference< XInterface > >& _sequence ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual ComplexTypes SAL_CALL getStruct() throw(::com::sun::star::uno::RuntimeException)
+ { return _aDummyStruct; }
+ virtual void SAL_CALL setStruct( const ::com::sun::star::test::performance::ComplexTypes& c ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL async() throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL sync() throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual ComplexTypes SAL_CALL complex_in( const ::com::sun::star::test::performance::ComplexTypes& aVal ) throw(::com::sun::star::uno::RuntimeException)
+ { return aVal; }
+ virtual ComplexTypes SAL_CALL complex_inout( ::com::sun::star::test::performance::ComplexTypes& aVal ) throw(::com::sun::star::uno::RuntimeException)
+ { return aVal; }
+ virtual void SAL_CALL complex_oneway( const ::com::sun::star::test::performance::ComplexTypes& aVal ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual void SAL_CALL complex_noreturn( const ::com::sun::star::test::performance::ComplexTypes& aVal ) throw(::com::sun::star::uno::RuntimeException)
+ {}
+ virtual Reference< XPerformanceTest > SAL_CALL createObject() throw(::com::sun::star::uno::RuntimeException)
+ { return new ServiceImpl(); }
+ virtual void SAL_CALL raiseRuntimeException( ) throw(::com::sun::star::uno::RuntimeException)
+ { throw _aDummyRE; }
+};
+
+
+void ServiceImpl::async() throw(::com::sun::star::uno::RuntimeException)
+{}
+
+// XServiceInfo
+//__________________________________________________________________________________________________
+OUString ServiceImpl::getImplementationName()
+ throw (RuntimeException)
+{
+ return OUString( );
+}
+//__________________________________________________________________________________________________
+sal_Bool ServiceImpl::supportsService( const OUString & rServiceName )
+ throw (RuntimeException)
+{
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > ServiceImpl::getSupportedServiceNames()
+ throw (RuntimeException)
+{
+ return Sequence< OUString > ();
+}
+
+/******************
+ * OCallMe
+ *
+ *****************/
+
+Any OCallMe::queryInterface( const Type & aType )
+{
+ Any a = ::cppu::queryInterface( aType,
+ SAL_STATIC_CAST( XCallMe * , this ) );
+
+ if( a.hasValue() )
+ {
+ return a;
+ }
+
+ return OWeakObject::queryInterface( aType );
+}
+
+void OCallMe::call( const ::rtl::OUString& s, sal_Int32 nToDo )
+ throw( RuntimeException, ::test::TestBridgeException)
+{
+ if( nToDo < 0 )
+ {
+ throw TestBridgeException();
+ }
+
+ OUString sDummy;
+ if( ! nToDo ) {
+ OString o = OUStringToOString( s,RTL_TEXTENCODING_ASCII_US);
+ printf( "%s\n" , o.pData->buffer );
+ }
+ for( sal_Int32 i = 0 ; i < nToDo ; i ++ )
+ {
+ sDummy += s;
+ }
+}
+
+void SAL_CALL OCallMe::drawLine( sal_Int32 x1, sal_Int32 y1 , sal_Int32 x2 , sal_Int32 y2 )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ // do nothings
+}
+
+void OCallMe::callOneway( const ::rtl::OUString& s, sal_Int32 nToDo )
+ throw(RuntimeException)
+{
+ static int iBefore = 0;
+
+ OUString sDummy;
+ m_nLastToDos = nToDo;
+
+
+ if( nToDo )
+ {
+ printf( "+" );
+ fflush( stdout );
+
+ TimeValue val = { nToDo , 0 };
+ osl_waitThread( &val );
+ printf( "-\n" );
+ }
+
+}
+
+::test::TestTypes SAL_CALL OCallMe::transport( const ::test::TestTypes& types )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return types;
+}
+
+::rtl::OUString OCallMe::getsAttribute() throw(RuntimeException)
+{
+ return m_sAttribute;
+}
+void OCallMe::setsAttribute( const ::rtl::OUString& _sattribute )
+ throw(RuntimeException)
+{
+ m_sAttribute = _sattribute;
+}
+void OCallMe::callAgain( const Reference< ::test::XCallMe >& callAgain,
+ sal_Int32 nToCall ) throw(RuntimeException)
+{
+ ::osl::MutexGuard guard( m_mutex );
+ if( nToCall %2 )
+ {
+ printf( "Deadlocktest pong %d\n", nToCall );
+ }
+ else
+ {
+ printf( "Deadlocktest ping %d\n", nToCall );
+ }
+ if( nToCall )
+ {
+ callAgain->callAgain( Reference< XCallMe > ( (XCallMe *) this ) , nToCall -1 );
+ }
+}
+
+/********************
+ * OInterfaceTest
+ *
+ *******************/
+Any OInterfaceTest::queryInterface( const Type & aType )
+{
+ Any a = ::cppu::queryInterface( aType,
+ SAL_STATIC_CAST( XInterfaceTest * , this ) );
+ if( a.hasValue() )
+ {
+ return a;
+ }
+ return OWeakObject::queryInterface( aType );
+}
+
+
+void OInterfaceTest::setIn(
+ const Reference< ::test::XCallMe >& callback )
+ throw(RuntimeException)
+{
+ m_rCallMe = callback;
+ call();
+}
+
+void OInterfaceTest::setInOut( Reference< ::test::XCallMe >& callback )
+ throw(RuntimeException)
+{
+ Reference< XCallMe > r = m_rCallMe;
+ m_rCallMe = callback;
+ callback = r;
+ call();
+}
+
+
+void OInterfaceTest::getOut( Reference< ::test::XCallMe >& callback )
+ throw(RuntimeException)
+{
+ callback = m_rCallMe;
+}
+
+Reference< ::test::XCallMe > OInterfaceTest::get( )
+ throw(RuntimeException)
+{
+ call();
+ return m_rCallMe;
+}
+
+void OInterfaceTest::call()
+{
+ if( m_rCallMe.is() )
+ {
+ m_rCallMe->call( OUString( RTL_CONSTASCII_USTRINGPARAM("This is my String during a callback!")) , 5);
+ }
+}
+
+
+Any OTestFactory::queryInterface( const Type & aType )
+{
+ Any a = ::cppu::queryInterface( aType,
+ SAL_STATIC_CAST( XTestFactory * , this ) );
+
+ if( a.hasValue() )
+ {
+ return a;
+ }
+
+ return OWeakObject::queryInterface( aType );
+}
+
+Reference< ::test::XCallMe > OTestFactory::createCallMe( )
+ throw(RuntimeException)
+{
+ return Reference< XCallMe > ( (XCallMe * ) new OCallMe() );
+}
+
+Reference< ::test::XInterfaceTest > SAL_CALL OTestFactory::createInterfaceTest( )
+ throw(RuntimeException)
+{
+ return Reference < XInterfaceTest > ( (XInterfaceTest * ) new OInterfaceTest() );
+}
+
+
+
+/********************************************************
+ *
+ ********************************************************/
+/*Any OConnectCallback::queryInterface( const Type & aType )
+{
+ Any a = ::cppu::queryInterface( aType,
+ SAL_STATIC_CAST( XConnectCallback * , this ) );
+ if( a.hasValue() )
+ {
+ return a;
+ }
+ return OWeakObject::queryInterface( aType );
+}
+
+
+void SAL_CALL OConnectCallback::attemptConnect(
+ const Reference< XConnectionServerSide >& connection )
+ throw(SecurityException, ::com::sun::star::uno::RuntimeException)
+{
+ // TODO
+ // user verification
+ if( L"bad guy" == connection->getUser() &&
+ L"secret" == connection->getPassword() )
+ {
+ Reference< XInterface > rInterface(
+ ( XInterface * ) (::cppu::OWeakObject *) new OTestFactory() );
+ connection->provideRemoteObject( rInterface );
+ }
+ else
+ {
+ throw SecurityException();
+ }
+}
+
+*/
+
+
+// class OInstanceProvider :
+// public ::cppu::OWeakObject,
+// public XInstanceProvider
+// {
+// public:
+// OInstanceProvider( ){}
+// ~OInstanceProvider(){ printf( "instance provider dies\n" );}
+// public:
+// // XInterface
+// Any SAL_CALL queryInterface( const Type & aType);
+// void SAL_CALL acquire() { OWeakObject::acquire(); }
+// void SAL_CALL release() { OWeakObject::release(); }
+
+// public:
+// // XConnectCallback
+// virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+// getInstance( const ::rtl::OUString& sObjectName )
+// throw( ::com::sun::star::container::NoSuchElementException,
+// ::com::sun::star::uno::RuntimeException);
+// };
+
+
+
+
+
+
+
+
+double getCallsPerSec( const Reference < XCallMe > &rCall , int nLoops, int nToDo )
+{
+ TimeValue aStartTime, aEndTime;
+ osl_getSystemTime( &aStartTime );
+ for( sal_Int32 i = 0; i < nLoops; i ++ )
+ {
+ rCall->call( OUString( RTL_CONSTASCII_USTRINGPARAM("Performance test string")) , nToDo );
+ }
+ osl_getSystemTime( &aEndTime );
+
+ double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0);
+ double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0);
+ return fEnd-fStart;
+}
+
+double getCallsPerSecOneway( const Reference < XCallMe > &rCall ,
+ int nLoops,
+ int nToDo,
+ double *pdAfterExecution
+ )
+{
+ TimeValue aStartTime, aEndTime, aAfterExecution;
+ osl_getSystemTime( &aStartTime );
+ for( sal_Int32 i = 0; i < nLoops; i ++ )
+ {
+// rCall->callOneway( OUString( RTL_CONSTASCII_USTRINGPARAM("Performance test string" )), 0 );
+ rCall->drawLine( 0 , 0 , 500 , 123 );
+ }
+ osl_getSystemTime( &aEndTime );
+
+ rCall->call( OUString( RTL_CONSTASCII_USTRINGPARAM("Performance test string")) , nToDo );
+ osl_getSystemTime( &aAfterExecution );
+
+ double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0);
+ double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0);
+ *pdAfterExecution = (double)aAfterExecution.Seconds +
+ ((double)aAfterExecution.Nanosec / 1000000000.0) - fStart;
+ return fEnd-fStart;
+}
+
+void testOnewayPerformanceOnTwoInterfaces(
+ const Reference < XCallMe > &rRemote1, const Reference < XCallMe > &rRemote2 )
+{
+ printf( "Doing oneway performance test on two interfaces ...\n" );
+ const sal_Int32 nLoops = 10000;
+ TimeValue aStartTime, aEndTime, aAfterExecution;
+ osl_getSystemTime( &aStartTime );
+ for( sal_Int32 i = 0; i < nLoops ; i ++ )
+ {
+ rRemote1->drawLine( 0 , 0 , 500 , 123 );
+ rRemote2->drawLine( 0 , 0 , 500 , 123 );
+ }
+ osl_getSystemTime( &aEndTime );
+ double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0);
+ double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0);
+
+ printf( "Overhead per Call [ms] %g\n" , ((fEnd-fStart)/((double)nLoops/1000 ))/2. );
+}
+
+void testPerformance( const Reference < XCallMe > &rRemote,
+ const Reference < XCallMe > &rLocal )
+{
+ OUString aTestString;
+
+ sal_Int32 nDoSomething = 1;
+ sal_Int32 nCalls = 80000;
+ double dRemote, dLocal,dAfterExecution;
+
+ printf( "performance test oneway...\n" );
+ dLocal = getCallsPerSecOneway( rLocal , nCalls , nDoSomething , &dAfterExecution);
+ dRemote = getCallsPerSecOneway( rRemote , nCalls , nDoSomething , &dAfterExecution);
+ printf( "Local=%g s,"
+ "Remote : %g s\n" , dLocal, dRemote );
+ if( dLocal > 0. )
+ {
+ printf( "Remote/Local : %g\n", dRemote/dLocal );
+ }
+
+ printf( "Overhead per Call [ms] %g\n" , (dRemote - dLocal)/((double)nCalls/1000 ) );
+ printf( "Overhead per Call after completion [ms] %g\n" , (dAfterExecution - dLocal)/((double)nCalls/1000 ) );
+
+ nCalls = 2000;
+
+ printf( "Doing performance test ...\n" );
+ dRemote = getCallsPerSec( rRemote , nCalls , nDoSomething );
+ dLocal = getCallsPerSec( rLocal , nCalls , nDoSomething );
+ printf( "Local=%g s,\n"
+ "Remote=%g s\n" , dLocal, dRemote );
+ if( dLocal > 0. )
+ {
+ printf( "Remote/Local : %g\n", dRemote/dLocal );
+ }
+ printf( "Overhead per synchron Call [ms] %g\n" , ((dRemote - dLocal)/((double)nCalls/1000 )) );
+}
+
+void testException( const Reference < XCallMe > &r )
+{
+ try {
+ r->call( OUString( RTL_CONSTASCII_USTRINGPARAM("dummy")) , -1 );
+ assert( ! "no exception flown !" );
+ }
+ catch( TestBridgeException & e )
+ {
+ // Exception flew successfully !
+ }
+ catch( Exception & e )
+ {
+ assert( ! "only base class of exception could be catched!" );
+ }
+ catch(...)
+ {
+ assert(! "wrong unknown exception !" );
+ }
+}
+
+void testSequenceOfCalls( const Reference< XCallMe > & rRCallMe )
+{
+ printf( "Testing sequence of calls\n" );
+ for( sal_Int32 i = 0 ; i < 800 ; i ++ )
+ {
+ rRCallMe->callOneway( OUString( RTL_CONSTASCII_USTRINGPARAM("hifuj" )), 0 );
+ }
+}
+
+void testAllTypes( const Reference < XCallMe > & rRCallMe )
+{
+ printf( "Testing all types\n" );
+
+ for( sal_Int32 i = 0; i < 32 ; i ++ )
+ {
+
+ TestTypes types;
+ types.Bool = sal_True;
+ types.Char = L'i';
+ types.Byte = -12;
+ types.Short = -32000;
+ types.UShort = (sal_uInt16 ) (1 << i);
+ types.Long = -123;
+ types.ULong = 1 << i;
+ types.Hyper = 50;
+ types.UHyper = 1 << i*2;
+ types.Float = (float)123.239;
+ types.Double = 1279.12490012;
+ types.String = OUString( RTL_CONSTASCII_USTRINGPARAM("abcdefghijklmnopqrstuvwxyz"));
+ types.Interface = Reference< XInterface >( rRCallMe , UNO_QUERY);
+ types.Any <<= types.Double;
+
+ TestTypes retTypes = rRCallMe->transport( types );
+
+ OSL_ASSERT( ( types.Bool && retTypes.Bool ) || ( ! types.Bool && ! retTypes.Bool ) );
+ OSL_ASSERT( types.Char == retTypes.Char );
+ OSL_ASSERT( types.Byte == retTypes.Byte );
+ OSL_ASSERT( types.Short == retTypes.Short );
+ OSL_ASSERT( types.UShort == retTypes.UShort );
+ OSL_ASSERT( types.Long == retTypes.Long );
+ OSL_ASSERT( types.ULong == retTypes.ULong );
+ OSL_ASSERT( types.Hyper == retTypes.Hyper );
+ OSL_ASSERT( types.UHyper == retTypes.UHyper );
+ OSL_ASSERT( types.Float == retTypes.Float );
+ OSL_ASSERT( types.Double == retTypes.Double );
+ OSL_ASSERT( types.String == retTypes.String );
+ OSL_ASSERT( types.Interface == retTypes.Interface );
+ OSL_ASSERT( types.Any == retTypes.Any );
+ }
+
+}
+
+void testRemote( const Reference< XInterface > &rRemote )
+{
+ char a;
+ getCppuType( (sal_Int8*)&a );
+
+ Reference< XTestFactory > rRFact( rRemote , UNO_QUERY );
+ if( ! rRFact.is() )
+ {
+ printf( "remote object doesn't support XTestFactory\n" );
+ return;
+ }
+ OSL_ASSERT( rRFact.is() );
+ Reference< XCallMe > rLCallMe = (XCallMe * ) new OCallMe();
+ Reference< XCallMe > rRCallMe = rRFact->createCallMe();
+
+ testAllTypes( rLCallMe );
+ testAllTypes( rRCallMe );
+
+ printf( "Testing exception local ...\n" );
+ testException( rLCallMe );
+ printf( "Testing exception remote ...\n" );
+ testException( rRCallMe );
+
+ //--------------------
+ // Test attributes
+ //----------------------
+ OUString ow = OUString::createFromAscii( "dum didel dum dideldei" );
+ rLCallMe->setsAttribute( ow );
+ OSL_ASSERT( rLCallMe->getsAttribute() == ow );
+
+ rRCallMe->setsAttribute( ow );
+ OSL_ASSERT( rRCallMe->getsAttribute() == ow );
+
+ //-------------------
+ // Performance test
+ //-------------------
+ testPerformance( rRCallMe , rLCallMe );
+ testOnewayPerformanceOnTwoInterfaces( rRFact->createCallMe(), rRCallMe );
+
+ //----------------
+ // Test sequence
+ //----------------
+ testSequenceOfCalls( rRCallMe );
+
+
+ // test triple to check if transporting the same interface multiple
+ // times causes any problems
+ Reference< XInterfaceTest > rRTest = rRFact->createInterfaceTest();
+ Reference< XInterfaceTest > rRTest2 = rRFact->createInterfaceTest();
+ Reference< XInterfaceTest > rRTest3 = rRFact->createInterfaceTest();
+
+ rRTest->setIn( rRCallMe );
+ rRTest2->setIn( rRCallMe );
+ rRTest3->setIn( rRCallMe );
+
+ OSL_ASSERT( rRTest->get() == rRCallMe );
+ OSL_ASSERT( rRTest2->get() == rRCallMe );
+ OSL_ASSERT( rRTest3->get() == rRCallMe );
+
+ rRTest->setIn( rLCallMe );
+ rRTest2->setIn( rLCallMe );
+ rRTest3->setIn( rLCallMe );
+
+ {
+ Reference< XCallMe > rLCallMe1 = (XCallMe * ) new OCallMe();
+ Reference< XCallMe > rLCallMe2 = (XCallMe * ) new OCallMe();
+ Reference< XCallMe > rLCallMe3 = (XCallMe * ) new OCallMe();
+ rRTest->setIn( rLCallMe1 );
+ rRTest2->setIn( rLCallMe2 );
+ rRTest3->setIn( rLCallMe3 );
+ OSL_ASSERT( rRTest->get() == rLCallMe1 );
+ OSL_ASSERT( rRTest2->get() == rLCallMe2 );
+ OSL_ASSERT( rRTest3->get() == rLCallMe3 );
+
+ rRTest->setIn( rLCallMe );
+ rRTest2->setIn( rLCallMe );
+ rRTest3->setIn( rLCallMe );
+
+ OSL_ASSERT( rRTest->get() == rLCallMe );
+ OSL_ASSERT( rRTest2->get() == rLCallMe );
+ OSL_ASSERT( rRTest3->get() == rLCallMe );
+ }
+
+ Reference < XCallMe > r = rRCallMe;
+ rRTest->setInOut( r );
+ OSL_ASSERT( r == rLCallMe );
+ OSL_ASSERT( ! ( r == rRCallMe ) );
+
+ // test empty references
+ rRTest->setIn( Reference < XCallMe > () );
+
+ //--------------------------------
+ // test thread deadlocking
+ //--------------------------------
+ rLCallMe->callAgain( rRCallMe, 20 );
+
+}
+
+
+
+
+
+
+Reference <XInterface > createComponent( const ::rtl::OUString &sService ,
+ const ::rtl::OUString &sDllName,
+ const Reference < XMultiServiceFactory > &rSMgr )
+{
+ Reference< XInterface > rInterface;
+ rInterface = rSMgr->createInstance( sService );
+
+ if( ! rInterface.is() )
+ {
+ // erst registrieren
+ Reference < XImplementationRegistration > rReg (
+ rSMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.registry.ImplementationRegistration" )),
+ UNO_QUERY );
+
+ OSL_ASSERT( rReg.is() );
+#ifdef SAL_W32
+ OUString aDllName = sDllName;
+#else
+ OUString aDllName = OUString( RTL_CONSTASCII_USTRINGPARAM("lib"));
+ aDllName += sDllName;
+ aDllName += OUString( RTL_CONSTASCII_USTRINGPARAM(".so"));
+#endif
+
+ try
+ {
+ rReg->registerImplementation(
+ OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ),
+ aDllName,
+ Reference< XSimpleRegistry > () );
+ rInterface = rSMgr->createInstance( sService );
+ }
+ catch( Exception & )
+ {
+ printf( "couldn't register dll %s\n" ,
+ OUStringToOString( aDllName, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ }
+ return rInterface;
+}
+
+
diff --git a/bridges/test/testcomp.h b/bridges/test/testcomp.h
new file mode 100644
index 000000000000..19313afc63ea
--- /dev/null
+++ b/bridges/test/testcomp.h
@@ -0,0 +1,214 @@
+/*************************************************************************
+ *
+ * $RCSfile: testcomp.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+//#include <com/sun/star/bridge/XServer.hpp>
+//#include <com/sun/star/bridge/XClient.hpp>
+#include <stdio.h>
+
+#include <com/sun/star/bridge/XInstanceProvider.hpp>
+//#include <com/sun/star/bridge/XConnectionAdministration.hpp>
+#include <vos/thread.hxx>
+#include <vos/timer.hxx>
+
+
+void parseCommandLine( char *argv[] ,
+ ::rtl::OUString *pProtocol , ::rtl::OUString *pConnection ,
+ sal_Bool *pbLatency , sal_Bool *pbReverse);
+
+
+Reference< XInterface > createComponent(
+ const ::rtl::OUString &sServiceName,
+ const ::rtl::OUString &sDllName,
+ const Reference < XMultiServiceFactory > & rSMgr );
+
+class OInterfaceTest :
+ public ::cppu::OWeakObject,
+ public XInterfaceTest
+{
+public:
+ OInterfaceTest() {}
+ ~OInterfaceTest() {}
+
+public:
+ // XInterface
+ Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType);
+ void SAL_CALL acquire() { OWeakObject::acquire(); }
+ void SAL_CALL release() { OWeakObject::release(); }
+
+public:
+ virtual void SAL_CALL setIn( const ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL getOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL get( ) throw(::com::sun::star::uno::RuntimeException);
+private:
+ void call();
+
+private:
+ Reference < XCallMe > m_rCallMe;
+};
+
+
+class OCallMe :
+ public ::cppu::OWeakObject,
+ public XCallMe
+{
+public:
+ OCallMe() : m_nLastToDos(-1) {}
+ ~OCallMe() {}
+
+public:
+ // XInterface
+ Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType);
+ void SAL_CALL acquire() { OWeakObject::acquire(); }
+ void SAL_CALL release() { OWeakObject::release(); }
+public:
+ // XCallMe
+ virtual void SAL_CALL call( const ::rtl::OUString& s, sal_Int32 nToDo )
+ throw(::com::sun::star::uno::RuntimeException,
+ ::test::TestBridgeException);
+ virtual void SAL_CALL callOneway( const ::rtl::OUString& s, sal_Int32 nToDo )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL drawLine( sal_Int32 x1, sal_Int32 y1 , sal_Int32 x2 , sal_Int32 y2 )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getsAttribute() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setsAttribute( const ::rtl::OUString& _sattribute ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL callAgain( const ::com::sun::star::uno::Reference< ::test::XCallMe >& callAgain,
+ sal_Int32 nToCall ) throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::test::TestTypes SAL_CALL transport( const ::test::TestTypes& types )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ ::osl::Mutex m_mutex;
+ ::rtl::OUString m_sAttribute;
+ sal_Int32 m_nLastToDos;
+};
+
+class OTestFactory :
+ public ::cppu::OWeakObject,
+ public XTestFactory
+{
+public:
+ OTestFactory() {}
+ ~OTestFactory() {}
+
+public:
+ // XInterface
+ Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType );
+ void SAL_CALL acquire() { OWeakObject::acquire(); }
+ void SAL_CALL release() { OWeakObject::release(); }
+public:
+ virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL createCallMe( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::test::XInterfaceTest > SAL_CALL createInterfaceTest( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+};
+
+/*
+class OConnectCallback :
+ public ::cppu::OWeakObject,
+ public XConnectCallback
+{
+public:
+ OConnectCallback( ){}
+ ~OConnectCallback(){ printf( "callback dies\n" );}
+public:
+ // XInterface
+ Any SAL_CALL queryInterface( const Type & aType);
+ void SAL_CALL acquire() { OWeakObject::acquire(); }
+ void SAL_CALL release() { OWeakObject::release(); }
+
+public:
+ // XConnectCallback
+ virtual void SAL_CALL attemptConnect(
+ const Reference< XConnectionServerSide >& connection )
+ throw(SecurityException, RuntimeException);
+};
+
+*/
+
+class OInstanceProvider :
+ public ::cppu::OWeakObject,
+ public XInstanceProvider
+{
+public:
+ OInstanceProvider( ){}
+ OInstanceProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & r ) :
+ m_rSMgr( r )
+ {}
+ ~OInstanceProvider(){ printf( "instance provider dies\n" );}
+public:
+ // XInterface
+ Any SAL_CALL queryInterface( const Type & aType);
+ void SAL_CALL acquire() { OWeakObject::acquire(); }
+ void SAL_CALL release() { OWeakObject::release(); }
+
+public:
+ // XConnectCallback
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ getInstance( const ::rtl::OUString& sObjectName )
+ throw( ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_rSMgr;
+};
+
+void testRemote( const Reference< XInterface > &rRemote );
diff --git a/bridges/test/testoffice.cxx b/bridges/test/testoffice.cxx
new file mode 100644
index 000000000000..8b8d7a97c245
--- /dev/null
+++ b/bridges/test/testoffice.cxx
@@ -0,0 +1,314 @@
+/*************************************************************************
+ *
+ * $RCSfile: testoffice.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <assert.h>
+
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+
+#include <cppuhelper/servicefactory.hxx>
+
+#include <com/sun/star/connection/XConnector.hpp>
+
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+
+#include <com/sun/star/text/XTextDocument.hpp>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <com/sun/star/frame/XComponentLoader.hpp>
+
+#include <cppuhelper/weak.hxx>
+
+#include <test/XTestFactory.hpp>
+
+using namespace ::test;
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::bridge;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::connection;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::text;
+
+#include "testcomp.h"
+
+#ifdef SAL_W32
+#include <conio.h>
+#endif
+
+#ifdef SOLARIS
+extern "C" void ChangeGlobalInit();
+#endif
+
+void mygetchar()
+{
+#ifdef SAL_W32
+ _getch();
+#else
+ getchar();
+#endif
+}
+
+
+void testPipe( const Reference < XMultiServiceFactory > & rSmgr )
+{
+ Reference < XOutputStream > rOut(
+ rSmgr->createInstance( OUString::createFromAscii( "com.sun.star.io.Pipe" ) ),
+ UNO_QUERY );
+
+ assert( rOut.is() );
+
+ {
+ Sequence < sal_Int8 > seq( 10 );
+ seq.getArray()[0] = 42;
+ rOut->writeBytes( seq );
+ }
+
+
+ {
+ Sequence < sal_Int8 > seq;
+ Reference < XInputStream > rIn( rOut , UNO_QUERY );
+ if( ! ( rIn->available() == 10) )
+ printf( "wrong bytes available\n" );
+ if( ! ( rIn->readBytes( seq , 10 ) == 10 ) )
+ printf( "wrong bytes read\n" );
+ if( ! ( 42 == seq.getArray()[0] ) )
+ printf( "wrong element in sequence\n" );
+
+// assert( 0 );
+ }
+}
+#include<stdio.h>
+#include<string.h>
+
+void testWriter( const Reference < XComponent > & rCmp )
+{
+
+ Reference< XTextDocument > rTextDoc( rCmp , UNO_QUERY );
+
+ Reference< XText > rText = rTextDoc->getText();
+ Reference< XTextCursor > rCursor = rText->createTextCursor();
+ Reference< XTextRange > rRange ( rCursor , UNO_QUERY );
+
+ char pcText[1024];
+ pcText[0] = 0;
+ printf( "pleast type any text\n" );
+ while( sal_True )
+ {
+ scanf( "%s" , pcText );
+
+ if( !strcmp( pcText , "end" ) )
+ {
+ break;
+ }
+
+ strcat( pcText , " " );
+ rText->insertString( rRange , OUString::createFromAscii( pcText ) , sal_False );
+ }
+}
+
+void testDocument( const Reference < XMultiServiceFactory > & rSmgr )
+{
+ Reference < XComponentLoader > rLoader(
+ rSmgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop" ))),
+ UNO_QUERY );
+
+ assert( rLoader.is() );
+
+ sal_Char *urls[] = {
+ "private:factory/swriter",
+ "private:factory/scalc",
+ "private:factory/sdraw",
+ "http://www.heise.de",
+ "file://h|/remote_interfaces.sdw"
+ };
+
+ sal_Char *docu[]= {
+ "a new writer document ...\n",
+ "a new calc document ...\n",
+ "a new draw document ...\n",
+ "www.heise.de\n",
+ "the remote_interfaces.sdw doc\n"
+ };
+
+ sal_Int32 i;
+ for( i = 0 ; i < 1 ; i ++ )
+ {
+ printf( "press any key to open %s\n" , docu[i] );
+ mygetchar();
+
+ Reference< XComponent > rComponent =
+ rLoader->loadComponentFromURL(
+ OUString::createFromAscii( urls[i] ) ,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("_blank")),
+ 0 ,
+ Sequence < ::com::sun::star::beans::PropertyValue >() );
+
+ testWriter( rComponent );
+ printf( "press any key to close the document\n" );
+ mygetchar();
+ rComponent->dispose();
+ }
+
+}
+
+void doSomething( const Reference < XInterface > &r )
+{
+ Reference < XNamingService > rName( r, UNO_QUERY );
+ if( rName.is() )
+ {
+ printf( "got the remote naming service !\n" );
+ Reference < XInterface > rXsmgr = rName->getRegisteredObject(
+ OUString::createFromAscii( "StarOffice.ServiceManager" ) );
+
+ Reference < XMultiServiceFactory > rSmgr( rXsmgr , UNO_QUERY );
+ if( rSmgr.is() )
+ {
+ printf( "got the remote service manager !\n" );
+ testPipe( rSmgr );
+ testDocument( rSmgr );
+ }
+ }
+}
+
+
+void main( int argc, char *argv[] )
+{
+
+#ifdef SOLARIS
+ ChangeGlobalInit(); // Switch on threads !
+#endif
+ if( argc < 2 )
+ {
+ printf( "usage : testclient host:port" );
+ exit( 1 );
+ }
+
+ OUString sConnectionString;
+ OUString sProtocol;
+ sal_Bool bLatency = sal_False;
+ sal_Bool bReverse = sal_False;
+ parseCommandLine( argv , &sConnectionString , &sProtocol , &bLatency , &bReverse );
+ {
+ Reference< XMultiServiceFactory > rSMgr = createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "client.rdb" ) ) );
+
+ // just ensure that it is registered
+
+ Reference < XConnector > rConnector(
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("connectr")),
+ rSMgr ),
+ UNO_QUERY );
+
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.Bridge.iiop")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("iiopbrdg")),
+ rSMgr );
+
+ Reference < XBridgeFactory > rFactory(
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("brdgfctr")),
+ rSMgr ),
+ UNO_QUERY );
+
+ try
+ {
+ if( rFactory.is() && rConnector.is() )
+ {
+ Reference < XConnection > rConnection =
+ rConnector->connect( sConnectionString );
+
+ Reference < XBridge > rBridge = rFactory->createBridge(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bla blub")),
+ sProtocol,
+ rConnection,
+ Reference < XInstanceProvider > () );
+
+ Reference < XInterface > rInitialObject
+ = rBridge->getInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("NamingService")) );
+
+ if( rInitialObject.is() )
+ {
+ printf( "got the remote object\n" );
+ doSomething( rInitialObject );
+ }
+ TimeValue value={2,0};
+ osl_waitThread( &value );
+ }
+ }
+ catch (... ) {
+ printf( "Exception thrown\n" );
+ }
+
+ Reference < XComponent > rComp( rSMgr , UNO_QUERY );
+ rComp->dispose();
+ }
+ //_getch();
+}
diff --git a/bridges/test/testsameprocess.cxx b/bridges/test/testsameprocess.cxx
new file mode 100644
index 000000000000..137b4be4e530
--- /dev/null
+++ b/bridges/test/testsameprocess.cxx
@@ -0,0 +1,252 @@
+/*************************************************************************
+ *
+ * $RCSfile: testsameprocess.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <assert.h>
+
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+
+#include <cppuhelper/servicefactory.hxx>
+
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+#include <com/sun/star/connection/XAcceptor.hpp>
+#include <com/sun/star/connection/XConnector.hpp>
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <cppuhelper/weak.hxx>
+
+#include <test/XTestFactory.hpp>
+
+#include <vos/thread.hxx>
+
+using namespace ::test;
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::vos;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::bridge;
+using namespace ::com::sun::star::connection;
+using namespace ::com::sun::star::registry;
+
+#ifdef SAL_W32
+#include <conio.h>
+#endif
+
+#include "testcomp.h"
+#include "osl/mutex.h"
+
+/*********
+ *
+ ********/
+
+class MyThread :
+ public OThread
+{
+public:
+ MyThread( const Reference< XAcceptor > &r ,
+ const Reference< XBridgeFactory > &rFactory,
+ const OUString &sConnectionDescription) :
+ m_rAcceptor( r ),
+ m_rBridgeFactory ( rFactory ),
+ m_sConnectionDescription( sConnectionDescription )
+ {}
+ virtual void SAL_CALL run();
+
+private:
+ Reference < XAcceptor > m_rAcceptor;
+ Reference < XBridgeFactory > m_rBridgeFactory;
+ OUString m_sConnectionDescription;
+};
+
+
+
+void MyThread::run()
+{
+
+ while ( sal_True )
+ {
+ try
+ {
+ Reference < XConnection > rConnection =
+ m_rAcceptor->accept( m_sConnectionDescription );
+
+ if( ! rConnection.is() )
+ {
+ break;
+ }
+
+ Reference < XBridge > rBridge =
+ m_rBridgeFactory->createBridge(
+ OUString() ,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("iiop")) ,
+ rConnection ,
+ (XInstanceProvider * ) new OInstanceProvider );
+
+
+ }
+ catch ( ... )
+ {
+ printf( "Exception was thrown by acceptor thread\n" );
+ break;
+ }
+ }
+}
+
+
+void main( int argc, char *argv[] )
+{
+ if( argc < 2 )
+ {
+ printf( "usage : testsamprocess host:port\n" );
+ exit(1 );
+ }
+
+ {
+#if SUPD>582
+ Reference< XMultiServiceFactory > rSMgr = createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "client.rdb" ) ) );
+#else
+ Reference< XMultiServiceFactory > rSMgr = createRegistryServiceFactory( "client.rdb" );
+#endif
+
+
+ Reference < XConnector > rConnector(
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("connectr")),
+ rSMgr ),
+ UNO_QUERY );
+
+ Reference < XAcceptor > rAcceptor(
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Acceptor")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("acceptor")),
+ rSMgr ),
+ UNO_QUERY );
+
+ // just ensure that it is registered
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.Bridge.iiop")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("iiopbrdg")),
+ rSMgr );
+
+ Reference < XBridgeFactory > rFactory(
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("brdgfctr")),
+ rSMgr ),
+ UNO_QUERY );
+
+
+ MyThread threadAcceptor( rAcceptor , rFactory , OUString::createFromAscii( argv[1] ) );
+
+ threadAcceptor.create();
+ TimeValue value={2,0};
+ osl_waitThread( &value );
+
+ try
+ {
+ Reference < XConnection > rConnection =
+ rConnector->connect( OUString::createFromAscii( argv[1] ) );
+
+ printf( "%s\n" , OUStringToOString( rConnection->getDescription(),
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+
+ if( rFactory.is() )
+ {
+
+ Reference < XBridge > rBridge = rFactory->createBridge(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bla blub")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("iiop")),
+ rConnection,
+ Reference < XInstanceProvider > () );
+
+ Reference < XInterface > rInitialObject
+ = rBridge->getInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("bla")) );
+
+ if( rInitialObject.is() )
+ {
+ printf( "got the remote object\n" );
+ testRemote( rInitialObject );
+ }
+ printf( "Closing...\n" );
+ TimeValue value={2,0};
+ osl_waitThread( &value );
+ }
+
+ Reference < XBridge > rBridge = rFactory->getBridge(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bla blub")) );
+ assert( ! rBridge.is() );
+
+ }
+ catch( Exception & )
+ {
+ printf( "Login failed, got an Exception !\n" );
+ }
+
+ rAcceptor->stopAccepting();
+ threadAcceptor.join();
+
+ Reference < XComponent > rComp( rFactory , UNO_QUERY );
+ rComp->dispose();
+
+
+ rComp = Reference < XComponent > ( rSMgr , UNO_QUERY );
+ rComp->dispose();
+ }
+}
diff --git a/bridges/test/testserver.cxx b/bridges/test/testserver.cxx
new file mode 100644
index 000000000000..48226762e9a5
--- /dev/null
+++ b/bridges/test/testserver.cxx
@@ -0,0 +1,293 @@
+/*************************************************************************
+ *
+ * $RCSfile: testserver.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:28:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <string.h>
+#include <assert.h>
+
+#include <osl/mutex.hxx>
+#include <osl/conditn.h>
+
+#include <vos/thread.hxx>
+#include <vos/socket.hxx>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/connection/XAcceptor.hpp>
+#include <com/sun/star/connection/XConnection.hpp>
+
+#include <com/sun/star/bridge/XInstanceProvider.hpp>
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+
+
+#include <test/XTestFactory.hpp>
+
+#include <cppuhelper/weak.hxx>
+
+using namespace ::test;
+using namespace ::rtl;
+using namespace ::vos;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::bridge;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::connection;
+#include "testcomp.h"
+#ifdef SAL_W32
+#include <conio.h>
+#endif
+
+/*********
+ *
+ ********/
+
+
+
+class MyThread :
+ public OThread
+{
+public:
+ MyThread( const Reference< XAcceptor > &r ,
+ const Reference< XBridgeFactory > &rFactory,
+ const Reference< XMultiServiceFactory > &rSMgr,
+ const OUString &sConnectionDescription,
+ const OUString &sProtocol,
+ sal_Bool bReverse,
+ sal_Bool bLatency ) :
+ m_rAcceptor( r ),
+ m_rBridgeFactory ( rFactory ),
+ m_sConnectionDescription( sConnectionDescription ),
+ m_sProtocol( sProtocol ),
+ m_bReverse( bReverse ),
+ m_bLatency( bLatency ),
+ m_rSMgr( rSMgr )
+ {}
+ virtual void SAL_CALL run();
+
+ void latencyTest( const Reference< XConnection > &r );
+
+private:
+ Reference < XAcceptor > m_rAcceptor;
+ Reference < XBridgeFactory > m_rBridgeFactory;
+ Reference < XMultiServiceFactory > m_rSMgr;
+ OUString m_sConnectionDescription;
+ OUString m_sProtocol;
+ sal_Bool m_bReverse;
+ sal_Bool m_bLatency;
+};
+
+
+void MyThread::latencyTest( const Reference< XConnection > &r )
+{
+ Sequence < sal_Int8 > s;
+ while( 12 == r->read( s , 12 ) )
+ {
+ r->read( s , 188 );
+ s = Sequence < sal_Int8 >(60);
+ r->write( s );
+ }
+}
+
+void MyThread::run()
+{
+
+ while ( sal_True )
+ {
+ try
+ {
+ Reference < XConnection > rConnection =
+ m_rAcceptor->accept( m_sConnectionDescription );
+
+ if( ! rConnection.is() )
+ {
+ break;
+ }
+ if( m_bLatency )
+ {
+ latencyTest( rConnection );
+ }
+ else
+ {
+
+ Reference < XBridge > rBridge =
+ m_rBridgeFactory->createBridge(
+ OUString() ,
+ m_sProtocol,
+ rConnection ,
+ (XInstanceProvider * ) new OInstanceProvider(m_rSMgr) );
+
+
+ if( m_bReverse )
+ {
+ printf( "doing reverse callme test (test is ok, when on each line a +- appears\n" );
+ Reference < XInterface > r = rBridge->getInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("blubber" )));
+ Reference < XTestFactory > rFactory( r , UNO_QUERY );
+ Reference < XCallMe > rCallMe = rFactory->createCallMe();
+
+ for( sal_Int32 i = 0 ; i < 1 ; i ++ )
+ {
+ rCallMe->callOneway(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("my test string")) , 2 );
+ }
+ printf( "all oneway are send\n" );
+ rCallMe->call( OUString::createFromAscii( "reverse call me test finished" ) , 0 );
+ printf( "revers callme test finished\n" );
+ }
+ }
+ }
+ catch ( Exception & e )
+ {
+ printf( "Exception was thrown by acceptor \n" );
+ OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US );
+ printf( "%s\n" , o.getStr() );
+ break;
+ }
+ catch ( ... )
+ {
+ printf( "Exception was thrown by acceptor thread\n" );
+ break;
+ }
+ }
+}
+
+
+#ifdef SOLARIS
+extern "C" void ChangeGlobalInit();
+#endif
+
+void main( int argc, char *argv[] )
+{
+// testserver();
+
+ if( argc < 2 )
+ {
+ printf( "usage : testserver [-r] connectionstring\n"
+ " -r does a reverse test (server calls client)\n" );
+ exit(1 );
+ }
+
+ OUString sConnectionString;
+ OUString sProtocol;
+ sal_Bool bReverse = sal_False;
+ sal_Bool bLatency = sal_False;
+
+ parseCommandLine( argv , &sConnectionString , &sProtocol , &bLatency , &bReverse );
+
+#ifdef SOLARIS
+ ChangeGlobalInit(); // Switch on threads !
+#endif
+
+ {
+ Reference< XMultiServiceFactory > rSMgr = createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "server.rdb" ) ) );
+
+ Reference < XBridgeFactory > rBridgeFactory ( createComponent(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("brdgfctr" )),
+ rSMgr ),
+ UNO_QUERY );
+
+
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.Bridge.iiop")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("iiopbrdg")),
+ rSMgr );
+
+
+ Reference < XAcceptor > rAcceptor(
+ createComponent( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Acceptor")),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("acceptor")),
+ rSMgr ) ,
+ UNO_QUERY );
+
+ MyThread thread( rAcceptor ,
+ rBridgeFactory,
+ rSMgr,
+ sConnectionString,
+ sProtocol,
+ bReverse,
+ bLatency);
+ thread.create();
+
+#ifdef SAL_W32
+ _getch();
+#elif SOLARIS
+ getchar();
+#elif LINUX
+ TimeValue value={360,0};
+ osl_waitThread( &value );
+#endif
+ printf( "Closing...\n" );
+
+ rAcceptor->stopAccepting();
+ thread.join();
+
+ printf( "Closed\n" );
+
+ Reference < XComponent > rComp2( rBridgeFactory , UNO_QUERY );
+ rComp2->dispose();
+ Reference < XComponent > rComp( rSMgr, UNO_QUERY );
+ rComp->dispose();
+ }
+}
diff --git a/bridges/version.mk b/bridges/version.mk
new file mode 100644
index 000000000000..a9c440164af3
--- /dev/null
+++ b/bridges/version.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# $RCSfile: version.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:28:47 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+# target
+RMCXT_TARGET=rmcxt
+
+# the major
+RMCXT_MAJOR=2
+# the minor
+RMCXT_MINOR=0
+# the micro
+RMCXT_MICRO=0
+
+# this is a c++ compatible library
+RMCXT_CPP=0
+
diff --git a/codemaker/inc/codemaker/global.hxx b/codemaker/inc/codemaker/global.hxx
new file mode 100644
index 000000000000..6eeb66576a78
--- /dev/null
+++ b/codemaker/inc/codemaker/global.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * $RCSfile: global.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:26 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#define _CODEMAKER_GLOBAL_HXX_
+
+#include <list>
+#include <vector>
+#include <set>
+
+#include <fstream.h>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _VOS_MACROS_HXX_
+#include <vos/macros.hxx>
+#endif
+
+
+struct EqualString
+{
+ sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
+ {
+ return (str1 == str2);
+ }
+};
+
+struct HashString
+{
+ size_t operator()(const ::rtl::OString& str) const
+ {
+ return str.hashCode();
+ }
+};
+
+struct LessString
+{
+ sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
+ {
+ return (str1 < str2);
+ }
+};
+
+#if defined(_MSC_VER) && _MSC_VER < 1200
+typedef NAMESPACE_STD(new_alloc) NewAlloc;
+#endif
+
+
+typedef NAMESPACE_STD(list) < ::rtl::OString > StringList;
+typedef NAMESPACE_STD(vector)< ::rtl::OString > StringVector;
+typedef NAMESPACE_STD(set) < ::rtl::OString, LessString > StringSet;
+
+::rtl::OString makeTempName(sal_Char* prefix);
+
+::rtl::OString createFileNameFromType(const ::rtl::OString& destination,
+ const ::rtl::OString type,
+ const ::rtl::OString postfix,
+ sal_Bool bLowerCase=sal_False,
+ const ::rtl::OString prefix="");
+
+sal_Bool fileExists(const ::rtl::OString& fileName);
+sal_Bool checkFileContent(const ::rtl::OString& targetFileName, const ::rtl::OString& tmpFileName);
+
+const ::rtl::OString inGlobalSet(const ::rtl::OUString & r);
+inline const ::rtl::OString inGlobalSet(sal_Char* p)
+{
+ return inGlobalSet( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(p) ) );
+}
+
+//*************************************************************************
+// FileStream
+//*************************************************************************
+class FileStream : public ofstream
+{
+public:
+ FileStream();
+ FileStream(const ::rtl::OString& name, sal_Int32 nMode = ios::out | ios::trunc);
+ virtual ~FileStream();
+
+ sal_Bool isValid();
+
+ void openFile(const ::rtl::OString& name, sal_Int32 nMode = ios::out | ios::trunc);
+ void closeFile();
+
+ sal_Int32 getSize();
+ ::rtl::OString getName() { return m_name; }
+protected:
+ ::rtl::OString m_name;
+};
+
+#endif // _CODEMAKER_GLOBAL_HXX_
+
diff --git a/codemaker/inc/codemaker/options.hxx b/codemaker/inc/codemaker/options.hxx
new file mode 100644
index 000000000000..e7553f9fcd33
--- /dev/null
+++ b/codemaker/inc/codemaker/options.hxx
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * $RCSfile: options.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:26 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_OPTIONS_HXX_
+#define _CODEMAKER_OPTIONS_HXX_
+
+#include <hash_map>
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#include <codemaker/global.hxx>
+#endif
+
+#if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString,
+ ::rtl::OString,
+ HashString,
+ EqualString,
+ NewAlloc
+> OptionMap;
+#else
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString,
+ ::rtl::OString,
+ HashString,
+ EqualString
+> OptionMap;
+#endif
+
+class CannotDumpException
+{
+public:
+ CannotDumpException(const ::rtl::OString& msg)
+ : m_message(msg) {}
+
+ ::rtl::OString m_message;
+};
+
+
+class IllegalArgument
+{
+public:
+ IllegalArgument(const ::rtl::OString& msg)
+ : m_message(msg) {}
+
+ ::rtl::OString m_message;
+};
+
+
+class Options
+{
+public:
+ Options();
+ ~Options();
+
+ virtual sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
+ throw( IllegalArgument ) = 0;
+
+ virtual ::rtl::OString prepareHelp() = 0;
+
+ const ::rtl::OString& getProgramName() const;
+ sal_uInt16 getNumberOfOptions() const;
+ sal_Bool isValid(const ::rtl::OString& option);
+ const ::rtl::OString getOption(const ::rtl::OString& option)
+ throw( IllegalArgument );
+ const OptionMap& getOptions();
+
+ sal_uInt16 getNumberOfInputFiles() const;
+ const ::rtl::OString getInputFile(sal_uInt16 index)
+ throw( IllegalArgument );
+
+ const StringVector& getInputFiles();
+
+protected:
+ ::rtl::OString m_program;
+ StringVector m_inputFiles;
+ OptionMap m_options;
+};
+
+#endif // _CODEMAKER_OPTIONS_HXX_
+
diff --git a/codemaker/inc/codemaker/typemanager.hxx b/codemaker/inc/codemaker/typemanager.hxx
new file mode 100644
index 000000000000..593e432c8ae9
--- /dev/null
+++ b/codemaker/inc/codemaker/typemanager.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * $RCSfile: typemanager.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:26 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <hash_map>
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#define _CODEMAKER_TYPEMANAGER_HXX_
+
+#ifndef _CODEMAKER_REGISTRY_HXX_
+#include <codemaker/registry.hxx>
+#endif
+
+RegistryTypeReaderLoader & getRegistryTypeReaderLoader();
+
+
+typedef NAMESPACE_STD(list) <Registry*> RegistryList;
+
+#if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString, // Typename
+ RTTypeClass, // TypeClass
+ HashString,
+ EqualString,
+ NewAlloc
+> T2TypeClassMap;
+#else
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString, // Typename
+ RTTypeClass, // TypeClass
+ HashString,
+ EqualString
+> T2TypeClassMap;
+#endif
+
+struct TypeManagerImpl
+{
+ TypeManagerImpl()
+ : m_refCount(0)
+ {}
+
+ sal_Int32 m_refCount;
+};
+
+class TypeManager
+{
+public:
+ TypeManager();
+ ~TypeManager();
+
+ TypeManager( const TypeManager& value )
+ : m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+
+ TypeManager& operator = ( const TypeManager& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+
+ virtual sal_Bool init(sal_Bool bMerge, const StringVector& regFiles)
+ { return sal_False; }
+ virtual sal_Bool init(const ::rtl::OString& registryName)
+ { return sal_False; }
+
+ virtual sal_Bool isValidType(const ::rtl::OString& name)
+ { return sal_False; }
+
+ virtual RegistryKey getTypeKey(const ::rtl::OString& name)
+ { return RegistryKey(); }
+ virtual TypeReader getTypeReader(const ::rtl::OString& name)
+ { return TypeReader(); }
+ virtual RTTypeClass getTypeClass(const ::rtl::OString& name)
+ { return RT_TYPE_INVALID; }
+
+ virtual void setBase(const ::rtl::OString& base) {}
+ virtual ::rtl::OString getBase() { return ::rtl::OString(); }
+
+ virtual sal_Int32 getSize() { return 0; }
+
+protected:
+ sal_Int32 acquire();
+ sal_Int32 release();
+
+protected:
+ TypeManagerImpl* m_pImpl;
+};
+
+struct RegistryTypeManagerImpl
+{
+ RegistryTypeManagerImpl()
+ : m_pMergedRegistry(NULL)
+ , m_isMerged(sal_False)
+ , m_base("/")
+ {}
+
+ T2TypeClassMap m_t2TypeClass;
+ RegistryList m_registries;
+ Registry* m_pMergedRegistry;
+ ::rtl::OString m_base;
+ sal_Bool m_isMerged;
+};
+
+class RegistryTypeManager : public TypeManager
+{
+public:
+ RegistryTypeManager();
+ ~RegistryTypeManager();
+
+ RegistryTypeManager( const RegistryTypeManager& value )
+ : TypeManager(value)
+ , m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+/*
+ RegistryTypeManager& operator = ( const RegistryTypeManager& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+*/
+ sal_Bool init(sal_Bool bMerge, const StringVector& regFiles);
+
+ sal_Bool isValidType(const ::rtl::OString& name)
+ { return searchTypeKey(name).isValid(); }
+ RegistryKey getTypeKey(const ::rtl::OString& name)
+ { return searchTypeKey(name); }
+ TypeReader getTypeReader(const ::rtl::OString& name);
+ RTTypeClass getTypeClass(const ::rtl::OString& name);
+
+ void setBase(const ::rtl::OString& base);
+ ::rtl::OString getBase() { return m_pImpl->m_base; }
+
+ sal_Int32 getSize() { return m_pImpl->m_t2TypeClass.size(); }
+protected:
+ RegistryKey searchTypeKey(const ::rtl::OString& name);
+ void freeRegistries();
+
+ void acquire();
+ void release();
+
+protected:
+ RegistryTypeManagerImpl* m_pImpl;
+};
+
+#endif // _CODEMAKER_TYPEMANAGER_HXX_
diff --git a/codemaker/prj/d.lst b/codemaker/prj/d.lst
new file mode 100644
index 000000000000..4c6d45c5d177
--- /dev/null
+++ b/codemaker/prj/d.lst
@@ -0,0 +1,8 @@
+..\%__SRC%\bin\cppumaker.exe %_DEST%\bin%_EXT%\cppumaker.exe
+..\%__SRC%\bin\cppumaker.pdb %_DEST%\bin%_EXT%\cppumaker.pdb
+..\%__SRC%\bin\javamaker.exe %_DEST%\bin%_EXT%\javamaker.exe
+..\%__SRC%\bin\javamaker.pdb %_DEST%\bin%_EXT%\javamaker.pdb
+
+..\%__SRC%\bin\cppumaker %_DEST%\bin%_EXT%\cppumaker
+..\%__SRC%\bin\javamaker %_DEST%\bin%_EXT%\javamaker
+
diff --git a/codemaker/source/codemaker/global.cxx b/codemaker/source/codemaker/global.cxx
new file mode 100644
index 000000000000..83d0366dffaa
--- /dev/null
+++ b/codemaker/source/codemaker/global.cxx
@@ -0,0 +1,377 @@
+/*************************************************************************
+ *
+ * $RCSfile: global.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+#ifndef _RTL_OSTRINGBUFFER_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#if defined(SAL_W32) || defined(SAL_OS2)
+#include <io.h>
+#include <direct.h>
+#include <errno.h>
+#endif
+
+#ifdef UNX
+#include <sys/stat.h>
+#include <errno.h>
+#include <unistd.h>
+#endif
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#include <codemaker/global.hxx>
+#endif
+
+using namespace vos;
+using namespace rtl;
+
+OString makeTempName(sal_Char* prefix)
+{
+ static OUString uTMP( RTL_CONSTASCII_USTRINGPARAM("TMP") );
+ static OUString uTEMP( RTL_CONSTASCII_USTRINGPARAM("TEMP") );
+ OUString uPrefix( RTL_CONSTASCII_USTRINGPARAM("cmk_") );
+ OUString uPattern;
+
+ sal_Char* pPrefix = "cmk_";
+ sal_Char tmpPattern[512];
+ sal_Char *pTmpName = NULL;
+
+ if (prefix)
+ pPrefix = prefix;
+
+ OStartupInfo StartupInfo;
+
+ if (StartupInfo.getEnvironment(uTMP, uPattern) != OStartupInfo::E_None)
+ {
+ if (StartupInfo.getEnvironment(uTEMP, uPattern) != OStartupInfo::E_None)
+ {
+#if defined(WIN32) || defined(WNT) || defined(OS2)
+ strcpy(tmpPattern, ".");
+#else
+ strcpy(tmpPattern, "/tmp");
+#endif
+ }
+ }
+
+ if (uPattern.getLength())
+ {
+ strcpy(tmpPattern, OUStringToOString(uPattern, RTL_TEXTENCODING_UTF8).getStr());
+ }
+
+#ifdef SAL_W32
+ strcat(tmpPattern, "\\");
+ strcat(tmpPattern, pPrefix);
+ strcat(tmpPattern, "XXXXXX");
+ pTmpName = mktemp(tmpPattern);
+#endif
+
+#ifdef SAL_OS2
+ strcpy(tmpPattern, tempnam(NULL, prefix);
+ pTmpName = tmpPattern;
+#endif
+
+#ifdef SAL_UNX
+ strcat(tmpPattern, "\\");
+ strcat(tmpPattern, pPrefix);
+ strcat(tmpPattern, "XXXXXX");
+ pTmpName = mktemp(tmpPattern);
+#endif
+
+ return OString(pTmpName);
+}
+
+OString createFileNameFromType( const OString& destination,
+ const OString typeName,
+ const OString postfix,
+ sal_Bool bLowerCase,
+ const OString prefix )
+{
+ OString type(typeName);
+
+ if (bLowerCase)
+ {
+ type = typeName.toLowerCase();
+ }
+
+ sal_uInt32 length = destination.getLength();
+
+ sal_Bool withPoint = sal_False;
+ if (length == 0)
+ {
+ length++;
+ withPoint = sal_True;
+ }
+
+ length += prefix.getLength() + type.getLength() + postfix.getLength();
+
+ sal_Bool withSeperator = sal_False;
+ if (destination.getStr()[destination.getLength()] != '\\' &&
+ destination.getStr()[destination.getLength()] != '/' &&
+ type.getStr()[0] != '\\' &&
+ type.getStr()[0] != '/')
+ {
+ length++;
+ withSeperator = sal_True;
+ }
+
+ OStringBuffer nameBuffer(length);
+
+ if (withPoint)
+ nameBuffer.append('.');
+ else
+ nameBuffer.append(destination.getStr(), destination.getLength());
+
+ if (withSeperator)
+ nameBuffer.append("/", 1);
+
+ OString tmpStr(type);
+ if (prefix.getLength() > 0)
+ {
+ tmpStr = type.replaceAt(type.lastIndexOf('/')+1, 0, prefix);
+ }
+
+ nameBuffer.append(tmpStr.getStr(), tmpStr.getLength());
+ nameBuffer.append(postfix.getStr(), postfix.getLength());
+
+ OString fileName(nameBuffer);
+
+ sal_Char token;
+#ifdef SAL_UNX
+ fileName = fileName.replace('\\', '/');
+ token = '/';
+#else
+ fileName = fileName.replace('/', '\\');
+ token = '\\';
+#endif
+
+ sal_Int32 count = fileName.getTokenCount(token) - 1;
+
+ nameBuffer = OStringBuffer(length);
+
+ for (int i=0; i < count; i++)
+ {
+ nameBuffer.append(fileName.getToken(i, token).getStr());
+
+ if (nameBuffer.getLength() == 0 || OString(".") == nameBuffer.getStr())
+ {
+ nameBuffer.append(token);
+ continue;
+ }
+
+#ifdef SAL_UNX
+ if (mkdir((char*)nameBuffer.getStr(), 0777) == -1)
+#else
+ if (mkdir((char*)nameBuffer.getStr()) == -1)
+#endif
+ {
+// #if __SUNPRO_CC >= 0x500
+// if( * ::___errno() == ENOENT )
+// #else
+ if ( errno == ENOENT )
+// #endif
+ return OString();
+ }
+
+ nameBuffer.append(token);
+ }
+
+ return fileName;
+}
+
+sal_Bool fileExists(const OString& fileName)
+{
+ FILE *f= fopen(fileName.getStr(), "r");
+
+ if (f != NULL)
+ {
+ fclose(f);
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+sal_Bool checkFileContent(const OString& targetFileName, const OString& tmpFileName)
+{
+ FILE *target = fopen(targetFileName.getStr(), "r");
+ FILE *tmp = fopen(tmpFileName.getStr(), "r");
+ sal_Bool ret = sal_False;
+
+ if (target != NULL && tmp != NULL)
+ {
+ sal_Bool bFindChanges = sal_False;
+ sal_Char buffer1[1024+1];
+ sal_Char buffer2[1024+1];
+ sal_Int32 n1 = 0;
+ sal_Int32 n2 = 0;
+
+ while ( !bFindChanges && !feof(target) && !feof(tmp))
+ {
+ n1 = fread(buffer1, sizeof(sal_Char), 1024, target);
+ n2 = fread(buffer2, sizeof(sal_Char), 1024, tmp);
+
+ if ( n1 != n2 )
+ {
+ bFindChanges = sal_True;
+ }
+ else
+ {
+ if ( rtl_compareMemory(buffer1, buffer2, n2) != 0 )
+ bFindChanges = sal_True;
+ }
+ }
+
+ fclose(target);
+ fclose(tmp);
+
+ if ( bFindChanges )
+ {
+ if ( !unlink(targetFileName.getStr()) )
+ if ( !rename(targetFileName.getStr(), tmpFileName.getStr()) )
+ ret = sal_True;
+ }
+ else
+ {
+ if ( !unlink(tmpFileName.getStr()) )
+ ret = sal_True;
+ }
+ }
+
+ return ret;
+}
+
+const OString inGlobalSet(const OUString & rValue)
+{
+ OString sValue( OUStringToOString(rValue, RTL_TEXTENCODING_UTF8) );
+ static StringSet aGlobalMap;
+ StringSet::iterator iter = aGlobalMap.find( sValue );
+ if( iter != aGlobalMap.end() )
+ return *iter;
+ return *(aGlobalMap.insert( sValue ).first);
+}
+
+
+//*************************************************************************
+// FileStream
+//*************************************************************************
+FileStream::FileStream()
+{
+}
+
+FileStream::FileStream(const OString& name, sal_Int32 nMode)
+ : ofstream(name, nMode)
+ , m_name(name)
+{
+}
+
+FileStream::~FileStream()
+{
+ flush();
+ close();
+}
+
+sal_Bool FileStream::isValid()
+{
+#if defined(SAL_UNX) || defined(SAL_OS2)
+ if(rdbuf()->fd() < 0)
+#else
+ if(fd() < 0)
+#endif
+ {
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+void FileStream::openFile(const OString& name, sal_Int32 nMode)
+{
+ if ( name.getLength() > 0 )
+ m_name = name;
+
+ if ( m_name.getLength() > 0 )
+ open(m_name, nMode);
+}
+
+void FileStream::closeFile()
+{
+ flush();
+ close();
+}
+
+sal_Int32 FileStream::getSize()
+{
+ flush();
+
+ FILE* f = fopen(m_name, "r");
+ sal_Int32 size = 0;
+ if (!fseek(f, 0, SEEK_END))
+ size = ftell(f);
+ fclose(f);
+ return size;
+}
+
diff --git a/codemaker/source/codemaker/makefile.mk b/codemaker/source/codemaker/makefile.mk
new file mode 100644
index 000000000000..e226fee6cdeb
--- /dev/null
+++ b/codemaker/source/codemaker/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=codemaker
+TARGET=$(PRJNAME)
+
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+CXXFILES= \
+ global.cxx \
+ options.cxx \
+ typemanager.cxx \
+ dependency.cxx
+
+OBJFILES= \
+ $(OBJ)$/global.obj \
+ $(OBJ)$/options.obj \
+ $(OBJ)$/typemanager.obj \
+ $(OBJ)$/dependency.obj
+
+# ------------------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/codemaker/source/codemaker/options.cxx b/codemaker/source/codemaker/options.cxx
new file mode 100644
index 000000000000..0ef959c45e71
--- /dev/null
+++ b/codemaker/source/codemaker/options.cxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: options.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_OPTIONS_HXX_
+#include <codemaker/options.hxx>
+#endif
+
+using namespace rtl;
+
+Options::Options()
+{
+}
+
+Options::~Options()
+{
+
+}
+
+const OString& Options::getProgramName() const
+{
+ return m_program;
+}
+
+sal_uInt16 Options::getNumberOfOptions() const
+{
+ return m_options.size();
+}
+
+sal_Bool Options::isValid(const OString& option)
+{
+ return (m_options.count(option) > 0);
+}
+
+const OString Options::getOption(const OString& option)
+ throw( IllegalArgument )
+{
+ const OString ret;
+
+ if (m_options.count(option) > 0)
+ {
+ return m_options[option];
+ } else
+ {
+ throw IllegalArgument("Option is not valid or currently not set.");
+ }
+
+ return ret;
+}
+
+const OptionMap& Options::getOptions()
+{
+ return m_options;
+}
+
+sal_uInt16 Options::getNumberOfInputFiles() const
+{
+ return m_inputFiles.size();
+}
+
+const OString Options::getInputFile(sal_uInt16 index)
+ throw( IllegalArgument )
+{
+ const OString ret;
+
+ if (index < m_inputFiles.size())
+ {
+ return m_inputFiles[index];
+ } else
+ {
+ throw IllegalArgument("index is out of bound.");
+ }
+
+ return ret;
+}
+
+const StringVector& Options::getInputFiles()
+{
+ return m_inputFiles;
+}
+
diff --git a/codemaker/source/codemaker/typemanager.cxx b/codemaker/source/codemaker/typemanager.cxx
new file mode 100644
index 000000000000..2e8e37cb36b4
--- /dev/null
+++ b/codemaker/source/codemaker/typemanager.cxx
@@ -0,0 +1,322 @@
+/*************************************************************************
+ *
+ * $RCSfile: typemanager.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+using namespace rtl;
+
+RegistryTypeReaderLoader & getRegistryTypeReaderLoader()
+{
+ static RegistryTypeReaderLoader aLoader;
+ return aLoader;
+}
+
+TypeManager::TypeManager()
+{
+ m_pImpl = new TypeManagerImpl();
+ acquire();
+}
+
+TypeManager::~TypeManager()
+{
+ release();
+}
+
+sal_Int32 TypeManager::acquire()
+{
+ return osl_incrementInterlockedCount(&m_pImpl->m_refCount);
+}
+
+sal_Int32 TypeManager::release()
+{
+ sal_Int32 refCount = 0;
+ if (0 == (refCount = osl_decrementInterlockedCount(&m_pImpl->m_refCount)) )
+ {
+ delete m_pImpl;
+ }
+ return refCount;;
+}
+
+RegistryTypeManager::RegistryTypeManager()
+{
+ m_pImpl = new RegistryTypeManagerImpl();
+ acquire();
+}
+
+RegistryTypeManager::~RegistryTypeManager()
+{
+ release();
+}
+
+void RegistryTypeManager::acquire()
+{
+ TypeManager::acquire();
+}
+
+void RegistryTypeManager::release()
+{
+ if (0 == TypeManager::release())
+ {
+ if (m_pImpl->m_pMergedRegistry)
+ {
+ if (m_pImpl->m_pMergedRegistry->isValid())
+ {
+ m_pImpl->m_pMergedRegistry->destroy(OUString());
+ }
+
+ delete m_pImpl->m_pMergedRegistry;
+ }
+
+ if (m_pImpl->m_registries.size() > 0)
+ {
+ freeRegistries();
+ }
+
+ delete m_pImpl;
+ }
+}
+
+sal_Bool RegistryTypeManager::init(sal_Bool bMerged, const StringVector& regFiles)
+{
+ m_pImpl->m_isMerged = bMerged && (regFiles.size() > 1);
+
+ if (regFiles.empty())
+ return sal_False;
+
+ StringVector::const_iterator iter = regFiles.begin();
+
+ RegistryLoader loader;
+ Registry tmpReg(loader);
+ while (iter != regFiles.end())
+ {
+ if (!tmpReg.open( OStringToOUString(*iter, RTL_TEXTENCODING_UTF8), REG_READONLY))
+ m_pImpl->m_registries.push_back(new Registry(tmpReg));
+ else
+ {
+ freeRegistries();
+ return sal_False;
+ }
+ iter++;
+ }
+
+ if (m_pImpl->m_isMerged)
+ {
+ Registry *pTmpReg = new Registry(loader);
+ OString tmpName(makeTempName(NULL));
+
+ if (!pTmpReg->create( OStringToOUString(tmpName, RTL_TEXTENCODING_UTF8) ) )
+ {
+ RegistryKey rootKey;
+ RegError ret = REG_NO_ERROR;
+ OUString aRoot( RTL_CONSTASCII_USTRINGPARAM("/") );
+ iter = regFiles.begin();
+ pTmpReg->openRootKey(rootKey);
+
+ while (iter != regFiles.end())
+ {
+ if ( ret = pTmpReg->mergeKey(rootKey, aRoot, OUString::createFromAscii( *iter )) )
+ {
+ if (ret != REG_MERGE_CONFLICT)
+ {
+ freeRegistries();
+ rootKey.closeKey();
+ pTmpReg->destroy( OUString() );
+ delete pTmpReg;
+ return sal_False;
+ }
+ }
+ iter++;
+ }
+
+ m_pImpl->m_pMergedRegistry = pTmpReg;
+ freeRegistries();
+ } else
+ {
+ delete pTmpReg;
+ freeRegistries();
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+TypeReader RegistryTypeManager::getTypeReader(const OString& name)
+{
+ TypeReader reader;
+ RegistryKey key(searchTypeKey(name));
+
+ if (key.isValid())
+ {
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ reader = TypeReader(rReaderLoader, pBuffer, valueSize, sal_True);
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ }
+ return reader;
+}
+
+RTTypeClass RegistryTypeManager::getTypeClass(const OString& name)
+{
+ if (m_pImpl->m_t2TypeClass.count(name) > 0)
+ {
+ return m_pImpl->m_t2TypeClass[name];
+ } else
+ {
+ RegistryKey key(searchTypeKey(name));
+
+ if (key.isValid())
+ {
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_False);
+
+ RTTypeClass ret = reader.getTypeClass();
+
+ rtl_freeMemory(pBuffer);
+
+ m_pImpl->m_t2TypeClass[name] = ret;
+ return ret;
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ }
+ }
+
+ return RT_TYPE_INVALID;
+}
+
+void RegistryTypeManager::setBase(const OString& base)
+{
+ m_pImpl->m_base = base;
+
+ if (base.lastIndexOf('/') != (base.getLength() - 1))
+ {
+ m_pImpl->m_base += "/";
+ }
+}
+
+void RegistryTypeManager::freeRegistries()
+{
+ RegistryList::const_iterator iter = m_pImpl->m_registries.begin();
+
+ while (iter != m_pImpl->m_registries.end())
+ {
+ delete *iter;
+
+ iter++;
+ }
+
+}
+
+RegistryKey RegistryTypeManager::searchTypeKey(const OString& name)
+{
+ RegistryKey key, rootKey;
+
+ if (m_pImpl->m_isMerged)
+ {
+ if (!m_pImpl->m_pMergedRegistry->openRootKey(rootKey))
+ {
+ rootKey.openKey(OStringToOUString(m_pImpl->m_base + name, RTL_TEXTENCODING_UTF8), key);
+ }
+ } else
+ {
+ RegistryList::const_iterator iter = m_pImpl->m_registries.begin();
+
+ while (iter != m_pImpl->m_registries.end())
+ {
+ if (!(*iter)->openRootKey(rootKey))
+ {
+ if (!rootKey.openKey(OStringToOUString(m_pImpl->m_base + name, RTL_TEXTENCODING_UTF8), key))
+ break;
+ }
+
+ iter++;
+ }
+ }
+
+ return key;
+}
+
diff --git a/codemaker/source/cppumaker/cppumaker.cxx b/codemaker/source/cppumaker/cppumaker.cxx
new file mode 100644
index 000000000000..92084608d216
--- /dev/null
+++ b/codemaker/source/cppumaker/cppumaker.cxx
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * $RCSfile: cppumaker.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+#include "cppuoptions.hxx"
+#include "cpputype.hxx"
+
+using namespace rtl;
+
+sal_Bool produceAllTypes(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ CppuOptions* pOptions,
+ sal_Bool bFullScope)
+ throw( CannotDumpException )
+{
+ if (!produceType(typeName, typeMgr, typeDependencies, pOptions))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+
+ RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+ RegistryKeyNames subKeys;
+
+ if (typeKey.getKeyNames(OUString(), subKeys))
+ return sal_False;
+
+ OString tmpName;
+ for (sal_uInt32 i=0; i < subKeys.getLength(); i++)
+ {
+ tmpName = OUStringToOString(subKeys.getElement(i), RTL_TEXTENCODING_UTF8);
+
+ if (pOptions->isValid("-B"))
+ tmpName = tmpName.copy(tmpName.indexOf('/', 1) + 1);
+ else
+ tmpName = tmpName.copy(1);
+
+ if (bFullScope)
+ {
+ if (!produceAllTypes(tmpName, typeMgr, typeDependencies, pOptions, sal_True))
+ return sal_False;
+ } else
+ {
+ if (!produceType(tmpName, typeMgr, typeDependencies, pOptions))
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ CppuOptions options;
+
+ try
+ {
+ if (!options.initOptions(argc, argv))
+ {
+ exit(1);
+ }
+ }
+ catch( IllegalArgument& e)
+ {
+ fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr());
+ exit(99);
+ }
+
+ RegistryTypeManager typeMgr;
+ TypeDependency typeDependencies;
+
+ if (!typeMgr.init(!options.isValid("-T"), options.getInputFiles()))
+ {
+ fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr());
+ exit(99);
+ }
+
+ if (options.isValid("-B"))
+ {
+ typeMgr.setBase(options.getOption("-B"));
+ }
+
+ try
+ {
+ if (options.isValid("-T"))
+ {
+ OString tOption(options.getOption("-T"));
+ sal_uInt32 count = tOption.getTokenCount(';');
+
+ OString typeName, tmpName;
+ sal_Bool ret = sal_False;
+ for (sal_uInt32 i = 0; i < count; i++)
+ {
+ typeName = tOption.getToken(i, ';');
+
+ tmpName = typeName.getToken(typeName.getTokenCount('.') - 1, '.');
+ if (tmpName == "*")
+ {
+ // produce this type and his scope, but the scope is not recursively generated.
+ if (typeName.equals("*"))
+ {
+ tmpName = "/";
+ } else
+ {
+ tmpName = typeName.copy(0, typeName.lastIndexOf('.')).replace('.', '/');
+ if (tmpName.getLength() == 0)
+ tmpName = "/";
+ else
+ tmpName.replace('.', '/');
+ }
+ ret = produceAllTypes(tmpName, typeMgr, typeDependencies, &options, sal_False);
+ } else
+ {
+ // produce only this type
+ ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies, &options);
+ }
+
+ if (!ret)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+ }
+ } else
+ {
+ // produce all types
+ if (!produceAllTypes("/", typeMgr, typeDependencies, &options, sal_True))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "an error occurs while dumping all types.");
+ exit(99);
+ }
+ }
+ }
+ catch( CannotDumpException& e)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ e.m_message.getStr());
+ exit(99);
+ }
+
+ return 0;
+}
+
+
diff --git a/codemaker/source/cppumaker/cppuoptions.cxx b/codemaker/source/cppumaker/cppuoptions.cxx
new file mode 100644
index 000000000000..dc025cb0a0c7
--- /dev/null
+++ b/codemaker/source/cppumaker/cppuoptions.cxx
@@ -0,0 +1,340 @@
+/*************************************************************************
+ *
+ * $RCSfile: cppuoptions.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdio.h>
+
+#include "cppuoptions.hxx"
+
+using namespace rtl;
+
+sal_Bool CppuOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile)
+ throw( IllegalArgument )
+{
+ sal_Bool ret = sal_True;
+ sal_uInt16 i=0;
+
+ if (!bCmdFile)
+ {
+ bCmdFile = sal_True;
+
+ m_program = av[0];
+
+ if (ac < 2)
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ }
+
+ i = 1;
+ } else
+ {
+ i = 0;
+ }
+
+ char *s=NULL;
+ for (i; i < ac; i++)
+ {
+ if (av[i][0] == '-')
+ {
+ switch (av[i][1])
+ {
+ case 'O':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-O', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-O"] = OString(s);
+ break;
+ case 'B':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-B', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-B"] = OString(s);
+ break;
+ case 'T':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-T', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ if (m_options.count("-T") > 0)
+ {
+ OString tmp(m_options["-T"]);
+ tmp = tmp + ";" + s;
+ m_options["-T"] = tmp;
+ } else
+ {
+ m_options["-T"] = OString(s);
+ }
+ break;
+ case 'L':
+ if (av[i][2] != '\0')
+ {
+ OString tmp("'-C', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ if (isValid("-C") || isValid("-CS"))
+ {
+ OString tmp("'-L' could not be combined with '-C' or '-CS' option");
+ throw IllegalArgument(tmp);
+ }
+ m_options["-L"] = OString("");
+ break;
+ case 'C':
+ if (av[i][2] == 'S')
+ {
+ if (av[i][3] != '\0')
+ {
+ OString tmp("'-CS', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ if (isValid("-L") || isValid("-C"))
+ {
+ OString tmp("'-CS' could not be combined with '-L' or '-C' option");
+ throw IllegalArgument(tmp);
+ }
+ m_options["-CS"] = OString("");
+ break;
+ } else
+ if (av[i][2] != '\0')
+ {
+ OString tmp("'-C', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ if (isValid("-L") || isValid("-CS"))
+ {
+ OString tmp("'-C' could not be combined with '-L' or '-CS' option");
+ throw IllegalArgument(tmp);
+ }
+ m_options["-C"] = OString("");
+ break;
+ case 'G':
+ if (av[i][2] == 'c')
+ {
+ if (av[i][3] != '\0')
+ {
+ OString tmp("'-Gc', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ m_options["-Gc"] = OString("");
+ break;
+ } else
+ if (av[i][2] != '\0')
+ {
+ OString tmp("'-G', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ m_options["-G"] = OString("");
+ break;
+ default:
+ throw IllegalArgument("the option is unknown" + OString(av[i]));
+ break;
+ }
+ } else
+ {
+ if (av[i][0] == '@')
+ {
+ FILE* cmdFile = fopen(av[i]+1, "r");
+ if( cmdFile == NULL )
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ } else
+ {
+ int rargc=0;
+ char* rargv[512];
+ char buffer[512];
+
+ while ( fscanf(cmdFile, "%s", buffer) != EOF )
+ {
+ rargv[rargc]= strdup(buffer);
+ rargc++;
+ }
+ fclose(cmdFile);
+
+ ret = initOptions(rargc, rargv, bCmdFile);
+
+ for (long i=0; i < rargc; i++)
+ {
+ free(rargv[i]);
+ }
+ }
+ } else
+ {
+ m_inputFiles.push_back(av[i]);
+ }
+ }
+ }
+
+ return ret;
+}
+
+OString CppuOptions::prepareHelp()
+{
+ OString help("\nusing: ");
+ help += m_program + " [-options] file_1 ... file_n\nOptions:\n";
+ help += " -O<path> = path describes the root directory for the generated output.\n";
+ help += " The output directory tree is generated under this directory.\n";
+ help += " -T<name> = name specifies a type or a list of types. The output for this\n";
+ help += " [t1;...] type is generated. If no '-T' option is specified,\n";
+ help += " then output for all types is generated.\n";
+ help += " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
+ help += " -B<name> = name specifies the base node. All types are searched under this\n";
+ help += " node. Default is the root '/' of the registry files.\n";
+ help += " -L = getCppuType function with a known leak.\n";
+ help += " -C = getCppuType function keeps comprehensive type information.\n";
+ help += " -CS = getCppuType function keeps comprehensive type information (static version).\n";
+ help += " -G = generate only target files which does not exists.\n";
+ help += " -Gc = generate only target files which content will be changed.\n";
+ help += prepareVersion();
+
+ return help;
+}
+
+OString CppuOptions::prepareVersion()
+{
+ OString version("\nSun Microsystems (R) ");
+ version += m_program + " Version 2.0\n\n";
+
+ return version;
+}
+
+
diff --git a/codemaker/source/cppumaker/cppuoptions.hxx b/codemaker/source/cppumaker/cppuoptions.hxx
new file mode 100644
index 000000000000..ee7744a6944e
--- /dev/null
+++ b/codemaker/source/cppumaker/cppuoptions.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * $RCSfile: cppuoptions.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUMAKER_CPPUOPTIONS_HXX_
+#define _CPPUMAKER_CPPUOPTIONS_HXX_
+
+#include <codemaker/options.hxx>
+
+class CppuOptions : public Options
+{
+public:
+ CppuOptions()
+ : Options() {}
+
+ ~CppuOptions() {}
+
+ sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
+ throw( IllegalArgument );
+
+ ::rtl::OString prepareHelp();
+
+ ::rtl::OString prepareVersion();
+
+protected:
+};
+
+#endif // _CPPUMAKER_CPPUOPTIONS_HXX_
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
new file mode 100644
index 000000000000..3fdcc1e72c11
--- /dev/null
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -0,0 +1,3838 @@
+/*************************************************************************
+ *
+ * $RCSfile: cpputype.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#include "cpputype.hxx"
+#include "cppuoptions.hxx"
+
+using namespace rtl;
+
+//*************************************************************************
+// CppuType
+//*************************************************************************
+CppuType::CppuType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : m_inheritedMemberCount(0)
+ , m_cppuTypeLeak(sal_False)
+ , m_cppuTypeDynamic(sal_True)
+ , m_cppuTypeStatic(sal_False)
+ , m_indentLength(0)
+ , m_typeName(typeName)
+ , m_name(typeName.getToken(typeName.getTokenCount('/') - 1, '/'))
+ , m_reader(typeReader)
+ , m_typeMgr((TypeManager&)typeMgr)
+ , m_dependencies(typeDependencies)
+{
+}
+
+CppuType::~CppuType()
+{
+
+}
+
+sal_Bool CppuType::dump(CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_False;
+
+ if (pOptions->isValid("-L"))
+ m_cppuTypeLeak = sal_True;
+ if (pOptions->isValid("-C"))
+ m_cppuTypeDynamic = sal_False;
+ if (pOptions->isValid("-CS"))
+ {
+ m_cppuTypeDynamic = sal_False;
+ m_cppuTypeStatic = sal_True;
+ }
+
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ OString tmpFileName;
+ OString hFileName = createFileNameFromType(outPath, m_typeName, ".hdl");
+
+ sal_Bool bFileExists = sal_False;
+ sal_Bool bFileCheck = sal_False;
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hFile;
+
+ if ( bFileCheck )
+ hFile.openFile(tmpFileName);
+ else
+ hFile.openFile(hFileName);
+
+ if(!hFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHFile(hFile);
+
+ hFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ OString hxxFileName = createFileNameFromType(outPath, m_typeName, ".hpp");
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmp");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hxxFile;
+
+ if ( bFileCheck )
+ hxxFile.openFile(tmpFileName);
+ else
+ hxxFile.openFile(hxxFileName);
+
+ if(!hxxFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hxxFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHxxFile(hxxFile);
+
+ hxxFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ return ret;
+}
+sal_Bool CppuType::dumpDependedTypes(CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_True;
+
+ TypeUsingSet usingSet(m_dependencies.getDependencies(m_typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+ OString typeName;
+ sal_uInt32 index = 0;
+ while (iter != usingSet.end())
+ {
+ typeName = (*iter).m_type;
+ if ((index = typeName.lastIndexOf(']')) > 0)
+ typeName = typeName.copy(index + 1);
+
+ if (getBaseType(typeName).getLength() == 0)
+ {
+ if (!produceType(typeName,
+ m_typeMgr,
+ m_dependencies,
+ pOptions))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+ }
+ iter++;
+ }
+
+ return ret;
+}
+
+OString CppuType::dumpHeaderDefine(FileStream& o, sal_Char* prefix, sal_Bool bExtended)
+{
+ if (m_typeName.equals("/"))
+ {
+ bExtended = sal_False;
+ m_typeName = "global";
+ }
+
+ sal_uInt32 length = 3 + m_typeName.getLength() + strlen(prefix);
+
+ if (bExtended)
+ length += m_name.getLength() + 1;
+
+ OStringBuffer tmpBuf(length);
+
+ tmpBuf.append('_');
+ tmpBuf.append(m_typeName);
+ tmpBuf.append('_');
+ if (bExtended)
+ {
+ tmpBuf.append(m_name);
+ tmpBuf.append('_');
+ }
+ tmpBuf.append(prefix);
+ tmpBuf.append('_');
+
+ OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toUpperCase());
+
+ o << "#ifndef " << tmp << "\n#define " << tmp << endl;
+
+ return tmp;
+}
+
+void CppuType::dumpDefaultHIncludes(FileStream& o)
+{
+ o << "#ifndef _CPPU_MACROS_HXX_\n"
+ << "#include <cppu/macros.hxx>\n"
+ << "#endif\n";
+
+ if (m_typeMgr.getTypeClass(m_typeName) == RT_TYPE_INTERFACE)
+ {
+ o << "#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_\n"
+ << "#include <com/sun/star/uno/Reference.h>\n"
+ << "#endif\n";
+ }
+}
+
+void CppuType::dumpDefaultHxxIncludes(FileStream& o)
+{
+ o << "#ifndef _OSL_MUTEX_HXX_\n"
+ << "#include <osl/mutex.hxx>\n"
+ << "#endif\n\n";
+
+ o << "#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_\n"
+ << "#include <com/sun/star/uno/Type.hxx>\n"
+ << "#endif\n";
+
+ if (m_typeMgr.getTypeClass(m_typeName) == RT_TYPE_INTERFACE)
+ {
+ o << "#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_\n"
+ << "#include <com/sun/star/uno/Reference.hxx>\n"
+ << "#endif\n";
+ }
+}
+
+void CppuType::dumpInclude(FileStream& o, const OString& typeName, sal_Char* prefix, sal_Bool bExtended, sal_Bool bCaseSensitive)
+{
+ sal_uInt32 length = 3+ m_typeName.getLength() + strlen(prefix);
+
+ if (bExtended)
+ length += m_name.getLength() + 1;
+
+ OStringBuffer tmpBuf(length);
+
+ tmpBuf.append('_');
+ tmpBuf.append(typeName);
+ tmpBuf.append('_');
+ if (bExtended)
+ {
+ tmpBuf.append(m_name);
+ tmpBuf.append('_');
+ }
+ tmpBuf.append(prefix);
+ tmpBuf.append('_');
+
+ OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toUpperCase());
+
+ length = 1 + typeName.getLength() + strlen(prefix);
+ if (bExtended)
+ length += m_name.getLength() + 1;
+
+ tmpBuf.ensureCapacity(length);
+ tmpBuf.append(typeName);
+ if (bExtended)
+ {
+ tmpBuf.append('/');
+ tmpBuf.append(m_name);
+ }
+ tmpBuf.append('.');
+ tmpBuf.append(prefix);
+
+ o << "#ifndef " << tmp << "\n#include <";
+ if (bCaseSensitive)
+ {
+ o << tmpBuf.makeStringAndClear();
+ } else
+ {
+ o << tmpBuf.makeStringAndClear();
+ }
+ o << ">\n#endif\n";
+}
+
+void CppuType::dumpDepIncludes(FileStream& o, const OString& typeName, sal_Char* prefix)
+{
+ TypeUsingSet usingSet(m_dependencies.getDependencies(typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+
+ OString sPrefix(OString(prefix).toUpperCase());
+ sal_Bool bSequenceDumped = sal_False;
+ sal_Bool bInterfaceDumped = sal_False;
+ sal_uInt32 index = 0;
+ sal_uInt32 seqNum = 0;
+ OString relType;
+ while (iter != usingSet.end())
+ {
+ index = (*iter).m_type.lastIndexOf(']');
+ seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ relType = (*iter).m_type;
+ if (index > 0)
+ relType = relType.copy(index+1);
+
+ OString defPrefix("HXX");
+ if (sPrefix.equals("HDL"))
+ defPrefix = "H";
+
+ if (seqNum > 0 && !bSequenceDumped)
+ {
+ bSequenceDumped = sal_True;
+ o << "#ifndef _COM_SUN_STAR_UNO_SEQUENCE_" << defPrefix
+ << "_\n#include <com/sun/star/uno/Sequence." << defPrefix.toLowerCase()
+ << ">\n#endif\n";
+ }
+
+ if (getBaseType(relType).getLength() == 0 &&
+ m_typeName != relType)
+ {
+ if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE
+ && sPrefix.equals("HDL"))
+ {
+ if (!bInterfaceDumped)
+ {
+ bInterfaceDumped = sal_True;
+ o << "#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_\n"
+ << "#include <com/sun/star/uno/Reference.h>\n"
+ << "#endif\n";
+ }
+
+ if (!((*iter).m_use & TYPEUSE_SUPER))
+ {
+ o << endl;
+ dumpNameSpace(o, sal_True, sal_False, relType);
+ o << "\nclass " << scopedName(m_typeName, relType, sal_True) << ";\n";
+ dumpNameSpace(o, sal_False, sal_False, relType);
+ o << "\n\n";
+ } else
+ {
+ dumpInclude(o, relType, prefix);
+ }
+ } else
+ {
+ dumpInclude(o, relType, prefix);
+ }
+ } else
+ if (relType == "any")
+ {
+ o << "#ifndef _COM_SUN_STAR_UNO_ANY_" << defPrefix
+ << "_\n#include <com/sun/star/uno/Any." << defPrefix.toLowerCase()
+ << ">\n#endif\n";
+ } else
+ if (relType == "type")
+ {
+ o << "#ifndef _COM_SUN_STAR_UNO_TYPE_" << defPrefix
+ << "_\n#include <com/sun/star/uno/Type." << defPrefix.toLowerCase()
+ << ">\n#endif\n";
+ } else
+ if (relType == "string" && sPrefix.equals("HDL"))
+ {
+ o << "#ifndef _RTL_USTRING_HXX_\n"
+ << "#include <rtl/ustring.hxx>\n"
+ << "#endif\n";
+ }
+
+ iter++;
+ }
+}
+
+void CppuType::dumpNameSpace(FileStream& o, sal_Bool bOpen, sal_Bool bFull, const OString& type)
+{
+ OString typeName(type);
+ sal_Bool bOneLine = sal_True;
+ if (typeName.getLength() == 0)
+ {
+ typeName = m_typeName;
+ bOneLine = sal_False;
+ }
+
+ if (typeName == "/")
+ return;
+
+ sal_uInt32 count = typeName.getTokenCount('/');
+
+ if (count == 1 && !bFull)
+ return;
+
+ if (!bFull) count--;
+
+ if (bOpen)
+ {
+ for (int i=0; i < count; i++)
+ {
+ o << "namespace " << typeName.getToken(i, '/');
+ if (bOneLine)
+ o << " { ";
+ else
+ o << "\n{\n";
+ }
+ } else
+ {
+ for (int i=count-1; i >= 0; i--)
+ {
+ o << "}";
+ if (bOneLine)
+ o << " ";
+ else
+ o << " // " << typeName.getToken(i, '/') << "\n";
+ }
+ }
+}
+
+void CppuType::dumpLGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ if (m_reader.getTypeClass() == RT_TYPE_TYPEDEF)
+ {
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL get_" << typeName << "_Type( )\n{\n";
+ } else
+ {
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ }
+ inc();
+
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "typelib_static_type_init( &s_pType_" << typeName << ", "
+ << getTypeClass(m_typeName, sal_True) << ", \"" << m_typeName.replace('/', '.') << "\" );\n";
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ dec();
+ o << indent() << "}\n";
+
+ return;
+}
+
+void CppuType::dumpGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ if ( m_cppuTypeLeak )
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+ if ( !m_cppuTypeDynamic )
+ {
+ dumpCGetCppuType(o);
+ return;
+ }
+
+ if ( !m_typeName.equals("com/sun/star/uno/Exception") )
+ {
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+ }
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ if ( m_typeName.equals("com/sun/star/uno/Exception") )
+ {
+ o << indent() << "return * reinterpret_cast< const ::com::sun::star::uno::Type * >( ::typelib_static_type_getByTypeClass("
+ << " typelib_TypeClass_EXCEPTION ) );\n";
+ } else
+ {
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool bIsBaseException = sal_False;
+ if (superType.getLength() > 0)
+ {
+ if ( superType.equals("com/sun/star/uno/Exception") )
+ {
+ bIsBaseException = sal_True;
+ } else
+ {
+ o << indent() << "const ::com::sun::star::uno::Type& rBaseType = getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 );\n\n";
+ }
+ }
+
+ sal_uInt32 count = getMemberCount();
+ if (count)
+ {
+ o << indent() << "typelib_TypeDescriptionReference * aMemberRefs[" << count << "];\n";
+// << indent() << "const sal_Char * aMemberNames[" << count << "];\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldType, fieldName;
+ OString scope = m_typeName.replace('/', '.');
+ sal_Bool bWithScope = sal_True;
+ OString modFieldType;
+ StringSet generatedTypeSet;
+ StringSet::iterator findIter;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = checkRealBaseType(m_reader.getFieldType(i), sal_True);
+
+ modFieldType = typeToIdentifier(fieldType);
+
+ findIter = generatedTypeSet.find(fieldType);
+ if ( findIter == generatedTypeSet.end() )
+ {
+ generatedTypeSet.insert(fieldType);
+ o << indent() << "const ::com::sun::star::uno::Type& rMemberType_"
+ << modFieldType/*i*/ << " = getCppuType( ( ";
+ dumpType(o, fieldType, sal_True, sal_False);
+ o << " *)0 );\n";
+ }
+
+ o << indent() << "aMemberRefs[" << i << "] = rMemberType_"
+ << modFieldType/*i*/ << ".getTypeLibType();\n";
+ }
+ o << endl;
+ }
+
+ o << indent() << "typelib_static_compound_type_init( &s_pType_" << typeName << ", "
+ << getTypeClass(m_typeName, sal_True) << ", \"" << m_typeName.replace('/', '.') << "\", ";
+ if ( superType.getLength() > 0 || bIsBaseException )
+ {
+ if ( bIsBaseException )
+ {
+ o << "* ::typelib_static_type_getByTypeClass( typelib_TypeClass_EXCEPTION ), "
+ << count << ", ";
+ } else
+ {
+ o << "rBaseType.getTypeLibType(), " << count << ", ";
+ }
+ } else
+ {
+ o << "0, " << count << ", ";
+ }
+
+ if (count)
+ {
+ o << " aMemberRefs );\n";
+ } else
+ {
+ o << " 0 );\n";
+ }
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< const ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ }
+ dec();
+ o << indent() << "}\n";
+
+ return;
+}
+
+void CppuType::dumpCGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n"
+ << "{\n";
+ inc();
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_typeName.replace('/', '.') << "\") );\n\n";
+
+ if ( m_cppuTypeDynamic )
+ {
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ } else
+ {
+ o << indent() << "// Start inline typedescription generation\n"
+ << indent() << "typelib_TypeDescription * pTD = 0;\n";
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ o << indent() << "const ::com::sun::star::uno::Type& rSuperType = getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 );\n";
+ }
+
+ dumpCppuGetTypeMemberDecl(o, CPPUTYPEDECL_ALLTYPES);
+
+ sal_uInt32 count = getMemberCount();
+ if (count)
+ {
+ o << "\n" << indent() << "typelib_CompoundMember_Init aMembers["
+ << count << "];\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldType, fieldName;
+ OString scope = m_typeName.replace('/', '.');
+ sal_Bool bWithScope = sal_True;
+
+ if ( m_reader.getTypeClass() == RT_TYPE_STRUCT ||
+ m_reader.getTypeClass() == RT_TYPE_ENUM )
+ {
+ bWithScope = sal_False;
+ }
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = checkRealBaseType(m_reader.getFieldType(i), sal_True);
+
+ o << indent() << "::rtl::OUString sMemberType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << fieldType.replace('/', '.') << "\") );\n";
+ o << indent() << "::rtl::OUString sMemberName" << i << "( RTL_CONSTASCII_USTRINGPARAM(\"";
+ if (bWithScope)
+ o << scope << "::";
+ o << fieldName << "\") );\n";
+ o << indent() << "aMembers[" << i << "].eTypeClass = "
+ << "(typelib_TypeClass)" << getTypeClass(fieldType) << ";\n"
+ << indent() << "aMembers[" << i << "].pTypeName = sMemberType" << i << ".pData;\n"
+ << indent() << "aMembers[" << i << "].pMemberName = sMemberName" << i << ".pData;\n";
+ }
+ }
+
+ o << "\n" << indent() << "typelib_typedescription_new(\n";
+ inc();
+ o << indent() << "&pTD,\n" << indent() << "(typelib_TypeClass)"
+ << getTypeClass() << ", sTypeName.pData,\n";
+
+ if (superType.getLength() > 0)
+ o << indent() << "rSuperType.getTypeLibType(),\n";
+ else
+ o << indent() << "0,\n";
+
+ if ( count )
+ {
+ o << indent() << count << ",\n" << indent() << "aMembers );\n\n";
+ } else
+ {
+ o << indent() << count << ",\n" << indent() << "0 );\n\n";
+ }
+
+ dec();
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pTD );\n\n";
+
+ o << indent() << "typelib_typedescription_release( pTD );\n"
+ << indent() << "// End inline typedescription generation\n\n";
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n\n";
+ o << indent() << "return *pType_" << typeName << ";\n";
+ dec();
+ o << "}\n";
+}
+
+void CppuType::dumpCppuGetTypeMemberDecl(FileStream& o, CppuTypeDecl eDeclFlag)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+
+ StringSet aFinishedTypes;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ if (aFinishedTypes.count(m_reader.getFieldType(i)) == 0)
+ {
+ aFinishedTypes.insert(m_reader.getFieldType(i));
+ dumpCppuGetType(o, m_reader.getFieldType(i), sal_True, eDeclFlag);
+ }
+ }
+}
+
+sal_uInt32 CppuType::getMemberCount()
+{
+ sal_uInt32 count = m_reader.getMethodCount();
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ count++;
+ }
+ return count;
+}
+
+sal_uInt32 CppuType::checkInheritedMemberCount(const TypeReader* pReader)
+{
+ sal_Bool bSelfCheck = sal_True;
+ if (!pReader)
+ {
+ bSelfCheck = sal_False;
+ pReader = &m_reader;
+ }
+
+ sal_uInt32 count = 0;
+ OString superType(pReader->getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ TypeReader aSuperReader(m_typeMgr.getTypeReader(superType));
+ if ( aSuperReader.isValid() )
+ {
+ count = checkInheritedMemberCount(&aSuperReader);
+ }
+ }
+
+ if (bSelfCheck)
+ {
+ count += pReader->getMethodCount();
+ sal_uInt32 fieldCount = pReader->getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = pReader->getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ {
+ count++;
+ }
+ }
+ }
+
+ return count;
+}
+
+sal_uInt32 CppuType::getInheritedMemberCount()
+{
+ if (m_inheritedMemberCount == 0)
+ {
+ m_inheritedMemberCount = checkInheritedMemberCount(0);
+ }
+
+ return m_inheritedMemberCount;
+}
+
+OString CppuType::getTypeClass(const OString& type, sal_Bool bCStyle)
+{
+ OString typeName = (type.getLength() > 0 ? type : m_typeName);
+ RTTypeClass rtTypeClass = RT_TYPE_INVALID;
+
+ if (type.getLength() > 0)
+ {
+ typeName = type;
+ rtTypeClass = m_typeMgr.getTypeClass(typeName);
+ } else
+ {
+ typeName = m_typeName;
+ rtTypeClass = m_reader.getTypeClass();
+ }
+
+ if (typeName.lastIndexOf(']') > 0)
+ return bCStyle ? "typelib_TypeClass_SEQUENCE" : "::com::sun::star::uno::TypeClass_SEQUENCE";
+
+ switch (rtTypeClass)
+ {
+ case RT_TYPE_INTERFACE:
+ return bCStyle ? "typelib_TypeClass_INTERFACE" : "::com::sun::star::uno::TypeClass_INTERFACE";
+ break;
+ case RT_TYPE_MODULE:
+ return bCStyle ? "typelib_TypeClass_MODULE" : "::com::sun::star::uno::TypeClass_MODULE";
+ break;
+ case RT_TYPE_STRUCT:
+ return bCStyle ? "typelib_TypeClass_STRUCT" : "::com::sun::star::uno::TypeClass_STRUCT";
+ break;
+ case RT_TYPE_ENUM:
+ return bCStyle ? "typelib_TypeClass_ENUM" : "::com::sun::star::uno::TypeClass_ENUM";
+ break;
+ case RT_TYPE_EXCEPTION:
+ return bCStyle ? "typelib_TypeClass_EXCEPTION" : "::com::sun::star::uno::TypeClass_EXCEPTION";
+ break;
+ case RT_TYPE_TYPEDEF:
+ {
+ OString realType = checkRealBaseType( typeName );
+ return getTypeClass( realType, bCStyle );
+ }
+// return bCStyle ? "typelib_TypeClass_TYPEDEF" : "::com::sun::star::uno::TypeClass_TYPEDEF";
+ break;
+ case RT_TYPE_SERVICE:
+ return bCStyle ? "typelib_TypeClass_SERVICE" : "::com::sun::star::uno::TypeClass_SERVICE";
+ break;
+ case RT_TYPE_INVALID:
+ {
+ if (type.equals("long"))
+ return bCStyle ? "typelib_TypeClass_LONG" : "::com::sun::star::uno::TypeClass_LONG";
+ if (type.equals("short"))
+ return bCStyle ? "typelib_TypeClass_SHORT" : "::com::sun::star::uno::TypeClass_SHORT";
+ if (type.equals("hyper"))
+ return bCStyle ? "typelib_TypeClass_HYPER" : "::com::sun::star::uno::TypeClass_HYPER";
+ if (type.equals("string"))
+ return bCStyle ? "typelib_TypeClass_STRING" : "::com::sun::star::uno::TypeClass_STRING";
+ if (type.equals("boolean"))
+ return bCStyle ? "typelib_TypeClass_BOOLEAN" : "::com::sun::star::uno::TypeClass_BOOLEAN";
+ if (type.equals("char"))
+ return bCStyle ? "typelib_TypeClass_CHAR" : "::com::sun::star::uno::TypeClass_CHAR";
+ if (type.equals("byte"))
+ return bCStyle ? "typelib_TypeClass_BYTE" : "::com::sun::star::uno::TypeClass_BYTE";
+ if (type.equals("any"))
+ return bCStyle ? "typelib_TypeClass_ANY" : "::com::sun::star::uno::TypeClass_ANY";
+ if (type.equals("type"))
+ return bCStyle ? "typelib_TypeClass_TYPE" : "::com::sun::star::uno::TypeClass_TYPE";
+ if (type.equals("float"))
+ return bCStyle ? "typelib_TypeClass_FLOAT" : "::com::sun::star::uno::TypeClass_FLOAT";
+ if (type.equals("double"))
+ return bCStyle ? "typelib_TypeClass_DOUBLE" : "::com::sun::star::uno::TypeClass_DOUBLE";
+ if (type.equals("void"))
+ return bCStyle ? "typelib_TypeClass_VOID" : "::com::sun::star::uno::TypeClass_VOID";
+ if (type.equals("unsigned long"))
+ return bCStyle ? "typelib_TypeClass_UNSIGNED_LONG" : "::com::sun::star::uno::TypeClass_UNSIGNED_LONG";
+ if (type.equals("unsigned short"))
+ return bCStyle ? "typelib_TypeClass_UNSIGNED_SHORT" : "::com::sun::star::uno::TypeClass_UNSIGNED_SHORT";
+ if (type.equals("unsigned hyper"))
+ return bCStyle ? "typelib_TypeClass_UNSIGNED_HYPER" : "::com::sun::star::uno::TypeClass_UNSIGNED_HYPER";
+ }
+ break;
+ }
+
+ return bCStyle ? "typelib_TypeClass_UNKNOWN" : "::com::sun::star::uno::TypeClass_UNKNOWN";
+}
+
+void CppuType::dumpType(FileStream& o, const OString& type,
+ sal_Bool bConst, sal_Bool bRef, sal_Bool bNative)
+ throw( CannotDumpException )
+{
+ OString sType(checkRealBaseType(type, sal_True));
+ sal_uInt32 index = sType.lastIndexOf(']');
+ sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ OString relType = (index > 0 ? (sType).copy(index+1) : type);
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(relType);
+
+ if (bConst) o << "const ";
+
+ int i;
+ for (i=0; i < seqNum; i++)
+ {
+ o << "::com::sun::star::uno::Sequence< ";
+ }
+
+ switch (typeClass)
+ {
+ case RT_TYPE_INTERFACE:
+ if (bNative)
+ o << scopedName(m_typeName, relType);
+ else
+ o << "::com::sun::star::uno::Reference< " << scopedName(m_typeName, relType) << " >";
+ break;
+ case RT_TYPE_INVALID:
+ {
+ OString tmp(getBaseType(relType));
+ if (tmp.getLength() > 0)
+ {
+ o << getBaseType(relType);
+ } else
+ throw CannotDumpException("Unknown type '" + relType + "', incomplete type library.");
+ }
+ break;
+ case RT_TYPE_STRUCT:
+ case RT_TYPE_ENUM:
+ case RT_TYPE_TYPEDEF:
+ case RT_TYPE_EXCEPTION:
+ o << scopedName(m_typeName, relType);
+ break;
+ }
+
+ for (i=0; i < seqNum; i++)
+ {
+ o << " >";
+ }
+
+ if (bRef) o << "&";
+}
+
+OString CppuType::getBaseType(const OString& type)
+{
+ if (type.equals("long"))
+ return "sal_Int32";
+ if (type.equals("short"))
+ return "sal_Int16";
+ if (type.equals("hyper"))
+ return "sal_Int64";
+ if (type.equals("string"))
+ return "::rtl::OUString";
+ if (type.equals("boolean"))
+ return "sal_Bool";
+ if (type.equals("char"))
+ return "sal_Unicode";
+ if (type.equals("byte"))
+ return "sal_Int8";
+ if (type.equals("any"))
+ return "::com::sun::star::uno::Any";
+ if (type.equals("type"))
+ return "::com::sun::star::uno::Type";
+ if (type.equals("float"))
+ return "float";
+ if (type.equals("double"))
+ return "double";
+ if (type.equals("octet"))
+ return "sal_Int8";
+ if (type.equals("void"))
+ return type;
+ if (type.equals("unsigned long"))
+ return "sal_uInt32";
+ if (type.equals("unsigned short"))
+ return "sal_uInt16";
+ if (type.equals("unsigned hyper"))
+ return "sal_uInt64";
+
+ return OString();
+}
+
+void CppuType::dumpCppuGetType(FileStream& o, const OString& type, sal_Bool bDecl, CppuTypeDecl eDeclFlag)
+{
+ OString sType( checkRealBaseType(type, sal_True) );
+ sal_uInt32 index = sType.lastIndexOf(']');
+ OString relType = (index > 0 ? (sType).copy(index+1) : type);
+
+ if (eDeclFlag == CPPUTYPEDECL_ONLYINTERFACES)
+ {
+ if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE)
+ {
+ o << indent() << "getCppuType( (";
+ dumpType(o, type, sal_True, sal_False);
+ o << "*)0 )";
+
+ if (bDecl)
+ o << ";\n";
+ }
+ } else
+ {
+ if (isBaseType(type))
+ {
+ return;
+ } else
+ {
+ if (eDeclFlag == CPPUTYPEDECL_NOINTERFACES &&
+ m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE)
+ return;
+
+// if (m_typeMgr.getTypeClass(type) == RT_TYPE_TYPEDEF)
+// {
+// o << indent() << "get_" << type.replace('/', '_') << "_Type()";
+// } else
+// {
+ o << indent() << "getCppuType( (";
+ dumpType(o, type, sal_True, sal_False);
+ o << "*)0 )";
+// }
+ }
+ if (bDecl)
+ o << ";\n";
+ }
+}
+
+void CppuType::dumpTypeInit(FileStream& o, const OString& typeName)
+{
+ OString type(checkSpecialCppuType(typeName));
+
+ BASETYPE baseType = isBaseType(type);
+
+ switch (baseType)
+ {
+ case BT_BOOLEAN:
+ o << "(sal_False)";
+ return;
+ break;
+ case BT_ANY:
+ case BT_STRING:
+ o << "()";
+ return;
+ break;
+ case BT_INVALID:
+ break;
+ default:
+ o << "((";
+ dumpType(o, type);
+ o << ")" << "0)";
+ return;
+ }
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(type);
+
+ if (typeClass == RT_TYPE_ENUM)
+ {
+ RegistryTypeReaderLoader aReaderLoader;
+
+ if (aReaderLoader.isLoaded())
+ {
+ TypeReader reader(m_typeMgr.getTypeReader(type));
+
+ if ( reader.isValid() )
+ {
+ o << "(" << shortScopedName("", type, sal_False)
+ << "::" << type.getToken(type.getTokenCount('/') - 1, '/')
+ << "_" << reader.getFieldName(0) << ")";
+ return;
+ }
+ }
+ }
+
+ o << "()";
+}
+
+BASETYPE CppuType::isBaseType(const OString& type)
+{
+ if (type.equals("long"))
+ return BT_LONG;
+ if (type.equals("short"))
+ return BT_SHORT;
+ if (type.equals("hyper"))
+ return BT_HYPER;
+ if (type.equals("string"))
+ return BT_STRING;
+ if (type.equals("boolean"))
+ return BT_BOOLEAN;
+ if (type.equals("char"))
+ return BT_CHAR;
+ if (type.equals("byte"))
+ return BT_BYTE;
+ if (type.equals("any"))
+ return BT_ANY;
+ if (type.equals("float"))
+ return BT_FLOAT;
+ if (type.equals("double"))
+ return BT_DOUBLE;
+ if (type.equals("void"))
+ return BT_VOID;
+ if (type.equals("unsigned long"))
+ return BT_UNSIGNED_LONG;
+ if (type.equals("unsigned short"))
+ return BT_UNSIGNED_SHORT;
+ if (type.equals("unsigned hyper"))
+ return BT_UNSIGNED_HYPER;
+
+ return BT_INVALID;
+}
+
+OString CppuType::typeToIdentifier(const OString& type)
+{
+ sal_uInt32 index = type.lastIndexOf(']');
+ sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+ OString sIdentifier;
+
+ while( seqNum > 0 )
+ {
+ sIdentifier += OString("seq");
+
+ if ( --seqNum == 0 )
+ {
+ sIdentifier += OString("_");
+ }
+ }
+
+ if ( isBaseType(relType) )
+ {
+ sIdentifier += relType.replace(' ', '_');
+ } else
+ {
+ sIdentifier += relType.replace('/', '_');
+ }
+
+
+ return sIdentifier;
+}
+
+OString CppuType::checkSpecialCppuType(const OString& type)
+{
+ OString baseType(type);
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ RegistryKey key;
+ sal_uInt8* pBuffer=NULL;
+ RTTypeClass typeClass;
+ sal_Bool isTypeDef = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
+ TypeReader reader;
+
+ while (isTypeDef)
+ {
+ reader = m_typeMgr.getTypeReader(baseType);
+
+ if (reader.isValid())
+ {
+ typeClass = reader.getTypeClass();
+
+ if (typeClass == RT_TYPE_TYPEDEF)
+ baseType = reader.getSuperTypeName();
+ else
+ isTypeDef = sal_False;
+ } else
+ {
+ break;
+ }
+ }
+
+ return baseType;
+}
+
+OString CppuType::checkRealBaseType(const OString& type, sal_Bool bResolveTypeOnly)
+{
+ sal_uInt32 index = type.lastIndexOf(']');
+ OString baseType = (index > 0 ? ((OString)type).copy(index+1) : type);
+ OString seqPrefix = (index > 0 ? ((OString)type).copy(0, index+1) : OString());
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ RegistryKey key;
+ sal_uInt8* pBuffer=NULL;
+ RTTypeClass typeClass;
+ sal_Bool mustBeChecked = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
+ TypeReader reader;
+
+ while (mustBeChecked)
+ {
+ reader = m_typeMgr.getTypeReader(baseType);
+
+ if (reader.isValid())
+ {
+ typeClass = reader.getTypeClass();
+
+ if (typeClass == RT_TYPE_TYPEDEF)
+ {
+ baseType = reader.getSuperTypeName();
+ index = baseType.lastIndexOf(']');
+ if (index > 0)
+ {
+ seqPrefix += baseType.copy(0, index+1);
+ baseType = baseType.copy(index+1);
+ }
+ } else
+ mustBeChecked = sal_False;
+ } else
+ {
+ break;
+ }
+ }
+
+ if ( bResolveTypeOnly )
+ baseType = seqPrefix + baseType;
+
+ return baseType;
+}
+
+void CppuType::dumpConstantValue(FileStream& o, sal_uInt16 index)
+{
+ RTConstValue constValue = m_reader.getFieldConstValue(index);
+
+ switch (constValue.m_type)
+ {
+ case RT_TYPE_BOOL:
+ if (constValue.m_value.aBool)
+ o << "sal_True";
+ else
+ o << "sal_False";
+ break;
+ case RT_TYPE_BYTE:
+ {
+ char tmp[16];
+ sprintf(tmp, "0x%x", (sal_Int8)constValue.m_value.aByte);
+ o << "(sal_Int8)" << tmp;
+ }
+ break;
+ case RT_TYPE_INT16:
+ o << "(sal_Int16)" << constValue.m_value.aShort;
+ break;
+ case RT_TYPE_UINT16:
+ o << "(sal_uInt16)" << constValue.m_value.aUShort;
+ break;
+ case RT_TYPE_INT32:
+ o << "(sal_Int32)" << constValue.m_value.aLong;
+ break;
+ case RT_TYPE_UINT32:
+ o << "(sal_uInt32)" << constValue.m_value.aULong;
+ break;
+ case RT_TYPE_FLOAT:
+ o << "(float)" << constValue.m_value.aFloat;
+ break;
+ case RT_TYPE_DOUBLE:
+ o << "(double)" << constValue.m_value.aDouble;
+ break;
+ case RT_TYPE_STRING:
+ {
+ ::rtl::OUString aUStr(constValue.m_value.aString);
+ ::rtl::OString aStr = ::rtl::OUStringToOString(aUStr, RTL_TEXTENCODING_ASCII_US);
+ o << "::rtl::OUString::createFromAscii(\"" << aStr.getStr() << "\")";
+ }
+ break;
+ }
+}
+
+void CppuType::inc(sal_uInt32 num)
+{
+ m_indentLength += num;
+}
+
+void CppuType::dec(sal_uInt32 num)
+{
+ if (m_indentLength - num < 0)
+ m_indentLength = 0;
+ else
+ m_indentLength -= num;
+}
+
+OString CppuType::indent()
+{
+ OStringBuffer tmp(m_indentLength);
+
+ for (int i=0; i < m_indentLength; i++)
+ {
+ tmp.append(' ');
+ }
+ return tmp.makeStringAndClear();
+}
+
+OString CppuType::indent(sal_uInt32 num)
+{
+ OStringBuffer tmp(m_indentLength + num);
+
+ for (int i=0; i < m_indentLength + num; i++)
+ {
+ tmp.append(' ');
+ }
+ return tmp.makeStringAndClear();
+}
+
+//*************************************************************************
+// InterfaceType
+//*************************************************************************
+InterfaceType::InterfaceType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+ m_inheritedMemberCount = 0;
+ m_hasAttributes = sal_False;
+ m_hasMethods = sal_False;
+}
+
+InterfaceType::~InterfaceType()
+{
+
+}
+
+sal_Bool InterfaceType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+ dumpNameSpace(o);
+ o << "\nclass " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " : public " << scopedName(m_typeName, superType);
+
+ o << "\n{\npublic:\n";
+ inc();
+
+ dumpAttributes(o);
+ dumpMethods(o);
+
+ dec();
+ o << "};\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+ o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+ << "class Type;\n} } } }\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+sal_Bool InterfaceType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+
+ dumpDepIncludes(o, m_typeName, "hpp");
+ o << endl;
+
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+void InterfaceType::dumpAttributes(FileStream& o)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ sal_Bool first=sal_True;
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << "\n" << indent() << "// Attributes\n";
+ }
+
+ o << indent() << "virtual ";
+ dumpType(o, fieldType);
+ o << " SAL_CALL get" << fieldName << "() throw(::com::sun::star::uno::RuntimeException) = 0;\n";
+
+ if (access != RT_ACCESS_READONLY)
+ {
+ OString relType = checkSpecialCppuType(fieldType);
+ sal_Bool bRef = sal_False;
+ sal_Bool bConst = sal_False;
+
+ if (m_typeMgr.getTypeClass(relType) == RT_TYPE_ENUM ||
+ (isBaseType(relType) && !relType.equals("string") && !relType.equals("any")))
+ {
+ bConst = sal_False;
+ bRef = sal_False;
+ } else
+ {
+ bConst = sal_True;
+ bRef = sal_True;
+ }
+
+ o << indent() << "virtual void SAL_CALL set" << fieldName << "( ";
+ dumpType(o, fieldType, bConst, bRef);
+ o << " _" << fieldName.toLowerCase() << " ) throw(::com::sun::star::uno::RuntimeException) = 0;\n";
+ }
+ }
+}
+
+void InterfaceType::dumpMethods(FileStream& o)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ sal_Bool first=sal_True;
+
+ OString methodName, returnType, paramType, paramName;
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+ RTMethodMode methodMode = RT_MODE_INVALID;
+ RTParamMode paramMode = RT_PARAM_INVALID;
+
+ sal_Bool bRef = sal_False;
+ sal_Bool bConst = sal_False;
+ sal_Bool bWithRunTimeExcp = sal_True;
+
+ for (sal_uInt16 i=0; i < methodCount; i++)
+ {
+ methodName = m_reader.getMethodName(i);
+ returnType = m_reader.getMethodReturnType(i);
+ paramCount = m_reader.getMethodParamCount(i);
+ excCount = m_reader.getMethodExcCount(i);
+ methodMode = m_reader.getMethodMode(i);
+
+ if ( methodName.equals("acquire") || methodName.equals("release") )
+ {
+ bWithRunTimeExcp = sal_False;
+ }
+
+ if (first)
+ {
+ first = sal_False;
+ o << "\n" << indent() << "// Methods\n";
+ }
+
+ o << indent() << "virtual ";
+ dumpType(o, returnType);
+ o << " SAL_CALL " << methodName << "( ";
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ paramName = m_reader.getMethodParamName(i, j);
+ paramType = m_reader.getMethodParamType(i, j);
+ paramMode = m_reader.getMethodParamMode(i, j);
+
+ switch (paramMode)
+ {
+ case RT_PARAM_IN:
+ {
+ OString relType = checkSpecialCppuType(paramType);
+ if (m_typeMgr.getTypeClass(relType) == RT_TYPE_ENUM ||
+ (isBaseType(relType) && !relType.equals("string") && !relType.equals("any")))
+ {
+ bConst = sal_False;
+ bRef = sal_False;
+ } else
+ {
+ bConst = sal_True;
+ bRef = sal_True;
+ }
+ break;
+ }
+ case RT_PARAM_OUT:
+ case RT_PARAM_INOUT:
+ bConst = sal_False;
+ bRef = sal_True;
+ break;
+ }
+
+ dumpType(o, paramType, bConst, bRef);
+ o << " " << paramName;
+
+ if (j+1 < paramCount) o << ", ";
+ }
+ o << " )";
+
+ o << " throw(";
+ OString excpName;
+ for (j=0; j < excCount; j++)
+ {
+ excpName = m_reader.getMethodExcType(i, j);
+ if (excpName != "com/sun/star/uno/RuntimeException")
+ o << scopedName(m_typeName, excpName);
+ if (bWithRunTimeExcp)
+ o << ", ";
+ }
+
+ if ( bWithRunTimeExcp )
+ {
+ o << "::com::sun::star::uno::RuntimeException";
+ }
+
+ o << ") = 0;\n";
+ }
+}
+
+void InterfaceType::dumpGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ if ( m_cppuTypeLeak )
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+ if ( !m_cppuTypeDynamic )
+ {
+ dumpCGetCppuType(o);
+ return;
+ }
+
+ if ( !m_typeName.equals("com/sun/star/uno/XInterface") )
+ {
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+ }
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ if ( m_typeName.equals("com/sun/star/uno/XInterface") )
+ {
+ o << indent() << "return * reinterpret_cast< const ::com::sun::star::uno::Type * >( ::typelib_static_type_getByTypeClass("
+ << " typelib_TypeClass_INTERFACE ) );\n";
+ } else
+ {
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool bWithBase = sal_False;
+ if (superType.getLength() > 0 && !superType.equals("com/sun/star/uno/XInterface"))
+ {
+ bWithBase = sal_True;
+ o << indent() << "const ::com::sun::star::uno::Type& rSuperType = getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 );\n";
+ }
+
+ o << indent() << "typelib_static_interface_type_init( &s_pType_" << typeName
+ << ", \"" << m_typeName.replace('/', '.') << "\", ";
+
+ if ( bWithBase )
+ {
+ o << "rSuperType.getTypeLibType() );\n";
+ } else
+ {
+ o << "0 );\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ }
+ dec();
+ o << indent() << "}\n";
+
+ return;
+}
+
+void InterfaceType::dumpCGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_typeName.replace('/', '.') << "\") );\n\n";
+
+ if ( m_cppuTypeDynamic )
+ {
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ } else
+ {
+ o << indent() << "// Start inline typedescription generation\n"
+ << indent() << "typelib_InterfaceTypeDescription * pTD = 0;\n\n";
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ o << indent() << "const ::com::sun::star::uno::Type& rSuperType = getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 );\n";
+ }
+
+ sal_uInt32 count = getMemberCount();
+ if (count)
+ {
+ o << indent() << "typelib_TypeDescriptionReference * pMembers[" << count << "] = { ";
+ for (sal_uInt16 i = 0; i < count; i++)
+ {
+ o << "0";
+ if (i+1 < count)
+ o << ",";
+ else
+ o << " };\n";
+ }
+
+ sal_uInt32 index = 0;
+ dumpCppuAttributeRefs(o, index);
+ dumpCppuMethodRefs(o, index);
+ }
+
+ o << "\n" << indent() << "typelib_typedescription_newInterface(\n";
+ inc();
+ o << indent() << "&pTD,\n"
+ << indent() << "sTypeName.pData, ";
+
+ RTUik uik;
+ m_reader.getUik(uik);
+ sal_Char buffer[53];
+ sprintf(buffer, "0x%.8x, 0x%.4x, 0x%.4x, 0x%.8x, 0x%.8x,\n",
+ uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5);
+ o << buffer;
+
+ if (superType.getLength() > 0)
+ o << indent() << "rSuperType.getTypeLibType(),\n";
+ else
+ o << indent() << "0,\n";
+
+ if ( count )
+ {
+ o << indent() << count << ",\n" << indent() << "pMembers );\n\n";
+ } else
+ {
+ o << indent() << count << ",\n" << indent() << "0 );\n\n";
+ }
+ dec();
+
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pTD );\n";
+ if ( count )
+ {
+ for (sal_uInt16 i=0; i < count; i++)
+ {
+ o << indent() << "typelib_typedescriptionreference_release( pMembers["
+ << i << "] );\n";
+ }
+ }
+ o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pTD );\n\n";
+
+// if (superType.getLength() > 0)
+// o << indent() << "typelib_typedescription_release( pSuperTD );\n\n";
+// else
+// o << endl;
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+
+ StringSet aTypes;
+ // type for RuntimeException is always needed
+ OString sRunTimeExceptionType("com/sun/star/uno/RuntimeException");
+ aTypes.insert(sRunTimeExceptionType);
+ dumpCppuGetType(o, sRunTimeExceptionType, sal_True, CPPUTYPEDECL_ALLTYPES);
+
+ dumpAttributesCppuDecl(o, &aTypes, CPPUTYPEDECL_ALLTYPES);
+ dumpMethodsCppuDecl(o, &aTypes, CPPUTYPEDECL_ALLTYPES);
+
+ if (count)
+ {
+ sal_uInt32 index = getInheritedMemberCount();
+ dumpCppuAttributes(o, index);
+ dumpCppuMethods(o, index);
+ }
+
+ o << indent() << "// End inline typedescription generation\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n\n"
+ << indent() << "return *pType_" << typeName << ";\n";
+
+ dec();
+ o << "}\n";
+}
+
+void InterfaceType::dumpCppuAttributeRefs(FileStream& o, sal_uInt32& index)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString scope = m_typeName.replace('/', '.');
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+
+ o << indent() << "::rtl::OUString sAttributeName" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << scope.replace('/', '.') << "::" << fieldName << "\") );\n";
+ o << indent() << "typelib_typedescriptionreference_new( &pMembers["
+ << index << "],\n";
+ inc(38);
+ o << indent() << "(typelib_TypeClass)::com::sun::star::uno::TypeClass_INTERFACE_ATTRIBUTE,\n"
+ << indent() << "sAttributeName" << i << ".pData );\n";
+ dec(38);
+ index++;
+ }
+}
+
+void InterfaceType::dumpCppuMethodRefs(FileStream& o, sal_uInt32& index)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ OString methodName; //, returnType, paramType, paramName;
+ OString scope = m_typeName.replace('/', '.');
+
+ for (sal_uInt16 i = 0; i < methodCount; i++)
+ {
+ methodName = m_reader.getMethodName(i);
+
+ o << indent() << "::rtl::OUString sMethodName" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << scope.replace('/', '.') << "::" << methodName << "\") );\n";
+ o << indent() << "typelib_typedescriptionreference_new( &pMembers["
+ << index << "],\n";
+ inc(38);
+ o << indent() << "(typelib_TypeClass)::com::sun::star::uno::TypeClass_INTERFACE_METHOD,\n"
+ << indent() << "sMethodName" << i << ".pData );\n";
+ dec(38);
+ index++;
+ }
+}
+
+sal_uInt32 InterfaceType::getMemberCount()
+{
+ sal_uInt32 count = m_reader.getMethodCount();
+
+ if (count)
+ m_hasMethods = sal_True;
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ {
+ m_hasAttributes = sal_True;
+ count++;
+ }
+ }
+ return count;
+}
+
+sal_uInt32 InterfaceType::checkInheritedMemberCount(const TypeReader* pReader)
+{
+ sal_uInt32 cout = 0;
+ sal_Bool bSelfCheck = sal_True;
+ if (!pReader)
+ {
+ bSelfCheck = sal_False;
+ pReader = &m_reader;
+ }
+
+ sal_uInt32 count = 0;
+ OString superType(pReader->getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ TypeReader aSuperReader(m_typeMgr.getTypeReader(superType));
+ if (aSuperReader.isValid())
+ {
+ count = checkInheritedMemberCount(&aSuperReader);
+ }
+ }
+
+ if (bSelfCheck)
+ {
+ count += pReader->getMethodCount();
+ sal_uInt32 fieldCount = pReader->getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = pReader->getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ {
+ count++;
+ }
+ }
+ }
+
+ return count;
+}
+
+sal_uInt32 InterfaceType::getInheritedMemberCount()
+{
+ if (m_inheritedMemberCount == 0)
+ {
+ m_inheritedMemberCount = checkInheritedMemberCount(0);
+ }
+
+ return m_inheritedMemberCount;
+}
+
+void InterfaceType::dumpCppuAttributes(FileStream& o, sal_uInt32& index)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ OString scope = m_typeName.replace('/', '.');
+
+ sal_uInt32 absoluteIndex = index;
+
+ if (m_hasAttributes)
+ {
+ o << "\n" << indent() << "typelib_InterfaceAttributeTypeDescription * pAttribute = 0;\n";
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = checkRealBaseType(m_reader.getFieldType(i), sal_True);
+
+ o << indent() << "::rtl::OUString sAttributeType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << fieldType.replace('/', '.') << "\") );\n";
+ o << indent() << "typelib_typedescription_newInterfaceAttribute( &pAttribute,\n";
+ inc();
+ o << indent() << absoluteIndex++ << ", sAttributeName" << i << ".pData,\n";
+ o << indent() << "(typelib_TypeClass)" << getTypeClass(fieldType)
+ << ", sAttributeType" << i << ".pData,\n";
+ if (access == RT_ACCESS_READONLY)
+ o << indent() << "sal_True );\n";
+ else
+ o << indent() << "sal_False );\n";
+ dec();
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pAttribute );\n\n";
+ }
+ o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pAttribute );\n";
+
+ index = absoluteIndex;
+ }
+}
+
+void InterfaceType::dumpCppuMethods(FileStream& o, sal_uInt32& index)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ OString methodName, returnType, paramType, paramName;
+ OString scope = m_typeName.replace('/', '.');
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+ RTMethodMode methodMode = RT_MODE_INVALID;
+ RTParamMode paramMode = RT_PARAM_INVALID;
+
+ sal_uInt32 absoluteIndex = index;
+
+ if (m_hasMethods)
+ {
+ o << "\n" << indent() << "typelib_InterfaceMethodTypeDescription * pMethod = 0;\n";
+
+ for (sal_uInt16 i=0; i < methodCount; i++)
+ {
+ methodName = m_reader.getMethodName(i);
+ returnType = checkRealBaseType(m_reader.getMethodReturnType(i), sal_True);
+ paramCount = m_reader.getMethodParamCount(i);
+ excCount = m_reader.getMethodExcCount(i);
+ methodMode = m_reader.getMethodMode(i);
+
+ o << indent() << "{\n";
+ inc();
+
+ if (paramCount)
+ {
+ o << indent() << "typelib_Parameter_Init aParameters[" << paramCount << "];\n";
+ }
+
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ paramName = m_reader.getMethodParamName(i, j);
+ paramType = checkRealBaseType(m_reader.getMethodParamType(i, j), sal_True);
+ paramMode = m_reader.getMethodParamMode(i, j);
+
+ o << indent() << "::rtl::OUString sParamName" << j << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << scope << "::" << paramName << "\") );\n";
+ o << indent() << "::rtl::OUString sParamType" << j << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << paramType.replace('/', '.') << "\") );\n";
+ o << indent() << "aParameters[" << j << "].pParamName = sParamName" << j << ".pData;\n";
+ o << indent() << "aParameters[" << j << "].eTypeClass = (typelib_TypeClass)"
+ << getTypeClass(paramType) << ";\n";
+ o << indent() << "aParameters[" << j << "].pTypeName = sParamType" << j << ".pData;\n";
+
+ if (paramMode == RT_PARAM_IN || paramMode == RT_PARAM_INOUT)
+ o << indent() << "aParameters[" << j << "].bIn = sal_True;\n";
+ else
+ o << indent() << "aParameters[" << j << "].bIn = sal_False;\n";
+
+ if (paramMode == RT_PARAM_OUT || paramMode == RT_PARAM_INOUT)
+ o << indent() << "aParameters[" << j << "].bOut = sal_True;\n";
+ else
+ o << indent() << "aParameters[" << j << "].bOut = sal_False;\n";
+ }
+
+ o << indent() << "rtl_uString * pExceptions[" << excCount + 1 << "];\n";
+ for (j=0; j < excCount; j++)
+ {
+ if (!m_reader.getMethodExcType(i, j).equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "::rtl::OUString sExceptionName" << j << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << OString(m_reader.getMethodExcType(i, j)).replace('/', '.') << "\") );\n";
+ o << indent() << "pExceptions[" << j << "] = sExceptionName" << j << ".pData;\n";
+ }
+ }
+ o << indent() << "::rtl::OUString sExceptionName" << excCount << "( RTL_CONSTASCII_USTRINGPARAM("
+ << "\"com.sun.star.uno.RuntimeException\") );\n";
+
+ o << indent() << "pExceptions[" << excCount << "] = sExceptionName" << excCount << ".pData;\n";
+
+ o << indent() << "::rtl::OUString sReturnType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << returnType.replace('/', '.') << "\") );\n";
+ o << indent() << "typelib_typedescription_newInterfaceMethod( &pMethod,\n";
+ inc();
+ o << indent() << absoluteIndex++ << ", ";
+ if (methodMode == RT_MODE_ONEWAY || methodMode == RT_MODE_ONEWAY_CONST)
+ o << "sal_True,\n";
+ else
+ o << "sal_False,\n";
+ o << indent() << "sMethodName" << i << ".pData,\n";
+ o << indent() << "(typelib_TypeClass)" << getTypeClass(returnType)
+ << ", sReturnType" << i << ".pData,\n";
+ if (paramCount)
+ o << indent() << paramCount << ", aParameters,\n";
+ else
+ o << indent() << "0, 0,\n";
+
+ o << indent() << excCount + 1 << ", pExceptions );\n";
+ dec();
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );\n";
+
+ dec();
+ o << indent() << "}\n";
+ }
+ o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pMethod );\n";
+
+ index = absoluteIndex;
+ }
+}
+
+void InterfaceType::dumpAttributesCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (pFinishedTypes->count(fieldType) == 0)
+ {
+ pFinishedTypes->insert(fieldType);
+ dumpCppuGetType(o, fieldType, sal_True, eDeclFlag);
+ }
+ }
+}
+
+void InterfaceType::dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ OString returnType, paramType, excType;
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+
+ for (sal_uInt16 i=0; i < methodCount; i++)
+ {
+ returnType = m_reader.getMethodReturnType(i);
+ paramCount = m_reader.getMethodParamCount(i);
+ excCount = m_reader.getMethodExcCount(i);
+
+ if (pFinishedTypes->count(returnType) == 0)
+ {
+ pFinishedTypes->insert(returnType);
+ dumpCppuGetType(o, returnType, sal_True, eDeclFlag);
+ }
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ paramType = m_reader.getMethodParamType(i, j);
+
+ if (pFinishedTypes->count(paramType) == 0)
+ {
+ pFinishedTypes->insert(paramType);
+ dumpCppuGetType(o, paramType, sal_True, eDeclFlag);
+ }
+ }
+
+ for (j=0; j < excCount; j++)
+ {
+ excType = m_reader.getMethodExcType(i, j);
+ if (pFinishedTypes->count(excType) == 0)
+ {
+ pFinishedTypes->insert(excType);
+ dumpCppuGetType(o, excType, sal_True, eDeclFlag);
+ }
+ }
+ }
+}
+
+//*************************************************************************
+// ModuleType
+//*************************************************************************
+ModuleType::ModuleType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ModuleType::~ModuleType()
+{
+
+}
+
+sal_Bool ModuleType::dump(CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_False;
+
+ if (pOptions->isValid("-U"))
+ m_cppuTypeDynamic = sal_True;
+
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ OString tmpName(m_typeName);
+
+ if (tmpName.equals("/"))
+ tmpName = "global";
+ else
+ tmpName += "/" + m_typeName.getToken(m_typeName.getTokenCount('/') - 1, '/');
+
+ OString tmpFileName;
+ OString hFileName = createFileNameFromType(outPath, tmpName, ".hdl");
+
+ sal_Bool bFileExists = sal_False;
+ sal_Bool bFileCheck = sal_False;
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hFile;
+
+ if ( bFileCheck )
+ hFile.openFile(tmpFileName);
+ else
+ hFile.openFile(hFileName);
+
+ if(!hFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHFile(hFile);
+
+ hFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ OString hxxFileName = createFileNameFromType(outPath, tmpName, ".hpp");
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmp");
+ bFileCheck = sal_True;
+ }
+
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hxxFile;
+
+ if ( bFileCheck )
+ hxxFile.openFile(tmpFileName);
+ else
+ hxxFile.openFile(hxxFileName);
+
+ if(!hxxFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hxxFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHxxFile(hxxFile);
+
+ hxxFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ return ret;
+}
+
+sal_Bool ModuleType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ sal_Bool bSpecialDefine = sal_True;
+
+ if (m_reader.getTypeClass() == RT_TYPE_CONSTANTS)
+ {
+ bSpecialDefine = sal_False;
+ }
+
+ OString headerDefine(dumpHeaderDefine(o, "HDL", bSpecialDefine));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpNameSpace(o, sal_True, sal_True);
+ o << endl;
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ {
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ o << "static const ";
+ dumpType(o, fieldType);
+ o << " " << fieldName << " = ";
+ dumpConstantValue(o, i);
+ o << ";\n";
+ }
+ }
+
+ o << endl;
+ dumpNameSpace(o, sal_False, sal_True);
+ o << "\n#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool ModuleType::hasConstants()
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+sal_Bool ModuleType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ sal_Bool bSpecialDefine = sal_True;
+
+ if (m_reader.getTypeClass() == RT_TYPE_CONSTANTS)
+ {
+ bSpecialDefine = sal_False;
+ }
+
+ OString headerDefine(dumpHeaderDefine(o, "HPP", bSpecialDefine));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl", bSpecialDefine);
+
+ o << "\n#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+//*************************************************************************
+// ConstantsType
+//*************************************************************************
+ConstantsType::ConstantsType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : ModuleType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ConstantsType::~ConstantsType()
+{
+
+}
+
+sal_Bool ConstantsType::dump(CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_False;
+
+ if (pOptions->isValid("-U"))
+ m_cppuTypeDynamic = sal_True;
+
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ OString tmpFileName;
+ OString hFileName = createFileNameFromType(outPath, m_typeName, ".hdl");
+
+ sal_Bool bFileExists = sal_False;
+ sal_Bool bFileCheck = sal_False;
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hFile;
+
+ if ( bFileCheck )
+ hFile.openFile(tmpFileName);
+ else
+ hFile.openFile(hFileName);
+
+ if(!hFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHFile(hFile);
+
+ hFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ OString hxxFileName = createFileNameFromType(outPath, m_typeName, ".hpp");
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmp");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hxxFile;
+
+ if ( bFileCheck )
+ hxxFile.openFile(tmpFileName);
+ else
+ hxxFile.openFile(hxxFileName);
+
+ if(!hxxFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hxxFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHxxFile(hxxFile);
+
+ hxxFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// StructureType
+//*************************************************************************
+StructureType::StructureType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+StructureType::~StructureType()
+{
+
+}
+
+sal_Bool StructureType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpNameSpace(o);
+
+ o << "\n#ifdef SAL_W32\n"
+ << "# pragma pack(push, 8)\n"
+ << "#elif defined(SAL_OS2)\n"
+ << "# pragma pack(8)\n"
+ << "#endif\n\n";
+
+ o << "struct " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " : public " << scopedName(m_typeName, superType);
+
+ o << "\n{\n";
+ inc();
+ o << indent() << "inline " << m_name << "();\n\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i=0;
+ if (fieldCount > 0 || getInheritedMemberCount() > 0)
+ {
+ o << indent() << m_name << "(";
+
+ sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (superHasMember)
+ o << ", ";
+ else
+ superHasMember = sal_True;
+
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " __" << fieldName;
+ }
+ o << ");\n\n";
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ o << indent();
+ dumpType(o, fieldType);
+ o << " " << fieldName << ";\n";
+ }
+
+ dec();
+ o << "};\n\n";
+
+ o << "#ifdef SAL_W32\n"
+ << "# pragma pack(pop)\n"
+ << "#elif defined(SAL_OS2)\n"
+ << "# pragma pack()\n"
+ << "#endif\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+ o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+ << "class Type;\n} } } }\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool StructureType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+
+ dumpDepIncludes(o, m_typeName, "hpp");
+ o << endl;
+
+ dumpNameSpace(o);
+ o << endl;
+
+ o << "inline " << m_name << "::" << m_name << "()\n";
+ inc();
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool first = sal_True;
+ if (superType.getLength() > 0)
+ {
+ o << indent() << ": " << scopedName(m_typeName, superType) << "()\n";
+ first = sal_False;
+ }
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i = 0;
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << ": ";
+ } else
+ o << indent() << ", ";
+
+ o << fieldName;
+ dumpTypeInit(o, fieldType);
+ o << endl;
+ }
+ dec();
+ o << "{\n}\n\n";
+
+ if (fieldCount > 0 || getInheritedMemberCount() > 0)
+ {
+ o << indent() << "inline " << m_name << "::" << m_name << "(";
+
+ sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (superHasMember)
+ o << ", ";
+ else
+ superHasMember = sal_True;
+
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " __" << fieldName;
+ }
+ o << ")\n";
+
+ inc();
+ sal_Bool first = sal_True;
+ if (superType.getLength() > 0)
+ {
+ o << indent() << ": " << scopedName(m_typeName, superType) << "(";
+ dumpSuperMember(o, superType, sal_False);
+ o << ")\n";
+ first = sal_False;
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << ": ";
+ } else
+ o << indent() << ", ";
+
+ o << fieldName << "(__" << fieldName << ")\n";
+ }
+
+ dec();
+ o << "{\n}\n\n";
+ }
+
+ dumpNameSpace(o, sal_False);
+
+ o << endl;
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool StructureType::dumpSuperMember(FileStream& o, const OString& superType, sal_Bool bWithType)
+{
+ sal_Bool hasMember = sal_False;
+
+ if (superType.getLength() > 0)
+ {
+ TypeReader aSuperReader(m_typeMgr.getTypeReader(superType));
+
+ if (aSuperReader.isValid())
+ {
+ hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType);
+
+ sal_uInt32 fieldCount = aSuperReader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_Int16 i=0; i < fieldCount; i++)
+ {
+ access = aSuperReader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = aSuperReader.getFieldName(i);
+ fieldType = aSuperReader.getFieldType(i);
+
+ if (hasMember)
+ {
+ o << ", ";
+ } else
+ {
+ hasMember = (fieldCount > 0);
+ }
+
+ if (bWithType)
+ {
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " ";
+ }
+ o << "__" << fieldName;
+ }
+ }
+/*
+ RegistryKey superKey = m_typeMgr.getTypeKey(superType);
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!superKey.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ if (!superKey.getValue(OUString(), pBuffer) )
+ {
+ TypeReader aSuperReader(rReaderLoader, pBuffer, valueSize, sal_True);
+
+ hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType);
+
+ sal_uInt32 fieldCount = aSuperReader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_Int16 i=0; i < fieldCount; i++)
+ {
+ access = aSuperReader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = aSuperReader.getFieldName(i);
+ fieldType = aSuperReader.getFieldType(i);
+
+ if (hasMember)
+ {
+ o << ", ";
+ } else
+ {
+ hasMember = (fieldCount > 0);
+ }
+
+ if (bWithType)
+ {
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " ";
+ }
+ o << "__" << fieldName;
+ }
+ }
+
+ rtl_freeMemory(pBuffer);
+ }
+*/
+ }
+
+ return hasMember;
+}
+
+//*************************************************************************
+// ExceptionType
+//*************************************************************************
+ExceptionType::ExceptionType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ExceptionType::~ExceptionType()
+{
+
+}
+
+sal_Bool ExceptionType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpNameSpace(o);
+
+ o << "\nclass " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " : public " << scopedName(m_typeName, superType);
+
+ o << "\n{\npublic:\n";
+ inc();
+// o << indent() << "inline " << m_name << "();\n\n";
+ o << indent() << "inline " << m_name << "() { }\n\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i = 0;
+
+ if (fieldCount > 0 || getInheritedMemberCount() > 0)
+ {
+ o << indent() << "inline " << m_name << "(";
+
+ sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (superHasMember)
+ o << ", ";
+ else
+ superHasMember = sal_True;
+
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " __" << fieldName;
+ }
+ o << ");\n\n";
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ o << indent();
+ dumpType(o, fieldType);
+ o << " " << fieldName << ";\n";
+ }
+
+
+ dec();
+ o << "};\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+ o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+ << "class Type;\n} } } }\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool ExceptionType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+
+ dumpDepIncludes(o, m_typeName, "hpp");
+ o << endl;
+
+ dumpNameSpace(o);
+ o << endl;
+//
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool first = sal_True;
+/*
+ o << "inline " << m_name << "::" << m_name << "()\n";
+ inc();
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool first = sal_True;
+ if (superType.getLength() > 0)
+ {
+ o << indent() << ": " << scopedName(m_typeName, superType) << "()\n";
+ first = sal_False;
+ }
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i = 0;
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << ": ";
+ } else
+ o << indent() << ", ";
+
+ o << fieldName;
+ dumpTypeInit(o, fieldType);
+ o << endl;
+ }
+ dec();
+ o << "{\n";
+ inc();
+ dumpCppuGetType(o, m_typeName, sal_True);
+ dec();
+ o << "}\n\n";
+*/
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i = 0;
+//
+ if (fieldCount > 0 || getInheritedMemberCount() > 0)
+ {
+ o << indent() << "inline " << m_name << "::" << m_name << "(";
+
+ sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (superHasMember)
+ o << ", ";
+ else
+ superHasMember = sal_True;
+
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " __" << fieldName;
+ }
+ o << ")\n";
+
+ inc();
+ sal_Bool first = sal_True;
+ if (superType.getLength() > 0)
+ {
+ o << indent() << ": " << scopedName(m_typeName, superType) << "(";
+ dumpSuperMember(o, superType, sal_False);
+ o << ")\n";
+ first = sal_False;
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << ": ";
+ } else
+ o << indent() << ", ";
+
+ o << fieldName << "(__" << fieldName << ")\n";
+ }
+
+ dec();
+ o << "{ }\n\n";
+/*
+ o << "{\n";
+ inc();
+ dumpCppuGetType(o, m_typeName, sal_True);
+ dec();
+ o << "}\n\n";
+*/
+ }
+
+ dumpNameSpace(o, sal_False);
+
+ o << endl;
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+sal_Bool ExceptionType::dumpSuperMember(FileStream& o, const OString& superType, sal_Bool bWithType)
+{
+ sal_Bool hasMember = sal_False;
+
+ if (superType.getLength() > 0)
+ {
+ TypeReader aSuperReader(m_typeMgr.getTypeReader(superType));
+
+ if (aSuperReader.isValid())
+ {
+ hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType);
+
+ sal_uInt32 fieldCount = aSuperReader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = aSuperReader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = aSuperReader.getFieldName(i);
+ fieldType = aSuperReader.getFieldType(i);
+
+ if (hasMember)
+ {
+ o << ", ";
+ } else
+ {
+ hasMember = (fieldCount > 0);
+ }
+
+ if (bWithType)
+ {
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " ";
+ }
+ o << "__" << fieldName;
+ }
+ }
+/*
+ RegistryKey superKey = m_typeMgr.getTypeKey(superType);
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!superKey.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ if (!superKey.getValue(OUString(), pBuffer) )
+ {
+ TypeReader aSuperReader(rReaderLoader, pBuffer, valueSize, sal_True);
+
+ hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType);
+
+ sal_uInt32 fieldCount = aSuperReader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = aSuperReader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = aSuperReader.getFieldName(i);
+ fieldType = aSuperReader.getFieldType(i);
+
+ if (hasMember)
+ {
+ o << ", ";
+ } else
+ {
+ hasMember = (fieldCount > 0);
+ }
+
+ if (bWithType)
+ {
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " ";
+ }
+ o << "__" << fieldName;
+ }
+ }
+
+ rtl_freeMemory(pBuffer);
+ }
+*/
+ }
+
+ return hasMember;
+}
+
+//*************************************************************************
+// EnumType
+//*************************************************************************
+EnumType::EnumType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+EnumType::~EnumType()
+{
+
+}
+
+sal_Bool EnumType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+
+ dumpNameSpace(o);
+
+ o << "\nenum " << m_name << "\n{\n";
+ inc();
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ RTConstValue constValue;
+ OString fieldName;
+ sal_uInt32 value=0;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ constValue = m_reader.getFieldConstValue(i);
+
+ if (constValue.m_type == RT_TYPE_INT32)
+ value = constValue.m_value.aLong;
+ else
+ value++;
+
+ o << indent() << m_name << "_" << fieldName << " = "
+ << value << ",\n";
+ }
+
+ o << indent() << m_name << "_MAKE_FIXED_SIZE = SAL_MAX_ENUM\n";
+
+ dec();
+ o << "};\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+ o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+ << "class Type;\n} } } }\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool EnumType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+void EnumType::dumpGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ if ( m_cppuTypeLeak )
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+ if ( !m_cppuTypeDynamic )
+ {
+ dumpCGetCppuType(o);
+ return;
+ }
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+
+ o << indent() << "typelib_static_enum_type_init( &s_pType_" << typeName << ",\n";
+ inc(31);
+ o << indent() << "\"" << m_typeName.replace('/', '.') << "\",\n"
+ << indent() << scopedName(OString(), m_typeName) << "_" << m_reader.getFieldName(0) << " );\n";
+ dec(31);
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ dec();
+ o << indent() << "}\n";
+
+ return;
+}
+
+void EnumType::dumpCGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_typeName.replace('/', '.') << "\") );\n\n";
+
+ if ( m_cppuTypeDynamic )
+ {
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ } else
+ {
+ o << indent() << "// Start inline typedescription generation\n"
+ << indent() << "typelib_TypeDescription * pTD = 0;\n\n";
+
+ sal_uInt32 count = m_reader.getFieldCount();
+ o << indent() << "rtl_uString* enumValueNames[" << count << "];\n";
+ sal_uInt32 i;
+ for (i = 0; i < count; i++)
+ {
+ o << indent() << "::rtl::OUString sEnumValue" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_reader.getFieldName(i) << "\") );\n";
+ o << indent() << "enumValueNames[" << i << "] = sEnumValue" << i << ".pData;\n";
+ }
+
+ o << "\n" << indent() << "sal_Int32 enumValues[" << count << "];\n";
+ RTConstValue constValue;
+ sal_Int32 value=0;
+ for (i = 0; i < count; i++)
+ {
+ o << indent() << "enumValues[" << i << "] = ";
+ constValue = m_reader.getFieldConstValue(i);
+ if (constValue.m_type == RT_TYPE_INT32)
+ value = constValue.m_value.aLong;
+ else
+ value++;
+ o << value << ";\n";
+ }
+
+ o << "\n" << indent() << "typelib_typedescription_newEnum( &pTD,\n";
+ inc();
+ o << indent() << "sTypeName.pData,\n"
+ << indent() << "(sal_Int32)" << scopedName("", m_typeName, sal_False)
+ << "_" << m_reader.getFieldName(0) << ",\n"
+ << indent() << count << ", enumValueNames, enumValues );\n\n";
+ dec();
+
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pTD );\n";
+ o << indent() << "typelib_typedescription_release( pTD );\n"
+ << indent() << "// End inline typedescription generation\n\n";
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n\n"
+ << indent() << "return *pType_" << typeName << ";\n";
+
+ dec();
+ o << "}\n";
+}
+
+//*************************************************************************
+// TypeDefType
+//*************************************************************************
+TypeDefType::TypeDefType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+TypeDefType::~TypeDefType()
+{
+
+}
+
+sal_Bool TypeDefType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpNameSpace(o);
+
+ o << "\ntypedef ";
+ dumpType(o, m_reader.getSuperTypeName());
+ o << " " << m_name << ";\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+// o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+// << "class Type;\n} } } }\n\n";
+// o << "inline const ::com::sun::star::uno::Type& SAL_CALL get_" << m_typeName.replace('/', '_')
+// << "_Type( );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool TypeDefType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hpp");
+ o << endl;
+
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+void TypeDefType::dumpGetCppuType(FileStream& o)
+{
+ if ( m_cppuTypeLeak )
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+ if ( !m_cppuTypeDynamic )
+ {
+ dumpCGetCppuType(o);
+ return;
+ }
+}
+
+void TypeDefType::dumpCGetCppuType(FileStream& o)
+{
+/*
+ OString typeName(m_typeName.replace('/', '_'));
+
+ if (m_cppuTypeLeak)
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL get_" << typeName << "_Type( )\n" << "{\n";
+ inc();
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_typeName.replace('/', '.') << "\") );\n\n";
+
+ if ( m_cppuTypeDynamic )
+ {
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ } else
+ {
+ o << indent() << "// Start inline typedescription generation\n"
+ << indent() << "typelib_TypeDescription * pTD = 0;\n";
+
+ OString superType(m_reader.getSuperTypeName());
+ o << indent() << "typelib_TypeDescription * pITD = 0;\n";
+
+ o << indent() << "getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 ).getDescription( &pITD );\n\n";
+
+ o << indent() << "typelib_typedescription_new(\n";
+ inc();
+ o << indent() << "&pTD,\n"
+ << indent() << "(typelib_TypeClass)::com::sun::star::uno::TypeClass_TYPEDEF, "
+ << "sTypeName.pData,\n";
+
+ o << indent() << "pITD,\n" << indent() << "0, 0 );\n\n";
+ dec();
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pTD );\n";
+ o << indent() << "typelib_typedescription_release( pITD );\n"
+ << indent() << "typelib_typedescription_release( pTD );\n"
+ << indent() << "// End inline typedescription generation\n\n";
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n\n"
+ << indent() << "return *pType_" << typeName << ";\n";
+ dec();
+ o << "}\n";
+*/
+}
+
+void TypeDefType::dumpLGetCppuType(FileStream& o)
+{
+/*
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL get_" << typeName << "_Type( )\n{\n";
+ inc();
+
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "const ::com::sun::star::uno::Type& rType = getCppuType( ( ";
+ dumpType(o, m_reader.getSuperTypeName(), sal_True, sal_False);
+ o << " *)0 );\n\n";
+
+ o << indent() << "::typelib_static_typedef_type_init( &s_pType_" << typeName
+ << ", \"" << m_typeName.replace('/', '.') << "\", rType.getTypeLibType() );\n";
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ dec();
+ o << indent() << "}\n";
+*/
+}
+
+//*************************************************************************
+// produceType
+//*************************************************************************
+sal_Bool produceType(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ if (typeDependencies.isGenerated(typeName))
+ return sal_True;
+
+ TypeReader reader(typeMgr.getTypeReader(typeName));
+
+ if (!reader.isValid())
+ {
+ if (typeName.equals("/"))
+ return sal_True;
+ else
+ return sal_False;
+ }
+
+/* RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+
+ if (!typeKey.isValid())
+ return sal_False;
+*/
+ if( !checkTypeDependencies(typeMgr, typeDependencies, typeName))
+ return sal_False;
+/*
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (typeKey.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ if (typeName.equals("/"))
+ return sal_True;
+ else
+ return sal_False;
+ }
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+
+ if (typeKey.getValue(OUString(), pBuffer))
+ {
+ rtl_freeMemory(pBuffer);
+ return sal_False;
+ }
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_True);
+
+ rtl_freeMemory(pBuffer);
+*/
+ RTTypeClass typeClass = reader.getTypeClass();
+ sal_Bool ret = sal_False;
+ switch (typeClass)
+ {
+ case RT_TYPE_INTERFACE:
+ {
+ InterfaceType iType(reader, typeName, typeMgr, typeDependencies);
+ ret = iType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = iType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_MODULE:
+ {
+ ModuleType mType(reader, typeName, typeMgr, typeDependencies);
+ if (mType.hasConstants())
+ {
+ ret = mType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+// ret = mType.dumpDependedTypes(pOptions);
+ } else
+ {
+ typeDependencies.setGenerated(typeName);
+ ret = sal_True;
+ }
+ }
+ break;
+ case RT_TYPE_STRUCT:
+ {
+ StructureType sType(reader, typeName, typeMgr, typeDependencies);
+ ret = sType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = sType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_ENUM:
+ {
+ EnumType enType(reader, typeName, typeMgr, typeDependencies);
+ ret = enType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = enType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_EXCEPTION:
+ {
+ ExceptionType eType(reader, typeName, typeMgr, typeDependencies);
+ ret = eType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = eType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_TYPEDEF:
+ {
+ TypeDefType tdType(reader, typeName, typeMgr, typeDependencies);
+ ret = tdType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = tdType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_CONSTANTS:
+ {
+ ConstantsType cType(reader, typeName, typeMgr, typeDependencies);
+ if (cType.hasConstants())
+ {
+ ret = cType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+// ret = cType.dumpDependedTypes(pOptions);
+ } else
+ {
+ typeDependencies.setGenerated(typeName);
+ ret = sal_True;
+ }
+ }
+ break;
+ case RT_TYPE_SERVICE:
+ case RT_TYPE_OBJECT:
+ ret = sal_True;
+ break;
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// scopedName
+//*************************************************************************
+OString scopedName(const OString& scope, const OString& type,
+ sal_Bool bNoNameSpace)
+{
+ sal_uInt32 count = type.getTokenCount('/');
+ sal_uInt32 offset = 0;
+/*
+ if (count > 1)
+ offset = count - 1;
+ else
+ return type;
+*/
+ if (count == 1)
+ return type;
+
+ if (bNoNameSpace)
+ return type.getToken(count - 1, '/');
+
+ // scoped name only if the namespace is not equal
+/*
+ if (scope.lastIndexOf('/') > 0)
+ {
+ OString tmpScp(scope.copy(0, scope.lastIndexOf('/')));
+ OString tmpScp2(type.copy(0, type.lastIndexOf('/')));
+
+ if (tmpScp == tmpScp2)
+ return type.getToken(count - 1, '/');
+ }
+*/
+
+// OStringBuffer tmpBuf(type.getLength() + offset);
+// tmpBuf.append(type.getToken(0, '/'));
+// for (int i=1; i < count; i++)
+ OStringBuffer tmpBuf(type.getLength() + count);
+ for (int i=0; i < count; i++)
+ {
+ tmpBuf.append("::");
+ tmpBuf.append(type.getToken(i, '/'));
+ }
+
+ return tmpBuf.makeStringAndClear();
+}
+
+//*************************************************************************
+// shortScopedName
+//*************************************************************************
+OString shortScopedName(const OString& scope, const OString& type,
+ sal_Bool bNoNameSpace)
+{
+ sal_uInt32 count = type.getTokenCount('/');
+ sal_uInt32 offset = 0;
+
+ if (count > 1)
+// offset = count - 2;
+ offset = count - 1;
+ else
+ return OString();
+
+ if (bNoNameSpace)
+ return OString();
+
+ // scoped name only if the namespace is not equal
+ if (scope.lastIndexOf('/') > 0)
+ {
+ OString tmpScp(scope.copy(0, scope.lastIndexOf('/')));
+ OString tmpScp2(type.copy(0, type.lastIndexOf('/')));
+
+ if (tmpScp == tmpScp2)
+ return OString();
+ }
+
+ OStringBuffer tmpBuf(type.lastIndexOf('/') + offset);
+
+ for (int i=0; i < count - 1; i++)
+ {
+ tmpBuf.append("::");
+ tmpBuf.append(type.getToken(i, '/'));
+ }
+
+ return tmpBuf.makeStringAndClear();
+}
+
+
diff --git a/codemaker/source/cppumaker/cpputype.hxx b/codemaker/source/cppumaker/cpputype.hxx
new file mode 100644
index 000000000000..7002fd12d181
--- /dev/null
+++ b/codemaker/source/cppumaker/cpputype.hxx
@@ -0,0 +1,325 @@
+/*************************************************************************
+ *
+ * $RCSfile: cpputype.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUMAKER_CPPUTYPE_HXX_
+#define _CPPUMAKER_CPPUTYPE_HXX_
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+enum BASETYPE
+{
+ BT_INVALID,
+ BT_VOID,
+ BT_ANY,
+ BT_TYPE,
+ BT_BOOLEAN,
+ BT_CHAR,
+ BT_STRING,
+ BT_FLOAT,
+ BT_DOUBLE,
+ BT_OCTET,
+ BT_BYTE,
+ BT_SHORT,
+ BT_LONG,
+ BT_HYPER,
+ BT_UNSIGNED_SHORT,
+ BT_UNSIGNED_LONG,
+ BT_UNSIGNED_HYPER
+};
+
+
+enum CppuTypeDecl
+{
+ CPPUTYPEDECL_ALLTYPES,
+ CPPUTYPEDECL_NOINTERFACES,
+ CPPUTYPEDECL_ONLYINTERFACES
+};
+
+class CppuOptions;
+class FileStream;
+
+class CppuType
+{
+public:
+ CppuType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~CppuType();
+
+ virtual sal_Bool dump(CppuOptions* pOptions) throw( CannotDumpException );
+ virtual sal_Bool dumpDependedTypes(CppuOptions* pOptions) throw( CannotDumpException );
+ virtual sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ) = 0;
+ virtual sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException ) = 0;
+
+ virtual ::rtl::OString dumpHeaderDefine(FileStream& o, sal_Char* prefix, sal_Bool bExtended=sal_False);
+ virtual void dumpDefaultHIncludes(FileStream& o);
+ virtual void dumpDefaultHxxIncludes(FileStream& o);
+ virtual void dumpInclude(FileStream& o, const ::rtl::OString& typeName, sal_Char* prefix, sal_Bool bExtended=sal_False, sal_Bool bCaseSensitive=sal_False);
+
+ virtual void dumpDepIncludes(FileStream& o, const ::rtl::OString& typeName, sal_Char* prefix);
+
+ virtual void dumpNameSpace(FileStream& o, sal_Bool bOpen = sal_True, sal_Bool bFull = sal_False, const ::rtl::OString& type="");
+ virtual void dumpGetCppuType(FileStream& o);
+ virtual void dumpCGetCppuType(FileStream& o);
+ virtual void dumpLGetCppuType(FileStream& o);
+
+ virtual void dumpType(FileStream& o, const ::rtl::OString& type, sal_Bool bConst=sal_False,
+ sal_Bool bRef=sal_False, sal_Bool bNative=sal_False)
+ throw( CannotDumpException );
+ ::rtl::OString getTypeClass(const ::rtl::OString& type="", sal_Bool bCStyle=sal_False);
+ ::rtl::OString getBaseType(const ::rtl::OString& type);
+ void dumpCppuGetType(FileStream& o, const ::rtl::OString& type, sal_Bool bDecl=sal_False, CppuTypeDecl eDeclFlag=CPPUTYPEDECL_ALLTYPES);
+ void dumpTypeInit(FileStream& o, const ::rtl::OString& type);
+ BASETYPE isBaseType(const ::rtl::OString& type);
+
+ ::rtl::OString typeToIdentifier(const ::rtl::OString& type);
+
+ void dumpConstantValue(FileStream& o, sal_uInt16 index);
+
+ virtual sal_uInt32 getMemberCount();
+ virtual sal_uInt32 getInheritedMemberCount();
+
+ void inc(sal_uInt32 num=4);
+ void dec(sal_uInt32 num=4);
+ ::rtl::OString indent();
+ ::rtl::OString indent(sal_uInt32 num);
+protected:
+ virtual sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader);
+
+ ::rtl::OString checkSpecialCppuType(const ::rtl::OString& type);
+ ::rtl::OString checkRealBaseType(const ::rtl::OString& type, sal_Bool bResolveTypeOnly = sal_False);
+ void dumpCppuGetTypeMemberDecl(FileStream& o, CppuTypeDecl eDeclFlag);
+
+protected:
+ sal_uInt32 m_inheritedMemberCount;
+
+ sal_Bool m_cppuTypeLeak;
+ sal_Bool m_cppuTypeDynamic;
+ sal_Bool m_cppuTypeStatic;
+ sal_uInt32 m_indentLength;
+ ::rtl::OString m_typeName;
+ ::rtl::OString m_name;
+ TypeReader m_reader;
+ TypeManager& m_typeMgr;
+ TypeDependency m_dependencies;
+};
+
+class InterfaceType : public CppuType
+{
+public:
+ InterfaceType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~InterfaceType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ void dumpAttributes(FileStream& o);
+ void dumpMethods(FileStream& o);
+ void dumpGetCppuType(FileStream& o);
+ void dumpCGetCppuType(FileStream& o);
+ void dumpCppuAttributeRefs(FileStream& o, sal_uInt32& index);
+ void dumpCppuMethodRefs(FileStream& o, sal_uInt32& index);
+ void dumpCppuAttributes(FileStream& o, sal_uInt32& index);
+ void dumpCppuMethods(FileStream& o, sal_uInt32& index);
+ void dumpAttributesCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag);
+ void dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag );
+
+ sal_uInt32 getMemberCount();
+ sal_uInt32 getInheritedMemberCount();
+
+protected:
+ sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader);
+
+protected:
+ sal_uInt32 m_inheritedMemberCount;
+ sal_Bool m_hasAttributes;
+ sal_Bool m_hasMethods;
+};
+
+class ModuleType : public CppuType
+{
+public:
+ ModuleType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ModuleType();
+
+ virtual sal_Bool dump(CppuOptions* pOptions) throw( CannotDumpException );
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool hasConstants();
+};
+
+class ConstantsType : public ModuleType
+{
+public:
+ ConstantsType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ConstantsType();
+
+ virtual sal_Bool dump(CppuOptions* pOptions) throw( CannotDumpException );
+};
+
+class StructureType : public CppuType
+{
+public:
+ StructureType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~StructureType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ sal_Bool dumpSuperMember(FileStream& o, const ::rtl::OString& super, sal_Bool bWithType);
+};
+
+class ExceptionType : public CppuType
+{
+public:
+ ExceptionType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ExceptionType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ sal_Bool dumpSuperMember(FileStream& o, const ::rtl::OString& super, sal_Bool bWithType);
+};
+
+class EnumType : public CppuType
+{
+public:
+ EnumType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~EnumType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ void dumpGetCppuType(FileStream& o);
+ void dumpCGetCppuType(FileStream& o);
+};
+
+class TypeDefType : public CppuType
+{
+public:
+ TypeDefType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~TypeDefType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ void dumpGetCppuType(FileStream& o);
+ void dumpLGetCppuType(FileStream& o);
+ void dumpCGetCppuType(FileStream& o);
+};
+
+
+sal_Bool produceType(const ::rtl::OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ CppuOptions* pOptions)
+ throw( CannotDumpException );
+
+/**
+ * This function returns a C++ scoped name, represents the namespace
+ * scoping of this type, e.g. com:.sun::star::uno::XInterface. If the scope of
+ * the type is equal scope, the relativ name will be used.
+ */
+::rtl::OString scopedName(const ::rtl::OString& scope, const ::rtl::OString& type,
+ sal_Bool bNoNameSpace=sal_False);
+
+::rtl::OString shortScopedName(const ::rtl::OString& scope, const ::rtl::OString& type,
+ sal_Bool bNoNameSpace=sal_False);
+
+
+#endif // _CPPUMAKER_CPPUTYPE_HXX_
+
diff --git a/codemaker/source/cppumaker/makefile.mk b/codemaker/source/cppumaker/makefile.mk
new file mode 100644
index 000000000000..fe915e3cb1d7
--- /dev/null
+++ b/codemaker/source/cppumaker/makefile.mk
@@ -0,0 +1,104 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=codemaker
+TARGET=cppumaker
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= cppumaker.cxx \
+ cppuoptions.cxx \
+ cpputype.cxx
+
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/cppumaker.obj \
+ $(OBJ)$/cppuoptions.obj \
+ $(OBJ)$/cpputype.obj
+
+APP1STDLIBS=\
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(REGLIB) \
+ $(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+= \
+ $(LIBCIMT) $(LIBCMT)
+.ENDIF
+
+APP1LIBS= \
+ $(LB)$/codemaker.lib
+
+.INCLUDE : target.mk
diff --git a/codemaker/source/javamaker/javamaker.cxx b/codemaker/source/javamaker/javamaker.cxx
new file mode 100644
index 000000000000..3e1714748f1f
--- /dev/null
+++ b/codemaker/source/javamaker/javamaker.cxx
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * $RCSfile: javamaker.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+#include "javaoptions.hxx"
+#include "javatype.hxx"
+
+using namespace rtl;
+
+sal_Bool produceAllTypes(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ JavaOptions* pOptions,
+ sal_Bool bFullScope)
+ throw( CannotDumpException )
+{
+ if (!produceType(typeName, typeMgr, typeDependencies, pOptions))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+
+ RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+ RegistryKeyNames subKeys;
+
+ if (typeKey.getKeyNames(OUString(), subKeys))
+ return sal_False;
+
+ OString tmpName;
+ for (sal_uInt32 i=0; i < subKeys.getLength(); i++)
+ {
+ tmpName = OUStringToOString(subKeys.getElement(i), RTL_TEXTENCODING_UTF8);
+
+ if (pOptions->isValid("-B"))
+ tmpName = tmpName.copy(tmpName.indexOf('/', 1) + 1);
+ else
+ tmpName = tmpName.copy(1);
+
+ if (bFullScope)
+ {
+ if (!produceAllTypes(tmpName, typeMgr, typeDependencies, pOptions, sal_True))
+ return sal_False;
+ } else
+ {
+ if (!produceType(tmpName, typeMgr, typeDependencies, pOptions))
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ JavaOptions options;
+
+ try
+ {
+ if (!options.initOptions(argc, argv))
+ {
+ exit(1);
+ }
+ }
+ catch( IllegalArgument& e)
+ {
+ fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr());
+ exit(99);
+ }
+
+ RegistryTypeManager typeMgr;
+ TypeDependency typeDependencies;
+
+ if (!typeMgr.init(!options.isValid("-T"), options.getInputFiles()))
+ {
+ fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr());
+ exit(99);
+ }
+
+ if (options.isValid("-B"))
+ {
+ typeMgr.setBase(options.getOption("-B"));
+ }
+
+ try
+ {
+ if (options.isValid("-T"))
+ {
+ OString tOption(options.getOption("-T"));
+ sal_uInt32 count = tOption.getTokenCount(';');
+
+ OString typeName, tmpName;
+ sal_Bool ret = sal_False;
+ for (sal_uInt32 i = 0; i < count; i++)
+ {
+ typeName = tOption.getToken(i, ';');
+
+ tmpName = typeName.getToken(typeName.getTokenCount('.') - 1, '.');
+ if (tmpName == "*")
+ {
+ // produce this type and his scope, but the scope is not recursively generated.
+ if (typeName.equals("*"))
+ {
+ tmpName = "/";
+ } else
+ {
+ tmpName = typeName.copy(0, typeName.lastIndexOf('.')).replace('.', '/');
+ if (tmpName.getLength() == 0)
+ tmpName = "/";
+ else
+ tmpName.replace('.', '/');
+ }
+ ret = produceAllTypes(tmpName, typeMgr, typeDependencies, &options, sal_False);
+ } else
+ {
+ // produce only this type
+ ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies, &options);
+ }
+
+ if (!ret)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+ }
+ } else
+ {
+ // produce all types
+ if (!produceAllTypes("/", typeMgr, typeDependencies, &options, sal_True))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "an error occurs while dumping all types.");
+ exit(99);
+ }
+ }
+ }
+ catch( CannotDumpException& e)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ e.m_message.getStr());
+ exit(99);
+ }
+
+ return 0;
+}
+
+
diff --git a/codemaker/source/javamaker/javaoptions.cxx b/codemaker/source/javamaker/javaoptions.cxx
new file mode 100644
index 000000000000..750fecb46a59
--- /dev/null
+++ b/codemaker/source/javamaker/javaoptions.cxx
@@ -0,0 +1,246 @@
+/*************************************************************************
+ *
+ * $RCSfile: javaoptions.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdio.h>
+
+#include "javaoptions.hxx"
+
+using namespace rtl;
+
+sal_Bool JavaOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile)
+ throw( IllegalArgument )
+{
+ sal_Bool ret = sal_True;
+ sal_uInt16 i=0;
+
+ if (!bCmdFile)
+ {
+ bCmdFile = sal_True;
+
+ m_program = av[0];
+
+ if (ac < 2)
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ }
+
+ i = 1;
+ } else
+ {
+ i = 0;
+ }
+
+ char *s=NULL;
+ for (i; i < ac; i++)
+ {
+ if (av[i][0] == '-')
+ {
+ switch (av[i][1])
+ {
+ case 'O':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-O', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-O"] = OString(s);
+ break;
+ case 'B':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-B', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-B"] = OString(s);
+ break;
+ case 'T':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-T', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ if (m_options.count("-T") > 0)
+ {
+ OString tmp(m_options["-T"]);
+ tmp = tmp + ";" + s;
+ m_options["-T"] = tmp;
+ } else
+ {
+ m_options["-T"] = OString(s);
+ }
+ break;
+ default:
+ throw IllegalArgument("the option is unknown" + OString(av[i]));
+ break;
+ }
+ } else
+ {
+ if (av[i][0] == '@')
+ {
+ FILE* cmdFile = fopen(av[i]+1, "r");
+ if( cmdFile == NULL )
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ } else
+ {
+ int rargc=0;
+ char* rargv[512];
+ char buffer[512];
+
+ while ( fscanf(cmdFile, "%s", buffer) != EOF )
+ {
+ rargv[rargc]= strdup(buffer);
+ rargc++;
+ }
+ fclose(cmdFile);
+
+ ret = initOptions(rargc, rargv, bCmdFile);
+
+ for (long i=0; i < rargc; i++)
+ {
+ free(rargv[i]);
+ }
+ }
+ } else
+ {
+ m_inputFiles.push_back(av[i]);
+ }
+ }
+ }
+
+ return ret;
+}
+
+OString JavaOptions::prepareHelp()
+{
+ OString help("\nusing: ");
+ help += m_program + " [-options] file_1 ... file_n\nOptions:\n";
+ help += " -O<path> = path describes the root directory for the generated output.\n";
+ help += " The output directory tree is generated under this directory.\n";
+ help += " -T<name> = name specifies a type or a list of types. The output for this\n";
+ help += " [t1;...] type is generated. If no '-T' option is specified,\n";
+ help += " then output for all types is generated.\n";
+ help += " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
+ help += " -B<name> = name specifies the base node. All types are searched under this\n";
+ help += " node. Default is the root '/' of the registry files.\n";
+ help += prepareVersion();
+
+ return help;
+}
+
+OString JavaOptions::prepareVersion()
+{
+ OString version("\nSun Microsystems (R) ");
+ version += m_program + " Version 2.0\n\n";
+
+ return version;
+}
+
+
diff --git a/codemaker/source/javamaker/javaoptions.hxx b/codemaker/source/javamaker/javaoptions.hxx
new file mode 100644
index 000000000000..5a6488db7420
--- /dev/null
+++ b/codemaker/source/javamaker/javaoptions.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * $RCSfile: javaoptions.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUMAKER_CPPUOPTIONS_HXX_
+#define _CPPUMAKER_CPPUOPTIONS_HXX_
+
+#include <codemaker/options.hxx>
+
+class JavaOptions : public Options
+{
+public:
+ JavaOptions()
+ : Options() {}
+
+ ~JavaOptions() {}
+
+ sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
+ throw( IllegalArgument );
+
+ ::rtl::OString prepareHelp();
+
+ ::rtl::OString prepareVersion();
+
+protected:
+};
+
+#endif // _CPPUMAKER_CPPUOPTIONS_HXX_
diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx
new file mode 100644
index 000000000000..241a5fb787fe
--- /dev/null
+++ b/codemaker/source/javamaker/javatype.cxx
@@ -0,0 +1,1977 @@
+/*************************************************************************
+ *
+ * $RCSfile: javatype.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#include "javatype.hxx"
+#include "javaoptions.hxx"
+
+using namespace rtl;
+
+//*************************************************************************
+// JavaType
+//*************************************************************************
+JavaType::JavaType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : m_indentLength(0)
+ , m_typeName(typeName)
+ , m_name(typeName.getToken(typeName.getTokenCount('/') - 1, '/'))
+ , m_reader(typeReader)
+ , m_typeMgr((TypeManager&)typeMgr)
+ , m_dependencies(typeDependencies)
+{
+}
+
+JavaType::~JavaType()
+{
+
+}
+
+sal_Bool JavaType::dump(JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_False;
+
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ OString fileName = createFileNameFromType(outPath, m_typeName, ".java");
+
+ FileStream javaFile(fileName);
+
+ if(!javaFile.isValid())
+ {
+ OString message("cannot open ");
+ message += fileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ return dumpFile(javaFile);
+}
+
+sal_Bool JavaType::dumpDependedTypes(JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_True;
+
+ TypeUsingSet usingSet(m_dependencies.getDependencies(m_typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+ OString typeName;
+ sal_Int32 index = 0;
+ while (iter != usingSet.end())
+ {
+ typeName = (*iter).m_type;
+ if ((index = typeName.lastIndexOf(']')) > 0)
+ typeName = typeName.copy(index + 1);
+
+ if (getBaseType(typeName).getLength() == 0)
+ {
+ if (!produceType(typeName,
+ m_typeMgr,
+ m_dependencies,
+ pOptions))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+ }
+ iter++;
+ }
+
+ return ret;
+}
+
+void JavaType::dumpPackage(FileStream& o, sal_Bool bFullScope)
+{
+ if (m_typeName.equals("/"))
+ return;
+
+ if (bFullScope)
+ {
+ o << "package " << m_typeName.replace('/', '.') << ";\n\n";
+ } else
+ {
+ if (m_typeName.lastIndexOf('/') > 0)
+ o << "package " << m_typeName.copy(0, m_typeName.lastIndexOf('/')).replace('/', '.') << ";\n\n";
+ }
+}
+
+void JavaType::dumpDepImports(FileStream& o, const OString& typeName)
+{
+ TypeUsingSet usingSet(m_dependencies.getDependencies(typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+
+ sal_Int32 index = 0;
+ sal_Int32 seqNum = 0;
+ OString relType;
+ while (iter != usingSet.end())
+ {
+ index = (*iter).m_type.lastIndexOf(']');
+ seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ relType = (*iter).m_type;
+ if (index > 0)
+ relType = relType.copy(index+1);
+
+ if (getBaseType(relType).getLength() == 0 &&
+ m_typeName != relType)
+ {
+ /// dump import;
+ }
+
+ iter++;
+ }
+}
+
+sal_uInt32 JavaType::getMemberCount()
+{
+ sal_uInt32 count = m_reader.getMethodCount();
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ count++;
+ }
+ return count;
+}
+
+void JavaType::dumpType(FileStream& o, const OString& type)
+ throw( CannotDumpException )
+{
+ sal_Int32 index = type.lastIndexOf(']');
+ sal_Int32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(relType);
+
+ switch (typeClass)
+ {
+ case RT_TYPE_INVALID:
+ {
+ OString tmp(getBaseType(relType));
+ if (tmp.getLength() > 0)
+ o << getBaseType(relType);
+ else
+ throw CannotDumpException("Unknown type '" + relType + "', incomplete type library.");
+ }
+ break;
+ case RT_TYPE_TYPEDEF:
+ {
+ OString baseType = checkSpecialJavaType(relType);
+ dumpType(o, baseType);
+ }
+ break;
+ case RT_TYPE_INTERFACE:
+ if (relType.equals("com/sun/star/uno/XInterface"))
+ {
+ o << "java.lang.Object";
+ } else
+ {
+ o << scopedName(m_typeName, relType);
+ }
+ break;
+ case RT_TYPE_STRUCT:
+ case RT_TYPE_ENUM:
+ case RT_TYPE_EXCEPTION:
+ o << scopedName(m_typeName, relType);
+ break;
+ }
+
+ for (sal_Int32 i=0; i < seqNum; i++)
+ {
+ o << "[]";
+ }
+}
+
+OString JavaType::getBaseType(const OString& type)
+{
+ if (type.equals("long"))
+ return "int";
+ if (type.equals("short"))
+ return "short";
+ if (type.equals("hyper"))
+ return "long";
+ if (type.equals("string"))
+ return "String";
+ if (type.equals("boolean"))
+ return type;
+ if (type.equals("char"))
+ return type;
+ if (type.equals("byte"))
+ return type;
+ if (type.equals("any"))
+ return "java.lang.Object";
+ if (type.equals("type"))
+ return "com.sun.star.uno.Type";
+ if (type.equals("float"))
+ return type;
+ if (type.equals("double"))
+ return type;
+ if (type.equals("octet"))
+ return "byte";
+ if (type.equals("void"))
+ return type;
+ if (type.equals("unsigned long"))
+ return "int";
+ if (type.equals("unsigned short"))
+ return "short";
+ if (type.equals("unsigned hyper"))
+ return "long";
+
+ return OString();
+}
+
+sal_Bool JavaType::isUnsigned(const OString& typeName)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ if ( relType.equals("unsigned long") ||
+ relType.equals("unsigned short") ||
+ relType.equals("unsigned hyper") )
+ return sal_True;
+
+ return sal_False;
+}
+
+sal_Bool JavaType::isAny(const OString& typeName)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ if ( relType.equals("any") )
+ return sal_True;
+
+ return sal_False;
+}
+
+sal_Bool JavaType::isInterface(const OString& typeName)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(relType);
+
+ if ( typeClass == RT_TYPE_INTERFACE)
+ return sal_True;
+
+ return sal_False;
+}
+
+void JavaType::dumpTypeInit(FileStream& o, const OString& name, const OString& typeName)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+ sal_Int32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ if (seqNum > 0)
+ {
+ o << indent() << name << " = _static_seq_" << name << ";\n";
+ return;
+ }
+
+ BASETYPE baseType = isBaseType(relType);
+
+ switch (baseType)
+ {
+ case BT_STRING:
+// o << "new String()";
+ o << indent() << name << " = \"\";\n";
+ return;
+ case BT_TYPE:
+ o << indent() << name << " = new com.sun.star.uno.Type();\n";
+ return;
+ case BT_ANY:
+// o << "new java.lang.Object()";
+// return;
+ case BT_BOOLEAN:
+ case BT_CHAR:
+ case BT_FLOAT:
+ case BT_DOUBLE:
+ case BT_BYTE:
+ case BT_SHORT:
+ case BT_LONG:
+ case BT_HYPER:
+ case BT_UNSIGNED_SHORT:
+ case BT_UNSIGNED_LONG:
+ case BT_UNSIGNED_HYPER:
+// o << "0";
+ return;
+ }
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(type);
+
+ if (typeClass == RT_TYPE_ENUM)
+ {
+ o << indent() << name << " = " << type.replace('/', '.') << ".getDefault();\n";
+ return;
+ }
+
+ if (typeClass == RT_TYPE_INTERFACE)
+ {
+// o << "null";
+ return;
+ }
+
+ o << indent() << name << " = new " << type.replace('/', '.') << "();\n";
+}
+
+BASETYPE JavaType::isBaseType(const OString& type)
+{
+ if (type.equals("long"))
+ return BT_LONG;
+ if (type.equals("short"))
+ return BT_SHORT;
+ if (type.equals("hyper"))
+ return BT_HYPER;
+ if (type.equals("string"))
+ return BT_STRING;
+ if (type.equals("boolean"))
+ return BT_BOOLEAN;
+ if (type.equals("char"))
+ return BT_CHAR;
+ if (type.equals("byte"))
+ return BT_BYTE;
+ if (type.equals("any"))
+ return BT_ANY;
+ if (type.equals("float"))
+ return BT_FLOAT;
+ if (type.equals("double"))
+ return BT_DOUBLE;
+ if (type.equals("void"))
+ return BT_VOID;
+ if (type.equals("type"))
+ return BT_TYPE;
+ if (type.equals("unsigned long"))
+ return BT_UNSIGNED_LONG;
+ if (type.equals("unsigned short"))
+ return BT_UNSIGNED_SHORT;
+ if (type.equals("unsigned hyper"))
+ return BT_UNSIGNED_HYPER;
+
+ return BT_INVALID;
+}
+
+OString JavaType::checkSpecialJavaType(const OString& type)
+{
+ OString baseType(type);
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ RegistryKey key;
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+ sal_uInt8* pBuffer=NULL;
+ RTTypeClass typeClass;
+ sal_Bool isTypeDef = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
+
+ while (isTypeDef)
+ {
+ key = m_typeMgr.getTypeKey(baseType);
+
+ if (key.isValid())
+ {
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_False);
+
+ typeClass = reader.getTypeClass();
+
+ if (typeClass == RT_TYPE_TYPEDEF)
+ baseType = reader.getSuperTypeName();
+ else
+ isTypeDef = sal_False;
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ key.closeKey();
+ } else
+ {
+ break;
+ }
+ }
+
+ return baseType;
+}
+
+OString JavaType::checkRealBaseType(const OString& type)
+{
+ sal_Int32 index = type.lastIndexOf(']');
+ OString baseType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ RegistryKey key;
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+ sal_uInt8* pBuffer=NULL;
+ RTTypeClass typeClass;
+ sal_Bool mustBeChecked = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
+
+ while (mustBeChecked)
+ {
+ key = m_typeMgr.getTypeKey(baseType);
+
+ if (key.isValid())
+ {
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_False);
+
+ typeClass = reader.getTypeClass();
+
+ if (typeClass == RT_TYPE_TYPEDEF)
+ {
+ baseType = reader.getSuperTypeName();
+ index = baseType.lastIndexOf(']');
+ if (index > 0)
+ {
+ baseType = baseType.copy(index+1);
+ }
+
+ } else
+ mustBeChecked = sal_False;
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ key.closeKey();
+ } else
+ {
+ break;
+ }
+ }
+
+ return baseType;
+}
+
+void JavaType::dumpConstantValue(FileStream& o, sal_uInt16 index)
+{
+ RTConstValue constValue = m_reader.getFieldConstValue(index);
+
+ switch (constValue.m_type)
+ {
+ case RT_TYPE_BOOL:
+ o << "(boolean)" << constValue.m_value.aBool;
+ break;
+ case RT_TYPE_BYTE:
+ o << "(byte)" << (sal_Int16) constValue.m_value.aByte;
+ break;
+ case RT_TYPE_INT16:
+ o << "(short)" << constValue.m_value.aShort << "L";
+ break;
+ case RT_TYPE_UINT16:
+ o << "(short)" << constValue.m_value.aUShort << "L";
+ break;
+ case RT_TYPE_INT32:
+ o << "(int)" << constValue.m_value.aLong << "L";
+ break;
+ case RT_TYPE_UINT32:
+ o << "(int)" << constValue.m_value.aULong << "L";
+ break;
+ case RT_TYPE_FLOAT:
+ o << "(float)" << constValue.m_value.aFloat;
+ break;
+ case RT_TYPE_DOUBLE:
+ o << "(double)" << constValue.m_value.aDouble;
+ break;
+ case RT_TYPE_STRING:
+ {
+ ::rtl::OUString aUStr(constValue.m_value.aString);
+ ::rtl::OString aStr = ::rtl::OUStringToOString(aUStr, RTL_TEXTENCODING_ASCII_US);
+ o << "L\"" << aStr.getStr() << "\"";
+ }
+ break;
+ }
+}
+
+sal_Bool JavaType::dumpMemberConstructor(FileStream& o)
+{
+ o << indent() << "public " << m_name << "( ";
+ inc(9 + m_name.getLength());
+
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool withIndent = sal_False;
+ if (superType.getLength() > 0)
+ withIndent = dumpInheritedMembers(o, superType, sal_True);
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_Bool first = withIndent;
+
+ sal_uInt16 i;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+
+ if (withIndent)
+ {
+ if (first)
+ {
+ first = sal_False;
+ o << ",\n";
+ }
+ o << indent();
+ } else
+ withIndent = sal_True;
+
+ dumpType(o, m_reader.getFieldType(i));
+ o << " _" << fieldName;
+
+ if (i+1 < fieldCount)
+ o << ",\n";
+ }
+
+ o << " )\n";
+ dec(9 + m_name.getLength());
+ o << indent() << "{\n";
+ inc();
+
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "super( _Message );\n";
+ o << indent() << "Context" << " = _Context;\n";
+ } else
+ {
+ if (superType.getLength() > 0)
+ {
+ o << indent() << "super( ";
+ inc(7);
+ dumpInheritedMembers(o, superType, sal_True, sal_False);
+ o << " );\n";
+ dec(7);
+ } else
+ {
+ if (m_typeName.equals("com/sun/star/uno/Exception"))
+ o << indent() << "super( _Message );\n";
+ }
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (m_typeName.equals("com/sun/star/uno/Exception") && fieldName.equals("Message"))
+ continue;
+
+ o << indent() << fieldName << " = _" << fieldName << ";\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+
+ return sal_True;
+}
+
+sal_Bool JavaType::dumpInheritedMembers(FileStream& o, const OString& type, sal_Bool first, sal_Bool withType)
+{
+ RegistryKey key = m_typeMgr.getTypeKey(type);
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+ sal_uInt8* pBuffer=NULL;
+ sal_Bool withIndent = sal_False;
+
+ if (key.isValid())
+ {
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_False);
+
+ OString superType(reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ withIndent = dumpInheritedMembers(o, superType, first, withType);
+
+ first = withIndent;
+
+ sal_uInt32 fieldCount = reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ if (withIndent)
+ {
+ if (first)
+ {
+ first = sal_False;
+ o << ",\n";
+ }
+ o << indent();
+ }else
+ withIndent = sal_True;
+
+ if (withType)
+ {
+ dumpType(o, reader.getFieldType(i));
+ o << " ";
+ }
+
+ o << "_" << reader.getFieldName(i);
+
+ if (i+1 < fieldCount)
+ o << ",\n";
+ }
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ key.closeKey();
+ }
+
+ return withIndent;
+}
+
+void JavaType::dumpSeqStaticMember(FileStream& o, const ::rtl::OString& typeName,
+ const ::rtl::OString& name)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+ sal_Int32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ if (seqNum > 0)
+ {
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ o << indent() << "public static final ";
+ dumpType(o, relType);
+ for (sal_Int32 i=0; i < seqNum; i++)
+ {
+ o << "[]";
+ }
+ o << " _static_seq_" << name << " = new ";
+ dumpType(o, relType);
+ for (i=0; i < seqNum; i++)
+ {
+ o << "[0]";
+ }
+ o << ";\n";
+ return;
+ }
+}
+
+
+void JavaType::inc(sal_uInt32 num)
+{
+ m_indentLength += num;
+}
+
+void JavaType::dec(sal_uInt32 num)
+{
+ if (m_indentLength - num < 0)
+ m_indentLength = 0;
+ else
+ m_indentLength -= num;
+}
+
+OString JavaType::indent()
+{
+ OStringBuffer tmp(m_indentLength);
+
+ for (int i=0; i < m_indentLength; i++)
+ {
+ tmp.append(' ');
+ }
+ return tmp.makeStringAndClear();
+}
+
+OString JavaType::indent(sal_uInt32 num)
+{
+ OStringBuffer tmp(m_indentLength + num);
+
+ for (int i=0; i < m_indentLength + num; i++)
+ {
+ tmp.append(' ');
+ }
+ return tmp.makeStringAndClear();
+}
+
+//*************************************************************************
+// InterfaceType
+//*************************************************************************
+InterfaceType::InterfaceType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+InterfaceType::~InterfaceType()
+{
+
+}
+
+sal_Bool InterfaceType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "public interface " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " extends " << scopedName(m_typeName, superType);
+
+ o << "\n{\n";
+ inc();
+
+ UnoInfoList aUnoTypeInfos;
+
+ dumpAttributes(o, &aUnoTypeInfos);
+ dumpMethods(o, &aUnoTypeInfos);
+
+ o << indent() << "// static Member\n" << indent() << "public static "
+ << "com.sun.star.uno.Uik UIK = new com.sun.star.uno.Uik( ";
+
+ RTUik uik;
+ m_reader.getUik(uik);
+ sal_Char buffer[67];
+ sprintf(buffer, "0x%.8x, (short)0x%.4x, (short)0x%.4x, 0x%.8x, 0x%.8x",
+ uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5);
+ o << buffer << " );\n";
+
+ if (!aUnoTypeInfos.empty())
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { \n";
+
+ inc();
+
+ sal_Int32 index = 0;
+ UnoInfoList::const_iterator iter = aUnoTypeInfos.begin();
+ while (iter != aUnoTypeInfos.end())
+ {
+ o << indent();
+
+ dumpUnoInfo(o, *iter, &index);
+ if (++iter != aUnoTypeInfos.end())
+ o << ",";
+
+ o << "\n";
+ }
+
+ dec();
+ o << indent() << " };\n";
+ }
+
+ o << "\n" << indent() << "public static Object UNORUNTIMEDATA = null;\n";
+
+ dec();
+ o << "}\n\n";
+
+ return sal_True;
+}
+
+void InterfaceType::dumpAttributes(FileStream& o, UnoInfoList* pUnoInfos)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ sal_Bool first=sal_True;
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_Int32 flags;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ flags = 0;
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << "// Attributes\n";
+ }
+
+ o << indent() << "public ";
+ dumpType(o, fieldType);
+ o << " get" << fieldName << "() throws com.sun.star.uno.RuntimeException;\n";
+
+ if (access != RT_ACCESS_READONLY)
+ {
+ o << indent() << "public void set" << fieldName << "( ";
+ dumpType(o, fieldType);
+ o << " _" << fieldName.toLowerCase() << " ) throws com.sun.star.uno.RuntimeException;\n";
+ }
+
+ if (access == RT_ACCESS_READONLY)
+ flags = flags | UIT_READONLY;
+ if (isUnsigned(fieldType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(fieldType))
+ flags = flags | UIT_ANY;
+ if (isInterface(fieldType))
+ flags = flags | UIT_INTERFACE;
+
+ pUnoInfos->push_back(UnoInfo(fieldName, "", UNOTYPEINFO_ATTIRBUTE, i, flags));
+ }
+
+ if (!first)
+ o << endl;
+}
+
+void InterfaceType::dumpMethods(FileStream& o, UnoInfoList* pUnoInfos)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ sal_Bool first=sal_True;
+
+ OString methodName, returnType, paramType, paramName;
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+ RTMethodMode methodMode = RT_MODE_INVALID;
+ RTParamMode paramMode = RT_PARAM_INVALID;
+ sal_Int32 flags;
+
+ for (sal_uInt16 i=0; i < methodCount; i++)
+ {
+ flags = 0;
+
+ methodName = m_reader.getMethodName(i);
+ returnType = m_reader.getMethodReturnType(i);
+ paramCount = m_reader.getMethodParamCount(i);
+ excCount = m_reader.getMethodExcCount(i);
+ methodMode = m_reader.getMethodMode(i);
+
+ if ( m_typeName.equals("com/sun/star/uno/XInterface") &&
+ ( methodName.equals("queryInterface") ||
+ methodName.equals("acquire") ||
+ methodName.equals("release") ) )
+ {
+ continue;
+ }
+
+ if (isUnsigned(returnType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(returnType))
+ flags = flags | UIT_ANY;
+ if (isInterface(returnType))
+ flags = flags | UIT_INTERFACE;
+ if (methodMode == RT_MODE_ONEWAY || methodMode == RT_MODE_ONEWAY_CONST)
+ flags = flags | UIT_ONEWAY;
+ if (methodMode == RT_MODE_ONEWAY_CONST || methodMode == RT_MODE_TWOWAY_CONST)
+ flags = flags | UIT_CONST;
+
+ if (sal_True || flags) // while unsorted, add always method type info
+ pUnoInfos->push_back(UnoInfo(methodName, "", UNOTYPEINFO_METHOD, i, flags));
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << "// Methods\n";
+ }
+
+ o << indent() << "public ";
+ dumpType(o, returnType);
+ o << " " << methodName << "( ";
+
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ flags = 0;
+ paramName = m_reader.getMethodParamName(i, j);
+ paramType = m_reader.getMethodParamType(i, j);
+ paramMode = m_reader.getMethodParamMode(i, j);
+
+ switch (paramMode)
+ {
+ case RT_PARAM_IN:
+ flags = flags | UIT_IN;
+ o << "/*IN*/";
+ break;
+ case RT_PARAM_OUT:
+ flags = flags | UIT_OUT;
+ o << "/*OUT*/";
+ break;
+ case RT_PARAM_INOUT:
+ flags = flags | UIT_IN | UIT_OUT;
+ o << "/*INOUT*/";
+ break;
+ }
+ if (isUnsigned(paramType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(paramType))
+ flags = flags | UIT_ANY;
+ if (isInterface(paramType))
+ flags = flags | UIT_INTERFACE;
+ if (flags && flags != 1)
+ pUnoInfos->push_back(UnoInfo(paramName, methodName, UNOTYPEINFO_PARAMETER, j, flags));
+
+ dumpType(o, paramType);
+ if (paramMode != RT_PARAM_IN)
+ o << "[]";
+
+ o << " " << paramName;
+
+ if (j+1 < paramCount) o << ", ";
+ }
+ o << " )";
+
+ o << " throws ";
+ OString excpName;
+ for (j=0; j < excCount; j++)
+ {
+ excpName = m_reader.getMethodExcType(i, j);
+ if (excpName != "com/sun/star/uno/RuntimeException")
+ o << scopedName(m_typeName, excpName) << ", ";
+ }
+ o << "com.sun.star.uno.RuntimeException;\n";
+ }
+
+ if (!first)
+ o << endl;
+}
+
+void InterfaceType::dumpUnoInfo(FileStream& o, const UnoInfo& unoInfo, sal_Int32 * index)
+{
+ switch (unoInfo.m_unoTypeInfo)
+ {
+ case UNOTYPEINFO_ATTIRBUTE:
+ {
+ sal_Bool hasFlags = sal_False;
+ o << "new com.sun.star.lib.uno.typeinfo.AttributeTypeInfo( \"" << unoInfo.m_name << "\", " << (*index) << ", ";
+ if (unoInfo.m_flags & UIT_READONLY)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.READONLY";
+ hasFlags = sal_True;
+ }
+ else // mutable attributes have also a set method (in addition to the get method)
+ (*index) ++;
+
+ ++ (*index);
+
+ if (unoInfo.m_flags & UIT_UNSIGNED)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED";
+ }
+ if (unoInfo.m_flags & UIT_ANY)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY";
+ }
+ if (unoInfo.m_flags & UIT_INTERFACE)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE";
+ }
+ if (!hasFlags)
+ {
+ o << "0";
+ }
+ o << " )";
+ }
+ break;
+ case UNOTYPEINFO_METHOD:
+ {
+ sal_Bool hasFlags = sal_False;
+ o << "new com.sun.star.lib.uno.typeinfo.MethodTypeInfo( \"" << unoInfo.m_name << "\", " << (*index) << ", ";
+ ++ (*index);
+ if (unoInfo.m_flags & UIT_UNSIGNED)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED";
+ }
+ if (unoInfo.m_flags & UIT_ONEWAY)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ONEWAY";
+ }
+ if (unoInfo.m_flags & UIT_CONST)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.CONST";
+ }
+ if (unoInfo.m_flags & UIT_ANY)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY";
+ }
+ if (unoInfo.m_flags & UIT_INTERFACE)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE";
+ }
+ if (!hasFlags)
+ {
+ o << "0";
+ }
+ o << " )";
+ }
+ break;
+ case UNOTYPEINFO_PARAMETER:
+ {
+ sal_Bool hasFlags = sal_False;
+ o << "new com.sun.star.lib.uno.typeinfo.ParameterTypeInfo( \"" << unoInfo.m_name
+ << "\", \"" << unoInfo.m_methodName << "\", " << unoInfo.m_index
+ << ", ";
+ if (unoInfo.m_flags & UIT_OUT)
+ {
+ if (unoInfo.m_flags & UIT_IN)
+ {
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.IN";
+ }
+
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.OUT";
+ }
+ if (unoInfo.m_flags & UIT_ANY)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY";
+ }
+ if (unoInfo.m_flags & UIT_INTERFACE)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE";
+ }
+ if (unoInfo.m_flags & UIT_UNSIGNED)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED";
+ }
+ if (!hasFlags)
+ {
+ o << "0";
+ }
+ o << " )";
+ }
+ break;
+ }
+}
+
+//*************************************************************************
+// ModuleType
+//*************************************************************************
+ModuleType::ModuleType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ModuleType::~ModuleType()
+{
+
+}
+
+sal_Bool ModuleType::dump(JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ OString fileName;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ {
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ fileName = createFileNameFromType(outPath, m_typeName + "/" + fieldName, ".java");
+ FileStream o(fileName);
+
+ if(!o.isValid())
+ {
+ OString message("cannot open ");
+ message += fileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ dumpPackage(o, sal_True);
+ o << indent() << "public interface " << fieldName << "\n{\n";
+ inc();
+ o << indent() << "public static final ";
+ dumpType(o, fieldType);
+ o << " value = ";
+ dumpConstantValue(o, i);
+ o << ";\n\n";
+
+ if (isUnsigned(fieldType))
+ {
+ o << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { new com.sun.star.lib.uno.typeinfo.ConstantTypeInfo( \""
+ << fieldName << "\", com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED ) };\n";
+ }
+
+ dec();
+ o << "}\n";
+ }
+ }
+
+ return sal_True;
+}
+
+sal_Bool ModuleType::hasConstants()
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//*************************************************************************
+// ConstantsType
+//*************************************************************************
+ConstantsType::ConstantsType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ConstantsType::~ConstantsType()
+{
+
+}
+
+sal_Bool ConstantsType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "public interface " << m_name << "\n{\n";
+ inc();
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ StringSet aTypeInfos;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ {
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (isUnsigned(fieldType))
+ aTypeInfos.insert(fieldName);
+
+ o << indent() << "public static final ";
+ dumpType(o, fieldType);
+ o << " " << fieldName << " = ";
+ dumpConstantValue(o, i);
+ o << ";\n";
+ }
+ }
+
+ if (!aTypeInfos.empty())
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { ";
+ inc(63);
+
+ StringSet::const_iterator iter = aTypeInfos.begin();
+ while (iter != aTypeInfos.end())
+ {
+ if (iter != aTypeInfos.begin())
+ o << indent();
+
+ o << "new com.sun.star.lib.uno.typeinfo.ConstantTypeInfo( \"" << *iter << "\", com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED )";
+
+ if (++iter != aTypeInfos.end())
+ o << ",\n";
+ }
+
+ dec(63);
+ o << " };\n";
+ }
+
+ dec();
+ o << "}\n";
+
+ return sal_True;
+}
+
+
+//*************************************************************************
+// StructureType
+//*************************************************************************
+StructureType::StructureType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+StructureType::~StructureType()
+{
+
+}
+
+sal_Bool StructureType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "public class " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " extends " << scopedName(m_typeName, superType);
+
+ o << "\n{\n";
+ inc();
+ o << indent() << "//instance variables\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+// StringSet aTypeInfos;
+ UnoInfoList aUnoTypeInfos;
+ sal_Int32 flags = 0;
+
+ sal_uInt16 i;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ flags = 0;
+ if (isUnsigned(fieldType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(fieldType))
+ flags = flags | UIT_ANY;
+ if (isInterface(fieldType))
+ flags = flags | UIT_INTERFACE;
+ if (flags)
+ aUnoTypeInfos.push_back(UnoInfo(fieldName, "", UNOTYPEINFO_MEMBER, i, flags));
+
+ dumpSeqStaticMember(o, fieldType, fieldName);
+ o << indent() << "public ";
+ dumpType(o, fieldType);
+ o << " " << fieldName << ";\n";
+ }
+
+ o << endl << indent() << "//constructors\n";
+ o << indent() << "public " << m_name << "()\n" << indent() << "{\n";
+ inc();
+ OString relType;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ dumpTypeInit(o, fieldName, fieldType);
+ }
+ dec();
+ o << indent() << "}\n\n";
+
+ dumpMemberConstructor(o);
+
+ if (!aUnoTypeInfos.empty())
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { ";
+ inc(63);
+
+ UnoInfoList::const_iterator iter = aUnoTypeInfos.begin();
+ while (iter != aUnoTypeInfos.end())
+ {
+ if (iter != aUnoTypeInfos.begin())
+ o << indent();
+
+ o << "new com.sun.star.lib.uno.typeinfo.MemberTypeInfo( \"" << (*iter).m_name << "\", ";
+
+ if ((*iter).m_flags & UIT_UNSIGNED)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED )";
+ }
+ else if ((*iter).m_flags & UIT_ANY)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY )";
+ }
+ else if ((*iter).m_flags & UIT_INTERFACE)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE )";
+ }
+
+ if (++iter != aUnoTypeInfos.end())
+ o << ",\n";
+ }
+
+ dec(63);
+ o << " };\n";
+ }
+
+ o << "\n" << indent() << "public static Object UNORUNTIMEDATA = null;\n";
+
+ dec();
+ o << "}\n";
+
+ return sal_True;
+}
+
+
+//*************************************************************************
+// ExceptionType
+//*************************************************************************
+ExceptionType::ExceptionType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ExceptionType::~ExceptionType()
+{
+
+}
+
+sal_Bool ExceptionType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "public class " << m_name;
+
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << " extends java.lang.RuntimeException\n";
+ } else
+ {
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " extends " << scopedName(m_typeName, superType);
+ else
+ o << " extends java.lang.Exception\n";
+ }
+
+ o << "\n{\n";
+ inc();
+ o << indent() << "//instance variables\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+// StringSet aTypeInfos;
+ UnoInfoList aUnoTypeInfos;
+ sal_Int32 flags = 0;
+
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "public java.lang.Object Context;\n";
+ }
+
+ sal_uInt16 i;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ flags = 0;
+
+ if (isUnsigned(fieldType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(fieldType))
+ flags = flags | UIT_ANY;
+ if (isInterface(fieldType))
+ flags = flags | UIT_INTERFACE;
+ if (flags)
+ aUnoTypeInfos.push_back(UnoInfo(fieldName, "", UNOTYPEINFO_MEMBER, i, flags));
+
+ if (m_typeName.equals("com/sun/star/uno/Exception") && fieldName.equals("Message"))
+ continue;
+
+ dumpSeqStaticMember(o, fieldType, fieldName);
+ o << indent() << "public ";
+ dumpType(o, fieldType);
+ o << " " << fieldName << ";\n";
+ }
+
+ o << endl << indent() << "//constructors\n";
+ o << indent() << "public " << m_name << "()\n" << indent() << "{\n";
+ inc();
+/*
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "Context = null;\n";
+ }
+*/
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (m_typeName.equals("com/sun/star/uno/Exception") && fieldName.equals("Message"))
+ continue;
+
+ dumpTypeInit(o, fieldName, fieldType);
+ }
+ dec();
+
+ o << indent() << "}\n\n";
+
+ dumpSimpleMemberConstructor(o);
+ dumpMemberConstructor(o);
+
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { "
+ << "new com.sun.star.lib.uno.typeinfo.MemberTypeInfo( \"Context\", com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE ) };\n";
+ } else
+ if (!aUnoTypeInfos.empty())
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { ";
+ inc(63);
+
+ UnoInfoList::const_iterator iter = aUnoTypeInfos.begin();
+ while (iter != aUnoTypeInfos.end())
+ {
+ if (iter != aUnoTypeInfos.begin())
+ o << indent();
+
+ o << "new com.sun.star.lib.uno.typeinfo.MemberTypeInfo( \"" << (*iter).m_name << "\", ";
+
+ if ((*iter).m_flags & UIT_UNSIGNED)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED )";
+ }
+ else if ((*iter).m_flags & UIT_ANY)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY )";
+ }
+ else if ((*iter).m_flags & UIT_INTERFACE)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE )";
+ }
+
+ if (++iter != aUnoTypeInfos.end())
+ o << ",\n";
+ }
+
+ dec(63);
+ o << " };\n";
+ }
+
+ o << "\n" << indent() << "public static Object UNORUNTIMEDATA = null;\n";
+
+ dec();
+ o << "}\n";
+
+ return sal_True;
+}
+
+sal_Bool ExceptionType::dumpSimpleMemberConstructor(FileStream& o)
+{
+ o << indent() << "public " << m_name << "( String _Message )\n";
+
+ OString superType(m_reader.getSuperTypeName());
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+
+ o << indent() << "{\n";
+ inc();
+
+ o << indent() << "super( _Message );\n";
+/*
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "super( _Message );\n";
+ o << indent() << "Context" << " = null;\n";
+ } else
+ {
+ o << indent() << "super( _Message );\n";
+ }
+*/
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (m_typeName.equals("com/sun/star/uno/Exception") && fieldName.equals("Message"))
+ continue;
+
+ dumpTypeInit(o, fieldName, fieldType);
+ }
+
+ dec();
+ o << indent() << "}\n\n";
+
+ return sal_True;
+}
+
+//*************************************************************************
+// EnumType
+//*************************************************************************
+EnumType::EnumType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+EnumType::~EnumType()
+{
+
+}
+
+sal_Bool EnumType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "final public class " << m_name << " extends com.sun.star.uno.Enum\n{\n";
+ inc();
+
+ o << indent() << "private " << m_name << "(int value)\n" << indent() << "{\n";
+ inc();
+ o << indent() << "super(value);\n";
+ dec();
+ o << indent() << "}\n\n";
+
+ o << indent() << "public static " << m_name << " getDefault()\n" << indent() << "{\n";
+ inc();
+ o << indent() << "return " << m_reader.getFieldName(0) << ";\n";
+ dec();
+ o << indent() << "}\n\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ RTConstValue constValue;
+ OString fieldName;
+ sal_uInt32 value=0;
+
+ sal_uInt16 i;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ constValue = m_reader.getFieldConstValue(i);
+
+ if (constValue.m_type == RT_TYPE_INT32)
+ value = constValue.m_value.aLong;
+ else
+ value++;
+
+ o << indent() << "public static final " << m_name << " " << fieldName << " = "
+ << "new " << m_name << "(" << value << ");\n";
+ o << indent() << "public static final int " << fieldName << "_value = " << value << ";\n";
+ }
+
+ o << "\n" << indent() << "public static " << m_name << " fromInt(int value)\n" << indent() << "{\n";
+ inc();
+ o << indent() << "switch( value )\n" << indent() << "{\n";
+ inc();
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ constValue = m_reader.getFieldConstValue(i);
+
+ if (constValue.m_type == RT_TYPE_INT32)
+ value = constValue.m_value.aLong;
+ else
+ value++;
+
+ o << indent() << "case " << value << ":\n";
+ inc();
+ o << indent() << "return " << fieldName << ";\n";
+ dec();
+ }
+ o << indent() << "default:\n";
+ inc();
+ o << indent() << "return null;\n";
+ dec();
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n";
+
+ o << "\n" << indent() << "public static Object UNORUNTIMEDATA = null;\n";
+
+ dec();
+ o << "}\n";
+
+ return sal_True;
+}
+
+//*************************************************************************
+// TypeDefType
+//*************************************************************************
+TypeDefType::TypeDefType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+TypeDefType::~TypeDefType()
+{
+
+}
+
+sal_Bool TypeDefType::dump(JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ OString relBaseType(checkRealBaseType(m_typeName));
+
+ return produceType(relBaseType, m_typeMgr, m_dependencies, pOptions);
+}
+
+
+//*************************************************************************
+// produceType
+//*************************************************************************
+sal_Bool produceType(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ if (typeDependencies.isGenerated(typeName))
+ return sal_True;
+
+ RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+
+ if (!typeKey.isValid())
+ return sal_False;
+
+ if( !checkTypeDependencies(typeMgr, typeDependencies, typeName))
+ return sal_False;
+
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (typeKey.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ if (typeName.equals("/"))
+ return sal_True;
+ else
+ return sal_False;
+ }
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+
+ if (typeKey.getValue(OUString(), pBuffer))
+ {
+ rtl_freeMemory(pBuffer);
+ return sal_False;
+ }
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_True);
+
+ rtl_freeMemory(pBuffer);
+
+ RTTypeClass typeClass = reader.getTypeClass();
+ sal_Bool ret = sal_False;
+ switch (typeClass)
+ {
+ case RT_TYPE_INTERFACE:
+ {
+ InterfaceType iType(reader, typeName, typeMgr, typeDependencies);
+ ret = iType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = iType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_MODULE:
+ {
+ ModuleType mType(reader, typeName, typeMgr, typeDependencies);
+ if (mType.hasConstants())
+ {
+ ret = mType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ } else
+ ret = sal_True;
+ }
+ break;
+ case RT_TYPE_STRUCT:
+ {
+ StructureType sType(reader, typeName, typeMgr, typeDependencies);
+ ret = sType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = sType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_ENUM:
+ {
+ EnumType enType(reader, typeName, typeMgr, typeDependencies);
+ ret = enType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = enType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_EXCEPTION:
+ {
+ ExceptionType eType(reader, typeName, typeMgr, typeDependencies);
+ ret = eType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = eType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_CONSTANTS:
+ {
+ ConstantsType cType(reader, typeName, typeMgr, typeDependencies);
+ ret = cType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ return ret;
+ }
+ break;
+ case RT_TYPE_TYPEDEF:
+ {
+ TypeDefType tdType(reader, typeName, typeMgr, typeDependencies);
+ ret = tdType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = tdType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_SERVICE:
+ case RT_TYPE_OBJECT:
+ ret = sal_True;
+ break;
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// scopedName
+//*************************************************************************
+OString scopedName(const OString& scope, const OString& type,
+ sal_Bool bNoNameSpace)
+{
+ if (type.indexOf('/') < 0)
+ return type;
+
+ if (bNoNameSpace)
+ return type.getToken(type.getTokenCount('/') - 1, '/');
+
+ // scoped name only if the namespace is not equal
+ if (scope.lastIndexOf('/') > 0)
+ {
+ OString tmpScp(scope.copy(0, scope.lastIndexOf('/')));
+ OString tmpScp2(type.copy(0, type.lastIndexOf('/')));
+
+ if (tmpScp == tmpScp2)
+ return type.getToken(type.getTokenCount('/') - 1, '/');
+ }
+
+ return type.replace('/', '.');
+}
+
+
+
diff --git a/codemaker/source/javamaker/javatype.hxx b/codemaker/source/javamaker/javatype.hxx
new file mode 100644
index 000000000000..d281176befbf
--- /dev/null
+++ b/codemaker/source/javamaker/javatype.hxx
@@ -0,0 +1,342 @@
+/*************************************************************************
+ *
+ * $RCSfile: javatype.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:28 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUMAKER_CPPUTYPE_HXX_
+#define _CPPUMAKER_CPPUTYPE_HXX_
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+enum BASETYPE
+{
+ BT_INVALID,
+ BT_VOID,
+ BT_ANY,
+ BT_TYPE,
+ BT_BOOLEAN,
+ BT_CHAR,
+ BT_STRING,
+ BT_FLOAT,
+ BT_DOUBLE,
+ BT_OCTET,
+ BT_BYTE,
+ BT_SHORT,
+ BT_LONG,
+ BT_HYPER,
+ BT_UNSIGNED_SHORT,
+ BT_UNSIGNED_LONG,
+ BT_UNSIGNED_HYPER
+};
+
+
+enum JavaTypeDecl
+{
+ CPPUTYPEDECL_ALLTYPES,
+ CPPUTYPEDECL_NOINTERFACES,
+ CPPUTYPEDECL_ONLYINTERFACES
+};
+
+static const sal_Int32 UIT_IN = 0x00000001;
+static const sal_Int32 UIT_OUT = 0x00000002;
+static const sal_Int32 UIT_UNSIGNED = 0x00000004;
+static const sal_Int32 UIT_READONLY = 0x00000008;
+static const sal_Int32 UIT_ONEWAY = 0x00000010;
+static const sal_Int32 UIT_CONST = 0x00000020;
+static const sal_Int32 UIT_ANY = 0x00000040;
+static const sal_Int32 UIT_INTERFACE = 0x00000080;
+
+enum UnoTypeInfo
+{
+ UNOTYPEINFO_INVALID,
+ UNOTYPEINFO_METHOD,
+ UNOTYPEINFO_PARAMETER,
+ UNOTYPEINFO_ATTIRBUTE,
+ UNOTYPEINFO_MEMBER
+};
+
+struct UnoInfo
+{
+ UnoInfo()
+ : m_unoTypeInfo(UNOTYPEINFO_INVALID)
+ , m_index(-1)
+ , m_flags(0)
+ {}
+
+ UnoInfo(const ::rtl::OString& name, const ::rtl::OString& methodName,
+ UnoTypeInfo unoTypeInfo, sal_Int32 index, sal_Int32 flags)
+ : m_name(name)
+ , m_methodName(methodName)
+ , m_unoTypeInfo(unoTypeInfo)
+ , m_index(index)
+ , m_flags(flags)
+ {}
+
+ ::rtl::OString m_name;
+ ::rtl::OString m_methodName;
+ UnoTypeInfo m_unoTypeInfo;
+ sal_Int32 m_index;
+ sal_Int32 m_flags;
+};
+
+inline int operator == (const UnoInfo& u1, const UnoInfo& u2)
+{
+ return ((u1.m_name == u2.m_name) && (u1.m_methodName == u2.m_methodName));
+}
+
+inline int operator < (const UnoInfo& u1, const UnoInfo& u2)
+{
+ if (u1.m_name == u2.m_name)
+ return (u1.m_methodName < u2.m_methodName);
+ else
+ return (u1.m_name < u2.m_name);
+}
+
+/*
+struct LessUnoInfo
+{
+ bool operator()(const UnoInfo& unoInfo1, const UnoInfo& unoInfo2) const
+ {
+ return (unoInfo1.m_name < unoInfo2.m_name);
+ }
+};
+
+typedef NAMESPACE_STD(set) <UnoInfo, LessUnoInfo> UnoInfoSet;
+*/
+typedef NAMESPACE_STD(list) <UnoInfo> UnoInfoList;
+
+class JavaOptions;
+class FileStream;
+
+class JavaType
+{
+public:
+ JavaType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~JavaType();
+
+ virtual sal_Bool dump(JavaOptions* pOptions) throw( CannotDumpException );
+ virtual sal_Bool dumpDependedTypes(JavaOptions* pOptions) throw( CannotDumpException );
+ virtual sal_Bool dumpFile(FileStream& o) throw( CannotDumpException ) { return sal_True; }
+
+ void dumpPackage(FileStream& o, sal_Bool bFullScope = sal_False);
+
+ virtual void dumpDepImports(FileStream& o, const ::rtl::OString& typeName);
+
+ virtual void dumpType(FileStream& o, const ::rtl::OString& type) throw( CannotDumpException );
+ ::rtl::OString getBaseType(const ::rtl::OString& type);
+ void dumpTypeInit(FileStream& o, const ::rtl::OString& name, const ::rtl::OString& type);
+ BASETYPE isBaseType(const ::rtl::OString& type);
+ sal_Bool isUnsigned(const ::rtl::OString& type);
+ sal_Bool isAny(const ::rtl::OString& type);
+ sal_Bool isInterface(const ::rtl::OString& type);
+
+ void dumpConstantValue(FileStream& o, sal_uInt16 index);
+
+ sal_uInt32 getMemberCount();
+
+ // only used for structs and exceptions
+ sal_Bool dumpMemberConstructor(FileStream& o);
+ sal_Bool dumpInheritedMembers( FileStream& o, const ::rtl::OString& type,
+ sal_Bool first, sal_Bool withType= sal_True );
+ void dumpSeqStaticMember(FileStream& o, const ::rtl::OString& type,
+ const ::rtl::OString& name);
+
+ void inc(sal_uInt32 num=4);
+ void dec(sal_uInt32 num=4);
+ ::rtl::OString indent();
+ ::rtl::OString indent(sal_uInt32 num);
+protected:
+ ::rtl::OString checkSpecialJavaType(const ::rtl::OString& type);
+ ::rtl::OString checkRealBaseType(const ::rtl::OString& type);
+
+protected:
+ sal_uInt32 m_indentLength;
+ ::rtl::OString m_typeName;
+ ::rtl::OString m_name;
+ TypeReader m_reader;
+ TypeManager& m_typeMgr;
+ TypeDependency m_dependencies;
+};
+
+class InterfaceType : public JavaType
+{
+public:
+ InterfaceType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~InterfaceType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+
+ void dumpAttributes(FileStream& o, UnoInfoList* pUnoInfos);
+ void dumpMethods(FileStream& o, UnoInfoList* pUnoInfos);
+
+ void dumpUnoInfo(FileStream& o, const UnoInfo& unoInfo, sal_Int32 * index);
+};
+
+class ModuleType : public JavaType
+{
+public:
+ ModuleType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ModuleType();
+
+ sal_Bool dump(JavaOptions* pOptions) throw( CannotDumpException );
+ sal_Bool hasConstants();
+};
+
+class ConstantsType : public JavaType
+{
+public:
+ ConstantsType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ConstantsType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+};
+
+class StructureType : public JavaType
+{
+public:
+ StructureType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~StructureType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+};
+
+class ExceptionType : public JavaType
+{
+public:
+ ExceptionType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ExceptionType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpSimpleMemberConstructor(FileStream& o);
+};
+
+class EnumType : public JavaType
+{
+public:
+ EnumType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~EnumType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+};
+
+class TypeDefType : public JavaType
+{
+public:
+ TypeDefType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~TypeDefType();
+
+ sal_Bool dump(JavaOptions* pOptions) throw( CannotDumpException );
+};
+
+
+sal_Bool produceType(const ::rtl::OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ JavaOptions* pOptions)
+ throw( CannotDumpException );
+
+/**
+ * This function returns a Java scoped name, represents the package
+ * scoping of this type, e.g. com.sun.star.uno.XInterface. If the scope of
+ * the type is equal scope, the relativ name will be used.
+ */
+::rtl::OString scopedName(const ::rtl::OString& scope, const ::rtl::OString& type,
+ sal_Bool bNoNameSpace=sal_False);
+
+
+#endif // _CPPUMAKER_CPPUTYPE_HXX_
+
diff --git a/codemaker/source/javamaker/makefile.mk b/codemaker/source/javamaker/makefile.mk
new file mode 100644
index 000000000000..113f19ddf3c4
--- /dev/null
+++ b/codemaker/source/javamaker/makefile.mk
@@ -0,0 +1,104 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:28 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=codemaker
+TARGET=javamaker
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= javamaker.cxx \
+ javaoptions.cxx \
+ javatype.cxx
+
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/javamaker.obj \
+ $(OBJ)$/javaoptions.obj \
+ $(OBJ)$/javatype.obj
+
+APP1STDLIBS=\
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(REGLIB) \
+ $(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+= \
+ $(LIBCIMT) $(LIBCMT)
+.ENDIF
+
+APP1LIBS= \
+ $(LB)$/codemaker.lib
+
+.INCLUDE : target.mk
diff --git a/cppu/inc/com/sun/star/uno/Any.h b/cppu/inc/com/sun/star/uno/Any.h
new file mode 100644
index 000000000000..788031178b4b
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Any.h
@@ -0,0 +1,376 @@
+/*************************************************************************
+ *
+ * $RCSfile: Any.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_ANY_H_
+#define _COM_SUN_STAR_UNO_ANY_H_
+
+#ifndef _CPPU_MACROS_HXX_
+#include <cppu/macros.hxx>
+#endif
+
+#ifndef _UNO_ANY2_H_
+#include <uno/any2.h>
+#endif
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_TYPE_H_
+#include <com/sun/star/uno/Type.h>
+#endif
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+class BinaryCompatible_Impl;
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+/** C++ class representing an IDL any.
+ This class is used to transport any type defined in IDL.
+ The class inherits from the binary C representation
+ of <b>uno_Any</b>.<br>
+ You can insert a value by either using the <<= operators
+ or the template function makeAny(). No any can hold an any.<br>
+ You can extract values from an any by using the >>= operators
+ which return true if the any contains an assignable value
+ (no data loss), e.g. the any contains a short and you >>= it
+ into a long variable.
+ <br>
+*/
+class Any : public uno_Any
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) throw()
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) throw()
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) throw()
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) throw()
+ {}
+
+ /** Default constructor:
+ Any holds no value; its type is void.
+ <br>
+ */
+ inline Any();
+
+ /** Copy constructor:
+ Sets value of the given any.
+ <br>
+ @param rAny another any
+ */
+ inline Any( const Any & rAny );
+
+ /** Constructor:
+ Sets a copy of the given data.
+ <br>
+ @param pData value
+ @param rType type of value
+ */
+ inline Any( const void * pData, const Type & rType );
+
+ /** Constructor:
+ Sets a copy of the given data.
+ <br>
+ @param pData value
+ @param pTypeDescr type of value
+ */
+ inline Any( const void * pData, typelib_TypeDescription * pTypeDescr );
+
+ /** Constructor:
+ Sets a copy of the given data.
+ <br>
+ @param pData value
+ @param pType type of value
+ */
+ inline Any( const void * pData, typelib_TypeDescriptionReference * pType );
+
+ /** Destructor:
+ Destructs any content and frees memory.
+ <br>
+ */
+ inline ~Any();
+
+ /** Assignment operator:
+ Sets the value of the given any.
+ <br>
+ @param rAny another any (right side)
+ @return this any
+ */
+ inline Any & SAL_CALL operator = ( const Any & rAny );
+
+ /** Gets the type of the set value.
+ <br>
+ @return a Type object of the set value
+ */
+ inline const Type & SAL_CALL getValueType() const
+ { return * reinterpret_cast< const Type * >( &pType ); }
+ /** Gets the type of the set value.
+ <br>
+ @return the <b>un</b>acquired type description reference of the set value
+ */
+ inline typelib_TypeDescriptionReference * SAL_CALL getValueTypeRef() const
+ { return pType; }
+
+ /** Gets the type description of the set value.<br>
+ Provides <b>ownership</b> of the type description!
+ Call an explicit typelib_typedescription_release() to release.
+ <br>
+ @param a pointer to type description pointer
+ */
+ inline void SAL_CALL getValueTypeDescription( typelib_TypeDescription ** ppTypeDescr ) const
+ { ::typelib_typedescriptionreference_getDescription( ppTypeDescr, getValueTypeRef() ); }
+
+ /** Gets the type class of the set value.
+ <br>
+ @return the type class of the set value
+ */
+ inline TypeClass SAL_CALL getValueTypeClass() const
+ { return (TypeClass)pType->eTypeClass; }
+
+ /** Gets the type name of the set value.
+ <br>
+ @return the type name of the set value
+ */
+ inline ::rtl::OUString SAL_CALL getValueTypeName() const
+ { return ::rtl::OUString( pType->pTypeName ); }
+
+ /** Tests if any contains a value.
+ <br>
+ @return true if any has a value, false otherwise
+ */
+ inline sal_Bool SAL_CALL hasValue() const
+ { return (TypeClass_VOID != getValueTypeClass()); }
+
+ /** Gets a pointer to the set value.
+ <br>
+ @return a pointer to the set value
+ */
+ inline const void * SAL_CALL getValue() const
+ { return pData; }
+
+ /** Sets a value. If the any already contains a value, that value will be destructed
+ and its memory freed.
+ <br>
+ @param pData pointer to value
+ @param rType type of value
+ */
+ inline void SAL_CALL setValue( const void * pData, const Type & rType );
+ /** Sets a value. If the any already contains a value, that value will be destructed
+ and its memory freed.
+ <br>
+ @param pData pointer to value
+ @param pType type of value
+ */
+ inline void SAL_CALL setValue( const void * pData, typelib_TypeDescriptionReference * pType );
+ /** Sets a value. If the any already contains a value, that value will be destructed
+ and its memory freed.
+ <br>
+ @param pData pointer to value
+ @param pTypeDescr type description of value
+ */
+ inline void SAL_CALL setValue( const void * pData, typelib_TypeDescription * pTypeDescr );
+
+ /** Clears this any. If the any already contains a value, that value will be destructed
+ and its memory freed. After this has been called, the any does not contain a value.
+ <br>
+ */
+ inline void SAL_CALL clear();
+
+ /** Equality operator: compares two anys.<br>
+ The values need not be of equal type, e.g. a short integer is compared to
+ a long integer.
+ <br>
+ @param rAny another any (right side)
+ @return true if both any contains equal values
+ */
+ inline sal_Bool SAL_CALL operator == ( const Any & rAny ) const;
+ /** Unequality operator: compares two anys.<br>
+ The values need not be of equal type, e.g. a short integer is compared to
+ a long integer.
+ <br>
+ @param rAny another any (right side)
+ @return true if both any contains unequal values
+ */
+ inline sal_Bool SAL_CALL operator != ( const Any & rAny ) const
+ { return (! operator == ( rAny )); }
+
+ // test the binary compatibility
+ friend class BinaryCompatible_Impl;
+};
+
+/** Template function to generically construct an any from a C++ value.
+ <br>
+ @param value a value
+ @return an any
+ */
+template< class C >
+inline Any SAL_CALL makeAny( const C & value );
+
+class BaseReference;
+class Type;
+
+/** Template binary <<= operator to set the value of an any.
+ <br>
+ @param rAny destination any (left side)
+ @param value source value (right side)
+ */
+template< class C >
+inline void SAL_CALL operator <<= ( ::com::sun::star::uno::Any & rAny, const C & value );
+/** Template binary >>= operator to assign a value from an any.<br>
+ If the any does not contain a value that can be assigned <b>without</b>
+ data loss, this operation will fail returning false.
+ <br>
+ @param rAny source any (left side)
+ @param value destination value (right side)
+ @return true if assignment was possible without data loss
+ */
+template< class C >
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, C & value );
+
+/** Template equality operator: compares set value of left side any to right side value.<br>
+ The values need not be of equal type, e.g. a short integer is compared to
+ a long integer.<br>
+ This operator can be implemented as template member function, if
+ all supported compilers can cope with template member functions.
+ <br>
+ @param rAny another any (left side)
+ @param value a value (right side)
+ @return true if values are equal, false otherwise
+*/
+template< class C >
+inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const C & value );
+/** Template unequality operator: compares set value of left side any to right side value.<br>
+ The values need not be of equal type, e.g. a short integer is compared to
+ a long integer.<br>
+ This operator can be implemented as template member function, if
+ all supported compilers can cope with template member functions.
+ <br>
+ @param rAny another any (left side)
+ @param value a value (right side)
+ @return true if values are unequal, false otherwise
+*/
+template< class C >
+inline sal_Bool SAL_CALL operator != ( const ::com::sun::star::uno::Any & rAny, const C & value )
+{
+ return (! operator == ( rAny, value ));
+}
+
+// additional specialized >>= and == operators
+// bool
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value );
+inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const sal_Bool & value );
+// byte
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value );
+// short
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int16 & value );
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt16 & value );
+// long
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int32 & value );
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt32 & value );
+// hyper
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int64 & value );
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt64 & value );
+// float
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, float & value );
+// double
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, double & value );
+// string
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, ::rtl::OUString & value );
+inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const ::rtl::OUString & value );
+// type
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, ::com::sun::star::uno::Type & value );
+inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const ::com::sun::star::uno::Type & value );
+// any
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, ::com::sun::star::uno::Any & value );
+// interface
+inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const ::com::sun::star::uno::BaseReference & value );
+
+}
+}
+}
+}
+
+/** Gets the meta type of IDL type <b>any</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>any</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Any * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_ANY ) );
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Any.hxx b/cppu/inc/com/sun/star/uno/Any.hxx
new file mode 100644
index 000000000000..f73cfdf28b08
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Any.hxx
@@ -0,0 +1,487 @@
+/*************************************************************************
+ *
+ * $RCSfile: Any.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#define _COM_SUN_STAR_UNO_ANY_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_ANY_H_
+#include <com/sun/star/uno/Any.h>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _UNO_ANY2_H_
+#include <uno/any2.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
+#include <com/sun/star/uno/Type.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
+#include <com/sun/star/uno/XInterface.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_
+#include <com/sun/star/uno/genfunc.hxx>
+#endif
+
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+inline Any::Any()
+{
+ ::uno_any_construct( this, 0, 0, cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const Any & rAny )
+{
+ ::uno_type_any_construct( this, rAny.pData, rAny.getValueTypeRef(), cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const void * pData, const Type & rType )
+{
+ ::uno_type_any_construct( this, const_cast< void * >( pData ), rType.getTypeLibType(), cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const void * pData, typelib_TypeDescription * pTypeDescr )
+{
+ ::uno_any_construct( this, const_cast< void * >( pData ), pTypeDescr, cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const void * pData, typelib_TypeDescriptionReference * pType )
+{
+ ::uno_type_any_construct( this, const_cast< void * >( pData ), pType, cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::~Any()
+{
+ ::uno_any_destruct( this, cpp_release );
+}
+//__________________________________________________________________________________________________
+inline Any & Any::operator = ( const Any & rAny )
+{
+ if (this != &rAny)
+ setValue( rAny.getValue(), rAny.getValueTypeRef() );
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline void Any::setValue( const void * pData, const Type & rType )
+{
+ ::uno_any_destruct( this, cpp_release );
+ ::uno_type_any_construct( this, const_cast< void * >( pData ), rType.getTypeLibType(), cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline void Any::setValue( const void * pData, typelib_TypeDescriptionReference * pType )
+{
+ ::uno_any_destruct( this, cpp_release );
+ ::uno_type_any_construct( this, const_cast< void * >( pData ), pType, cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline void Any::setValue( const void * pData, typelib_TypeDescription * pTypeDescr )
+{
+ ::uno_any_destruct( this, cpp_release );
+ ::uno_any_construct( this, const_cast< void * >( pData ), pTypeDescr, cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline void Any::clear()
+{
+ ::uno_any_destruct( this, cpp_release );
+ ::uno_any_construct( this, 0, 0, cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline sal_Bool Any::operator == ( const Any & rAny ) const
+{
+ const Type & rType = ::getCppuType( this );
+ return ::uno_type_equalData(
+ const_cast< void * >( getValue() ), getValueTypeRef(),
+ const_cast< void * >( rAny.getValue() ), rAny.getValueTypeRef(),
+ cpp_queryInterface, cpp_release );
+}
+
+//__________________________________________________________________________________________________
+template< class C >
+inline Any SAL_CALL makeAny( const C & value )
+{
+ return Any( &value, ::getCppuType( &value ) );
+}
+
+//__________________________________________________________________________________________________
+template< class C >
+inline void SAL_CALL operator <<= ( ::com::sun::star::uno::Any & rAny, const C & value )
+{
+ rAny.setValue( &value, ::getCppuType( &value ) );
+}
+
+//__________________________________________________________________________________________________
+template< class C >
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, C & value )
+{
+ const ::com::sun::star::uno::Type & rType = ::getCppuType( &value );
+ return ::uno_type_assignData(
+ &value, rType.getTypeLibType(),
+ const_cast< void * >( rAny.getValue() ), rAny.getValueTypeRef(),
+ ::com::sun::star::uno::cpp_queryInterface,
+ ::com::sun::star::uno::cpp_acquire,
+ ::com::sun::star::uno::cpp_release );
+}
+
+// bool
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value )
+{
+ if (::com::sun::star::uno::TypeClass_BOOLEAN == rAny.getValueTypeClass())
+ {
+ value = (* reinterpret_cast< const sal_Bool * >( rAny.getValue() ) != sal_False);
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const sal_Bool & value )
+{
+ return (::com::sun::star::uno::TypeClass_BOOLEAN == rAny.getValueTypeClass() &&
+ (value != sal_False) == (* reinterpret_cast< const sal_Bool * >( rAny.getValue() ) != sal_False));
+}
+// byte
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value )
+{
+ if (::com::sun::star::uno::TypeClass_BYTE == rAny.getValueTypeClass())
+ {
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+// short
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int16 & value )
+{
+ switch (rAny.getValueTypeClass())
+ {
+ case ::com::sun::star::uno::TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_SHORT:
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt16 & value )
+{
+ switch (rAny.getValueTypeClass())
+ {
+ case ::com::sun::star::uno::TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_SHORT:
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+// long
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int32 & value )
+{
+ switch (rAny.getValueTypeClass())
+ {
+ case ::com::sun::star::uno::TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_LONG:
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt32 & value )
+{
+ switch (rAny.getValueTypeClass())
+ {
+ case ::com::sun::star::uno::TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_LONG:
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+// hyper
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int64 & value )
+{
+ switch (rAny.getValueTypeClass())
+ {
+ case ::com::sun::star::uno::TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_HYPER:
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER:
+ value = * reinterpret_cast< const sal_Int64 * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt64 & value )
+{
+ switch (rAny.getValueTypeClass())
+ {
+ case ::com::sun::star::uno::TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_HYPER:
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER:
+ value = * reinterpret_cast< const sal_uInt64 * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+// float
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, float & value )
+{
+ switch (rAny.getValueTypeClass())
+ {
+ case ::com::sun::star::uno::TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_FLOAT:
+ value = * reinterpret_cast< const float * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+// double
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, double & value )
+{
+ switch (rAny.getValueTypeClass())
+ {
+ case ::com::sun::star::uno::TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_FLOAT:
+ value = * reinterpret_cast< const float * >( rAny.getValue() );
+ return sal_True;
+ case ::com::sun::star::uno::TypeClass_DOUBLE:
+ value = * reinterpret_cast< const double * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+// string
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= (
+ const ::com::sun::star::uno::Any & rAny, ::rtl::OUString & value )
+{
+ if (::com::sun::star::uno::TypeClass_STRING == rAny.getValueTypeClass())
+ {
+ value = * reinterpret_cast< const ::rtl::OUString * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == (
+ const ::com::sun::star::uno::Any & rAny, const ::rtl::OUString & value )
+{
+ return (::com::sun::star::uno::TypeClass_STRING == rAny.getValueTypeClass() &&
+ value == * reinterpret_cast< const ::rtl::OUString * >( rAny.getValue() ));
+}
+// type
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= (
+ const ::com::sun::star::uno::Any & rAny, ::com::sun::star::uno::Type & value )
+{
+ if (::com::sun::star::uno::TypeClass_TYPE == rAny.getValueTypeClass())
+ {
+ value = * reinterpret_cast< const ::com::sun::star::uno::Type * >( rAny.getValue() );
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == (
+ const ::com::sun::star::uno::Any & rAny, const ::com::sun::star::uno::Type & value )
+{
+ return (::com::sun::star::uno::TypeClass_TYPE == rAny.getValueTypeClass() &&
+ value == * reinterpret_cast< const ::com::sun::star::uno::Type * >( rAny.getValue() ));
+}
+// any
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= (
+ const ::com::sun::star::uno::Any & rAny, ::com::sun::star::uno::Any & value )
+{
+ value = rAny;
+ return sal_True;
+}
+// interface
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == (
+ const ::com::sun::star::uno::Any & rAny, const ::com::sun::star::uno::BaseReference & value )
+{
+ if (::com::sun::star::uno::TypeClass_INTERFACE == rAny.getValueTypeClass())
+ {
+ ::com::sun::star::uno::XInterface * p1 =
+ * reinterpret_cast< ::com::sun::star::uno::XInterface * const * >( rAny.getValue() );
+ if (p1 && p1 == value.get())
+ return sal_True;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xI1(
+ p1, ::com::sun::star::uno::UNO_QUERY );
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xI2(
+ value.get(), ::com::sun::star::uno::UNO_QUERY );
+ return (xI1.is() && xI1.get() == xI2.get());
+ }
+ return sal_False;
+}
+
+// operator to compare to an any.
+//__________________________________________________________________________________________________
+template< class C >
+inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const C & value )
+{
+ const ::com::sun::star::uno::Type & rType = ::getCppuType( &value );
+ return ::uno_type_equalData(
+ const_cast< void * >( rAny.getValue() ), rAny.getValueTypeRef(),
+ const_cast< C * >( &value ), rType.getTypeLibType(),
+ ::com::sun::star::uno::cpp_queryInterface,
+ ::com::sun::star::uno::cpp_release );
+}
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Reference.h b/cppu/inc/com/sun/star/uno/Reference.h
new file mode 100644
index 000000000000..4db47ad47402
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Reference.h
@@ -0,0 +1,342 @@
+/*************************************************************************
+ *
+ * $RCSfile: Reference.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#define _COM_SUN_STAR_UNO_REFERENCE_H_
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+class XInterface;
+
+/** Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
+ <br>
+*/
+enum __UnoReference_NoAcquire
+{
+ /** This enum value can be used for creating a reference granting a given
+ interface, i.e. transferring ownership to it.
+ <br>
+ */
+ UNO_REF_NO_ACQUIRE = 0xbebeef
+};
+
+/** Base reference class holding/ acquiring an interface.<br>
+ Constructors acquire an interface while the destructor releases it.
+ This class serves as a base class for all template reference classes and
+ has been introduced due to compiler problems with templated operators ==, =!.
+ <br>
+*/
+class BaseReference
+{
+ /** the interface pointer<br>
+ */
+ XInterface * _pInterface;
+
+protected:
+ /** Default Constructor:
+ Sets null reference.
+ <br>
+ */
+ inline BaseReference();
+ /** Constructor:
+ Sets given interface pointer.
+ <br>
+ @param pInterface an interface pointer
+ */
+ inline BaseReference( XInterface * pInterface );
+ /** Constructor:
+ Sets reference to given interface pointer without acquiring it.
+ <br>
+ @param pInterface interface pointer
+ @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline BaseReference( XInterface * pInterface, __UnoReference_NoAcquire );
+ /** Copy constructor:
+ Copies interface reference.
+ <br>
+ @param rRef another reference
+ */
+ inline BaseReference( const BaseReference & rRef );
+ /** Destructor:
+ Releases interface reference.
+ <br>
+ */
+ inline ~BaseReference();
+
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) throw()
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) throw()
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) throw()
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) throw()
+ {}
+
+ /** Sets interface pointer. An interface already set will be released.
+ <br>
+ @param pInterface an interface pointer
+ */
+ inline void SAL_CALL set( XInterface * pInterface );
+ /** Clears reference, i.e. releases interface.
+ Reference is null after clear() call.
+ <br>
+ */
+ inline void SAL_CALL clear();
+ /** Gets interface pointer.
+ This call does <b>not</b> acquire the interface.
+ <br>
+ @return <b>un</b>acquired interface pointer
+ */
+ inline XInterface * SAL_CALL get() const
+ { return _pInterface; }
+ /** Checks if reference is null.
+ <br>
+ @return true if reference acquires an interface, i.e. is not null
+ */
+ inline sal_Bool SAL_CALL is() const
+ { return (_pInterface != 0); }
+ /** Equality operator: compares two interfaces<br>
+ Checks if both references are null or refer to the same object.
+ <br>
+ @param rRef another reference
+ @return true if both references are null or refer to the same object, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const BaseReference & rRef ) const;
+ /** Unequality operator: compares two interfaces<br>
+ Checks if both references are null or refer to the same object.
+ <br>
+ @param rRef another reference
+ @return false if both references are null or refer to the same object, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const
+ { return (! operator == ( rRef )); }
+
+ // needed for stl container operations, though this makes no sense on pointers
+ inline sal_Bool SAL_CALL operator < ( const BaseReference& rRef ) const
+ { return (_pInterface < rRef._pInterface); }
+};
+
+/** Enum defining UNO_QUERY and UNO_REF_NO_ACQUIRE for query interface constructor
+ of reference template.
+ <br>
+*/
+enum __UnoReference_Query
+{
+ /** This enum value can be used for querying interface constructor of reference template.
+ <br>
+ */
+ UNO_REF_QUERY = 0xdb0e121e,
+ UNO_QUERY = 0xdb0
+};
+
+/** Template reference class for interface type derived from BaseReference.
+ A special constructor given the UNO_QUERY or UNO_REF_QUERY identifier queries interfaces
+ for reference type.
+ <br>
+*/
+template< class interface_type >
+class Reference : public BaseReference
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ static void * SAL_CALL operator new( size_t nSize ) throw()
+ { return ::rtl_allocateMemory( nSize ); }
+ static void SAL_CALL operator delete( void * pMem ) throw()
+ { ::rtl_freeMemory( pMem ); }
+ static void * SAL_CALL operator new( size_t, void * pMem ) throw()
+ { return pMem; }
+ static void SAL_CALL operator delete( void *, void * ) throw()
+ {}
+
+ /** Default Constructor:
+ Sets null reference.
+ <br>
+ */
+ inline Reference()
+ : BaseReference()
+ {}
+ /** Copy constructor:
+ Copies interface reference.
+ <br>
+ @param rRef another reference
+ */
+ inline Reference( const Reference< interface_type > & rRef )
+ : BaseReference( rRef )
+ {}
+ /** Constructor:
+ Sets given interface pointer.
+ <br>
+ @param pInterface an interface pointer
+ */
+ inline Reference( interface_type * pInterface )
+ : BaseReference( pInterface )
+ {}
+
+ /** Constructor:
+ Sets given interface pointer without acquiring it.
+ <br>
+ @param pInterface another reference
+ @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Reference( XInterface * pInterface, __UnoReference_NoAcquire )
+ : BaseReference( pInterface, UNO_REF_NO_ACQUIRE )
+ {}
+
+ /** Constructor:
+ Queries given interface for reference interface type (<b>interface_type</b>).
+ <br>
+ @param rRef another reference
+ @param dummy UNO_QUERY or UNO_REF_QUERY to force obvious distinction to other constructors
+ */
+ inline Reference( const BaseReference & rRef, __UnoReference_Query )
+ : BaseReference( query( rRef ) )
+ {}
+ /** Constructor:
+ Queries given interface for reference interface type (<b>interface_type</b>).
+ <br>
+ @param pInterface an interface pointer
+ @param dummy UNO_QUERY to force obvious distinction to other constructors
+ */
+ inline Reference( XInterface * pInterface, __UnoReference_Query )
+ : BaseReference( query( pInterface ) )
+ {}
+
+ /** Assignment operator:
+ Acquires given interface pointer and sets reference.
+ An interface already set will be released.
+ <br>
+ @param pInterface an interface pointer
+ @return this reference
+ */
+ inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface );
+ /** Assignment operator:
+ Acquires given interface reference and sets reference.
+ An interface already set will be released.
+ <br>
+ @param rRef an interface reference
+ @return this reference
+ */
+ inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef )
+ { return operator = ( rRef.get() ); }
+
+ /** Queries given interface for type <b>interface_type</b>.
+ <br>
+ @param pInterface interface pointer
+ @return interface reference of demanded type (may be null)
+ */
+ inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface );
+ /** Queries given interface reference for type <b>interface_type</b>.
+ <br>
+ @param rRef interface reference
+ @return interface reference of demanded type (may be null)
+ */
+ inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef )
+ { return query( rRef.get() ); }
+
+ /** Cast operatory to Reference< XInterface >:
+ Reference objects are binary compatible and any interface must be derived
+ from com.sun.star.uno.XInterface.
+ This a useful direct cast possibility.
+ <br>
+ */
+ inline SAL_CALL operator const Reference< XInterface > & () const
+ { return * reinterpret_cast< const Reference< XInterface > * >( this ); }
+
+ /** Dereference operator:
+ Used to call interface methods.
+ <br>
+ @return <b>un</b>acquired interface pointer
+ */
+ interface_type * SAL_CALL operator -> () const
+ { return static_cast< interface_type * >( BaseReference::get() ); }
+
+ /** Gets interface pointer.
+ This call does <b>not</b> acquire the interface.
+ <br>
+ @return <b>un</b>acquired interface pointer
+ */
+ interface_type * SAL_CALL get() const
+ { return static_cast< interface_type * >( BaseReference::get() ); }
+};
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Reference.hxx b/cppu/inc/com/sun/star/uno/Reference.hxx
new file mode 100644
index 000000000000..adcc32fd493f
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Reference.hxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * $RCSfile: Reference.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#define _COM_SUN_STAR_UNO_REFERENCE_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#include <com/sun/star/uno/Reference.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HDL_
+#include <com/sun/star/uno/XInterface.hdl>
+#endif
+#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_
+#include <com/sun/star/uno/genfunc.hxx>
+#endif
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+inline BaseReference::BaseReference()
+ : _pInterface( 0 )
+{
+}
+//__________________________________________________________________________________________________
+inline BaseReference::BaseReference( XInterface * pInterface )
+ : _pInterface( pInterface )
+{
+ if (_pInterface)
+ _pInterface->acquire();
+}
+//__________________________________________________________________________________________________
+inline BaseReference::BaseReference( XInterface * pInterface, __UnoReference_NoAcquire )
+ : _pInterface( pInterface )
+{
+}
+//__________________________________________________________________________________________________
+inline BaseReference::BaseReference( const BaseReference & rRef )
+ : _pInterface( rRef._pInterface )
+{
+ if (_pInterface)
+ _pInterface->acquire();
+}
+//__________________________________________________________________________________________________
+inline BaseReference::~BaseReference()
+{
+ if (_pInterface)
+ _pInterface->release();
+}
+//__________________________________________________________________________________________________
+inline sal_Bool BaseReference::operator == ( const BaseReference & rRef ) const
+{
+ if (_pInterface == rRef._pInterface)
+ return sal_True;
+ // only the query to XInterface must return the same pointer if they belong to same objects
+ Reference< XInterface > x1( _pInterface, UNO_QUERY );
+ Reference< XInterface > x2( rRef, UNO_QUERY );
+ return (x1.get() == x2.get());
+}
+//__________________________________________________________________________________________________
+inline void BaseReference::set( XInterface * pInterface )
+{
+ if (pInterface != _pInterface)
+ {
+ if (pInterface)
+ pInterface->acquire();
+ if (_pInterface)
+ _pInterface->release();
+ _pInterface = pInterface;
+ }
+}
+//__________________________________________________________________________________________________
+inline void BaseReference::clear()
+{
+ if (_pInterface)
+ {
+ _pInterface->release();
+ _pInterface = 0;
+ }
+}
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > & Reference< interface_type >::operator = ( interface_type * pInterface )
+{
+ BaseReference::set( pInterface );
+ return *this;
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > Reference< interface_type >::query( XInterface * pInterface )
+{
+ const Type & rType = ::getCppuType( (const Reference< interface_type > *)0 );
+ return Reference< interface_type >( reinterpret_cast< XInterface * >(
+ cpp_queryInterface( pInterface, rType.getTypeLibType() ) ), UNO_REF_NO_ACQUIRE );
+}
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Sequence.h b/cppu/inc/com/sun/star/uno/Sequence.h
new file mode 100644
index 000000000000..f87e78122e74
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Sequence.h
@@ -0,0 +1,291 @@
+/*************************************************************************
+ *
+ * $RCSfile: Sequence.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
+#define _COM_SUN_STAR_UNO_SEQUENCE_H_
+
+#ifndef _CPPU_MACROS_HXX_
+#include <cppu/macros.hxx>
+#endif
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+#ifndef _UNO_SEQUENCE2_H_
+#include <uno/sequence2.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_TYPE_H_
+#include <com/sun/star/uno/Type.h>
+#endif
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+
+namespace rtl
+{
+class ByteSequence;
+}
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+/** Template C++ class representing an IDL sequence<>. Template argument is
+ sequence element type<br>
+ C++ Sequences are reference counted and shared, so the sequence keeps a handle
+ to its data.
+ To keep value semantics, copies are only generated if the sequence is to be modified
+ (new handle).
+ <br>
+*/
+template< class E >
+class Sequence
+{
+ /** sequence handle<br>
+ */
+ uno_Sequence * _pSequence;
+
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) throw()
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) throw()
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) throw()
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) throw()
+ {}
+
+ /** typedefs the element type of the sequence
+ <br>
+ */
+ typedef E ElementType;
+
+ /** Default constructor:
+ Creates an empty sequence.
+ <br>
+ */
+ inline Sequence< E >();
+ /** Copy constructor:
+ Creates a copy of given sequence.
+ <br>
+ @param rSeq another sequence of same type
+ */
+ inline Sequence< E >( const Sequence< E > & rSeq );
+ /** Constructor:
+ Creates a copy of given elements.
+ <br>
+ @param pElement an array of elements
+ @param len length of array
+ */
+ inline Sequence< E >( const E * pElements, sal_Int32 len );
+ /** Constructor:
+ Creates a default constructed sequence of given length.
+ <br>
+ @param len initial sequence length
+ */
+ inline Sequence< E >( sal_Int32 len );
+ /** Destructor:
+ Releases sequence handle. Last handle will destruct elements and free memory.
+ <br>
+ */
+ inline ~Sequence< E >();
+
+ /** Assignment operator:
+ Acquires given sequence handle and releases previously set handle.
+ <br>
+ @param rSeq another sequence of same type
+ @return this sequence
+ */
+ inline Sequence< E > & SAL_CALL operator = ( const Sequence< E > & rSeq );
+
+ /** Gets type of elements.
+ <br>
+ @return type of element
+ */
+ inline const Type & getElementType() const
+ { return ::getCppuType( (const ElementType *)0 ); }
+ /** Gets length of sequence.
+ <br>
+ @return length of sequence
+ */
+ inline sal_Int32 SAL_CALL getLength() const
+ { return _pSequence->nElements; }
+
+ /** Gets a pointer to elements array for <b>reading</b>.
+ If the sequence has a length of 0, then the returned pointer is undefined.
+ <br>
+ @return pointer to elements array
+ */
+ inline const E * SAL_CALL getConstArray() const
+ { return reinterpret_cast< const E * >( _pSequence->elements ); }
+ /** Gets a pointer to elements array for <b>reading and writing</b>.<br>
+ In general if the sequence has a handle acquired by other sequences
+ (reference count > 1), then a new sequence is created copy constructing
+ all elements to keep value semantics!<br>
+ If the sequence has a length of 0, then the returned pointer is undefined.
+ <br>
+ @return pointer to elements array
+ */
+ inline E * SAL_CALL getArray();
+
+ /** Non-const index operator:
+ Obtains a reference to element indexed at given position.<br>
+ The implementation does <b>not</b> check for array bounds!<br>
+ In general if the sequence has a handle acquired by other sequences
+ (reference count > 1), then a new sequence is created copy constructing
+ all elements to keep value semantics!
+ <br>
+ @param nIndex index
+ @return non-const C++ reference to element
+ */
+ inline E & SAL_CALL operator [] ( sal_Int32 nIndex )
+ { return getArray()[ nIndex ]; }
+ /** Const index operator:
+ Obtains a reference to element indexed at given position.<br>
+ The implementation does <b>not</b> check for array bounds!<br>
+ <br>
+ @param nIndex index
+ @return const C++ reference to element
+ */
+ inline const E & SAL_CALL operator [] ( sal_Int32 nIndex ) const
+ { return getConstArray()[ nIndex ]; }
+
+ /** Equality operator:
+ Compares two sequences.
+ <br>
+ @param rSeq another sequence of same type (right side)
+ @return true if both sequences are equal, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const Sequence< E > & rSeq ) const;
+ /** Unequality operator:
+ Compares two sequences.
+ <br>
+ @param rSeq another sequence of same type (right side)
+ @return false if both sequences are equal, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const Sequence< E > & rSeq ) const
+ { return (! operator == ( rSeq )); }
+
+ /** Reallocates sequence to new length.
+ If the new length is smaller than the former, then upper elements
+ will be destructed (and their memory freed).
+ If the new length is greater than the former, then upper (new) elements
+ are default constructed.<br>
+ If the sequence has a handle acquired by other sequences
+ (reference count > 1), then the remaining elements are copy constructed
+ to a new sequence handle to keep value semantics!
+ <br>
+ @param nSize new size of sequence
+ */
+ inline void SAL_CALL realloc( sal_Int32 nSize );
+};
+
+/** Creates an UNO byte sequence from a SAL byte sequence.
+ <br>
+ @param rByteSequence a byte sequence
+ @return an UNO byte sequence
+*/
+inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
+ const ::rtl::ByteSequence & rByteSequence );
+
+}
+}
+}
+}
+
+/** Gets the meta type of IDL sequence.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL sequence
+*/
+template< class S >
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))
+inline const ::com::sun::star::uno::Type
+#else
+inline const ::com::sun::star::uno::Type &
+#endif
+SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< S > * );
+
+/** Gets the meta type of IDL <b>sequence< char ></b>.
+ This function has been introduced due to ambiguities with unsigned short.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL <b>sequence< char ></b>
+*/
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))
+inline const ::com::sun::star::uno::Type
+#else
+inline const ::com::sun::star::uno::Type &
+#endif
+SAL_CALL getCharSequenceCppuType();
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Sequence.hxx b/cppu/inc/com/sun/star/uno/Sequence.hxx
new file mode 100644
index 000000000000..7b9e3065571e
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Sequence.hxx
@@ -0,0 +1,236 @@
+/*************************************************************************
+ *
+ * $RCSfile: Sequence.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#define _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+
+#ifndef _CPPU_MACROS_HXX_
+#include <cppu/macros.hxx>
+#endif
+
+#ifndef _OSL_INTERLCK_H_
+#include <osl/interlck.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
+#include <com/sun/star/uno/Sequence.h>
+#endif
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_
+#include <com/sun/star/uno/genfunc.hxx>
+#endif
+
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence()
+{
+ const Type & rType = ::getCppuType( this );
+ ::uno_type_sequence_construct( &_pSequence, rType.getTypeLibType(), 0, 0, cpp_acquire );
+}
+//__________________________________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence( const Sequence< E > & rSeq )
+{
+ ::osl_incrementInterlockedCount( &rSeq._pSequence->nRefCount );
+ _pSequence = rSeq._pSequence;
+}
+//__________________________________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence( const E * pElements, sal_Int32 len )
+ : _pSequence( 0 )
+{
+ const Type & rType = ::getCppuType( this );
+ ::uno_type_sequence_construct( &_pSequence, rType.getTypeLibType(),
+ const_cast< E * >( pElements ), len, cpp_acquire );
+}
+//__________________________________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence( sal_Int32 len )
+ : _pSequence( 0 )
+{
+ const Type & rType = ::getCppuType( this );
+ ::uno_type_sequence_construct( &_pSequence, rType.getTypeLibType(), 0, len, cpp_acquire );
+}
+//__________________________________________________________________________________________________
+template< class E >
+inline Sequence< E >::~Sequence()
+{
+ const Type & rType = ::getCppuType( this );
+ ::uno_type_destructData( this, rType.getTypeLibType(), cpp_release );
+}
+//__________________________________________________________________________________________________
+template< class E >
+inline Sequence< E > & Sequence< E >::operator = ( const Sequence< E > & rSeq )
+{
+ const Type & rType = ::getCppuType( this );
+ ::uno_type_sequence_assign( &_pSequence, rSeq._pSequence, rType.getTypeLibType(), cpp_release );
+ return *this;
+}
+//__________________________________________________________________________________________________
+template< class E >
+inline sal_Bool Sequence< E >::operator == ( const Sequence< E > & rSeq ) const
+{
+ if (_pSequence == rSeq._pSequence)
+ return sal_True;
+ const Type & rType = ::getCppuType( this );
+ return ::uno_type_equalData( const_cast< Sequence< E > * >( this ), rType.getTypeLibType(),
+ const_cast< Sequence< E > * >( &rSeq ), rType.getTypeLibType(),
+ cpp_queryInterface, cpp_release );
+}
+//__________________________________________________________________________________________________
+template< class E >
+inline E * Sequence< E >::getArray()
+{
+ const Type & rType = ::getCppuType( this );
+ ::uno_type_sequence_reference2One( &_pSequence, rType.getTypeLibType(), cpp_acquire, cpp_release );
+ return reinterpret_cast< E * >( _pSequence->elements );
+}
+//__________________________________________________________________________________________________
+template< class E >
+inline void Sequence< E >::realloc( sal_Int32 nSize )
+{
+ const Type & rType = ::getCppuType( this );
+ ::uno_type_sequence_realloc( &_pSequence, rType.getTypeLibType(), nSize, cpp_acquire, cpp_release );
+}
+
+//--------------------------------------------------------------------------------------------------
+inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
+ const ::rtl::ByteSequence & rByteSequence )
+{
+ return ::com::sun::star::uno::Sequence< sal_Int8 >(
+ * reinterpret_cast< const ::com::sun::star::uno::Sequence< sal_Int8 > * >( &rByteSequence ) );
+}
+
+}
+}
+}
+}
+
+// generic sequence template
+template< class S >
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))
+inline const ::com::sun::star::uno::Type
+#else
+inline const ::com::sun::star::uno::Type &
+#endif
+SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< S > * )
+{
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))
+ typelib_TypeDescriptionReference * s_pType = 0;
+#else
+ static typelib_TypeDescriptionReference * s_pType = 0;
+ if (! s_pType)
+ {
+#endif
+ const ::com::sun::star::uno::Type & rElementType = ::getCppuType(
+ (::com::sun::star::uno::Sequence< S >::ElementType *)0 );
+ ::typelib_static_sequence_type_init( &s_pType, rElementType.getTypeLibType() );
+#if !( (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >( &s_pType );
+#else
+ return ::com::sun::star::uno::Type( s_pType );
+#endif
+}
+
+// char sequence
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))
+inline const ::com::sun::star::uno::Type
+#else
+inline const ::com::sun::star::uno::Type &
+#endif
+SAL_CALL getCharSequenceCppuType()
+{
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))
+ typelib_TypeDescriptionReference * s_pType = 0;
+#else
+ static typelib_TypeDescriptionReference * s_pType = 0;
+ if (! s_pType)
+ {
+#endif
+ const ::com::sun::star::uno::Type & rElementType = ::getCharCppuType();
+ ::typelib_static_sequence_type_init( &s_pType, rElementType.getTypeLibType() );
+#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >( &s_pType );
+#else
+ return ::com::sun::star::uno::Type( s_pType );
+#endif
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Type.h b/cppu/inc/com/sun/star/uno/Type.h
new file mode 100644
index 000000000000..7765d4e910ce
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Type.h
@@ -0,0 +1,364 @@
+/*************************************************************************
+ *
+ * $RCSfile: Type.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_TYPE_H_
+#define _COM_SUN_STAR_UNO_TYPE_H_
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_TYPECLASS_HDL_
+#include <com/sun/star/uno/TypeClass.hdl>
+#endif
+#ifndef _CPPU_MACROS_HXX_
+#include <cppu/macros.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+/** Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
+ <br>
+*/
+enum __UnoType_NoAcquire
+{
+ /** This enum value can be used for creating a Type object granting a given
+ type description reference, i.e. transferring ownership to it.
+ <br>
+ */
+ UNO_TYPE_NO_ACQUIRE = 0xbebeef1e
+};
+
+/** C++ class representing an IDL meta type.
+ This class is used to represent a a type, i.e. a type name and its type class.<br>
+ Internally the type holds a C type description reference of the runtime.
+ You can obtain a full type description of a type by calling member function
+ getDescription().
+ <br>
+*/
+class Type
+{
+ /** the C typelib reference pointer<br>
+ */
+ typelib_TypeDescriptionReference * _pType;
+
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) throw()
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) throw()
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) throw()
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) throw()
+ {}
+
+ /** Default Constructor:
+ Type is set to void.
+ <br>
+ */
+ inline Type();
+
+ /** Constructor:
+ Type is constructed by given name and type class.
+ <br>
+ @param eTypeClass type class of type
+ @param rTypeName name of type
+ */
+ inline Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName );
+
+ /** Constructor:
+ Type is constructed by given name and type class.
+ <br>
+ @param eTypeClass type class of type
+ @param pTypeName name of type
+ */
+ inline Type( TypeClass eTypeClass, const sal_Char * pTypeName );
+
+ /** Constructor:
+ Type is (copy) constructed by given C type description reference.
+ <br>
+ @param pType C type description reference
+ */
+ inline Type( typelib_TypeDescriptionReference * pType );
+
+ /** Constructor:
+ Type is (copy) constructed by given C type description reference without acquiring it.
+ <br>
+ @param pType C type description reference
+ @param dummy UNO_TYPE_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Type( typelib_TypeDescriptionReference * pType, __UnoType_NoAcquire );
+
+ /** Copy constructor:
+ Type is copy constructed by given type.
+ <br>
+ @param rType another type
+ */
+ inline Type( const Type & rType );
+
+ /** Destructor:
+ Releases acquired C type description reference.
+ <br>
+ */
+ inline ~Type()
+ { ::typelib_typedescriptionreference_release( _pType ); }
+
+ /** Assignment operator:
+ Acquires right side type and releases previously set type.
+ <br>
+ @param rType another type (right side)
+ @return this type
+ */
+ inline Type & SAL_CALL operator = ( const Type & rType );
+
+ /** Gets the type class of set type.
+ <br>
+ @return type class of set type
+ */
+ inline TypeClass SAL_CALL getTypeClass() const
+ { return (TypeClass)_pType->eTypeClass; }
+
+ /** Gets the name of the set type.
+ <br>
+ @return name of the set type
+ */
+ inline ::rtl::OUString SAL_CALL getTypeName() const
+ { return ::rtl::OUString( _pType->pTypeName ); }
+
+ /** Obtains a full type description of set type.
+ <br>
+ @param ppDescr [inout] type description
+ */
+ inline void SAL_CALL getDescription( typelib_TypeDescription ** ppDescr ) const
+ { ::typelib_typedescriptionreference_getDescription( ppDescr, _pType ); }
+
+ /** Gets the C typelib type description reference pointer.
+ Does <b>not</b> acquire the reference!
+ <br>
+ @return <b>un</b>acquired type description reference
+ */
+ inline typelib_TypeDescriptionReference * SAL_CALL getTypeLibType() const
+ { return _pType; }
+
+ /** Compares two types.
+ <br>
+ @param rType another type
+ @return true if both types refer the same type, false otherwise
+ */
+ inline sal_Bool SAL_CALL equals( const Type & rType ) const
+ { return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); }
+ /** Equality operator:
+ Compares two types.
+ <br>
+ @param rType another type
+ @return true if both types refer the same type, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const Type & rType ) const
+ { return equals( rType ); }
+ /** Unequality operator:
+ Compares two types.
+ <br>
+ @param rType another type
+ @return false if both types refer the same type, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const Type & rType ) const
+ { return (! equals( rType )); }
+};
+
+}
+}
+}
+}
+
+/** Gets the meta type of IDL type <b>type</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>type</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Type * );
+
+/** Gets the meta type of IDL type <b>void</b>.
+ @return type of IDL type <b>void</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType();
+/** Gets the meta type of IDL type <b>void</b>.
+ <br>
+ @return type of IDL type <b>void</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType();
+
+/** Gets the meta type of IDL type <b>boolean</b>.
+ <br>
+ @return type of IDL type <b>boolean</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType();
+/** Gets the meta type of IDL type <b>boolean</b>.
+ <br>
+ @return type of IDL type <b>boolean</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType();
+/** Gets the meta type of IDL type <b>boolean</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>boolean</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Bool * );
+
+/** Gets the meta type of IDL type <b>char</b>.
+ <br>
+ @return type of IDL type <b>char</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType();
+/** Gets the meta type of IDL type <b>char</b>.
+ <br>
+ @return type of IDL type <b>char</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType();
+
+/** Gets the meta type of IDL type <b>byte</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>byte</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int8 * );
+
+/** Gets the meta type of IDL type <b>string</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>string</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::rtl::OUString * );
+
+/** Gets the meta type of IDL type <b>short</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>short</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int16 * );
+
+/** Gets the meta type of IDL type <b>unsigned short</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>unsigned short</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt16 * );
+
+/** Gets the meta type of IDL type <b>long</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>long</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int32 * );
+
+/** Gets the meta type of IDL type <b>unsigned long</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>unsigned long</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt32 * );
+
+/** Gets the meta type of IDL type <b>hyper</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>hyper</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int64 * );
+
+/** Gets the meta type of IDL type <b>unsigned hyper</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>unsigned hyper</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt64 * );
+
+/** Gets the meta type of IDL type <b>float</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>float</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const float * );
+
+/** Gets the meta type of IDL type <b>double</b>.
+ <br>
+ @param dummy typed pointer for function signature
+ @return type of IDL type <b>double</b>
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const double * );
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Type.hxx b/cppu/inc/com/sun/star/uno/Type.hxx
new file mode 100644
index 000000000000..f40eb7fb602d
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Type.hxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * $RCSfile: Type.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
+#define _COM_SUN_STAR_UNO_TYPE_HXX_
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_TYPE_H_
+#include <com/sun/star/uno/Type.h>
+#endif
+
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+inline Type::Type()
+{
+ _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) )->getTypeLibType();
+ ::typelib_typedescriptionreference_acquire( _pType );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName )
+ : _pType( 0 )
+{
+ ::typelib_typedescriptionreference_new( &_pType, (typelib_TypeClass)eTypeClass, rTypeName.pData );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( TypeClass eTypeClass, const sal_Char * pTypeName )
+ : _pType( 0 )
+{
+ ::typelib_typedescriptionreference_newByAsciiName( &_pType, (typelib_TypeClass)eTypeClass, pTypeName );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( typelib_TypeDescriptionReference * pType )
+ : _pType( pType )
+{
+ ::typelib_typedescriptionreference_acquire( _pType );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( typelib_TypeDescriptionReference * pType, __UnoType_NoAcquire )
+ : _pType( pType )
+{
+}
+//__________________________________________________________________________________________________
+inline Type::Type( const Type & rType )
+ : _pType( rType._pType )
+{
+ ::typelib_typedescriptionreference_acquire( _pType );
+}
+//__________________________________________________________________________________________________
+inline Type & Type::operator = ( const Type & rType )
+{
+ ::typelib_typedescriptionreference_assign( &_pType, rType._pType );
+ return *this;
+}
+
+}
+}
+}
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Type * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_TYPE ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType()
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) );
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType()
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType()
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_BOOLEAN ) );
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType()
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_BOOLEAN ) );
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Bool * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_BOOLEAN ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType()
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_CHAR ) );
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType()
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_CHAR ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int8 * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_BYTE ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::rtl::OUString * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_STRING ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int16 * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_SHORT ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt16 * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_UNSIGNED_SHORT ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int32 * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_LONG ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt32 * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_UNSIGNED_LONG ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int64 * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_HYPER ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt64 * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_UNSIGNED_HYPER ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const float * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_FLOAT ) );
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const double * )
+{
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_DOUBLE ) );
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/genfunc.h b/cppu/inc/com/sun/star/uno/genfunc.h
new file mode 100644
index 000000000000..853fb6828020
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/genfunc.h
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * $RCSfile: genfunc.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_GENFUNC_H_
+#define _COM_SUN_STAR_UNO_GENFUNC_H_
+
+typedef struct _typelib_TypeDescriptionReference typelib_TypeDescriptionReference;
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+extern "C"
+{
+/** C function to acquire a C++ interface.
+ <br>
+ @param pCppI C++ interface pointer
+*/
+inline void SAL_CALL cpp_acquire( void * pCppI );
+/** C function to release a C++ interface.
+ <br>
+ @param pCppI C++ interface pointer
+*/
+inline void SAL_CALL cpp_release( void * pCppI );
+/** C function to query for a C++ interface.
+ <br>
+ @param pCppI C++ interface pointer
+ @param pType demanded interface type
+ @return acquired C++ interface pointer or null
+*/
+inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescriptionReference * pType );
+}
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/genfunc.hxx b/cppu/inc/com/sun/star/uno/genfunc.hxx
new file mode 100644
index 000000000000..e392126a76c9
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/genfunc.hxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * $RCSfile: genfunc.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_
+#define _COM_SUN_STAR_UNO_GENFUNC_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_GENFUNC_H_
+#include <com/sun/star/uno/genfunc.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+extern "C"
+{
+//==================================================================================================
+inline void SAL_CALL cpp_acquire( void * pCppI )
+{
+ reinterpret_cast< XInterface * >( pCppI )->acquire();
+}
+//==================================================================================================
+inline void SAL_CALL cpp_release( void * pCppI )
+{
+ reinterpret_cast< XInterface * >( pCppI )->release();
+}
+//==================================================================================================
+inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescriptionReference * pType )
+{
+ if (pCppI)
+ {
+ Any aRet( reinterpret_cast< XInterface * >( pCppI )->queryInterface(
+ * reinterpret_cast< const Type * >( &pType ) ) );
+ if (aRet.hasValue())
+ {
+ XInterface * pRet = * reinterpret_cast< XInterface * const * >( aRet.getValue() );
+ pRet->acquire();
+ return pRet;
+ }
+ }
+ return 0;
+}
+}
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/cppu/macros.hxx b/cppu/inc/cppu/macros.hxx
new file mode 100644
index 000000000000..5c9f6f62b9d0
--- /dev/null
+++ b/cppu/inc/cppu/macros.hxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * $RCSfile: macros.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPU_MACROS_HXX_
+#define _CPPU_MACROS_HXX_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _UNO_LBNAMES_H_
+#include <uno/lbnames.h>
+#endif
+
+
+// Microsoft Visual C++ 4.x, 5.0, 6.0
+#if defined(_MSC_VER)
+# if ( _MSC_VER < 1000 )
+# define CPPU_COMPILER_ERROR "msc version must be between 4.2 and 6.x"
+# elif (_MSC_VER < 1100) // MSVC 4.x
+# pragma warning( disable: 4290 )
+# define CPPU_CLBN_TMP UNO_LB_MSCI
+# define CPPU_CLBN_NS_TMP UNO_LB_MSCI_NAMESPACE
+# elif(_MSC_VER < 1200) // MSVC 5.0
+# define CPPU_CLBN_TMP UNO_LB_MSCI
+# define CPPU_CLBN_NS_TMP UNO_LB_MSCI_NAMESPACE
+# elif(_MSC_VER < 1300) // MSVC 6.0
+# define CPPU_CLBN_TMP UNO_LB_MSCI
+# define CPPU_CLBN_NS_TMP UNO_LB_MSCI_NAMESPACE
+# else
+# define CPPU_COMPILER_ERROR "msc version must be between 4.2 and 6.x"
+# endif
+
+// AIX xlC 3.1 , 3.0.1 ==0x301
+// Visual Age C++ 3.x
+#elif ( defined (__xlC__) && __xlC__ < 0x400 ) || \
+ ( defined ( __IBMCPP__ ) && ( __IBMCPP__ < 400 ) )
+# define CPPU_COMPILER_ERROR "visual age on aix not supported"
+
+// Borland C++ ( 5.x )
+#elif defined (BC50)
+# define CPPU_COMPILER_ERROR "borland compiler not supported"
+
+#elif defined(__SUNPRO_CC)
+# if ( __SUNPRO_CC < 0x500 )
+# define CPPU_COMPILER_ERROR "sunpro cc version must be 5.x"
+# elif( __SUNPRO_CC < 0x600 )
+# define CPPU_CLBN_TMP UNO_LB_SUNPRO5
+# define CPPU_CLBN_NS_TMP UNO_LB_SUNPRO5_NAMESPACE
+# else
+# define CPPU_COMPILER_ERROR "sunpro cc version must be 5.x"
+# endif
+
+// g++ 2.7.x
+#elif defined __GNUC__
+// cygnus have a lot of version, let's assume the best.
+// no specific definitions known except this one
+# if ( __GNUC__ == 2 && __GNUC_MINOR__ == 7 )
+# define CPPU_COMPILER_ERROR "gcc 2.7 compiler not supported"
+# elif ( __GNUC__ == 2 && __GNUC_MINOR__ == 91 )
+# define CPPU_CLBN_TMP UNO_LB_GCC2
+# define CPPU_CLBN_NS_TMP UNO_LB_GCC2_NAMESPACE
+# elif ( __GNUC__ == 2 && __GNUC_MINOR__ == 95 )
+# define CPPU_CLBN_TMP UNO_LB_GCC2
+# define CPPU_CLBN_NS_TMP UNO_LB_GCC2_NAMESPACE
+# else
+# define CPPU_COMPILER_ERROR "gcc unknown version"
+# endif
+
+#elif defined (__WATCOM_CPLUSPLUS__)
+# define CPPU_COMPILER_ERROR "watcom compiler not supported"
+
+// Symantec 7.5
+#elif defined (__SC__)
+# define CPPU_COMPILER_ERROR "symantec compiler not supported"
+
+// HP-UX und aCC
+#elif defined(HPUX) && !defined(__GNUC__)
+# define CPPU_COMPILER_ERROR "HP-UX compiler not supported"
+
+// MAC Metrowerks
+#elif defined (__MWERKS__)
+# define CPPU_COMPILER_ERROR "Metroworks compiler not supported"
+#else
+# define CPPU_COMPILER_ERROR "unknown compiler"
+#endif
+
+#ifdef CPPU_COMPILER_ERROR
+// set to unknown
+# error CPPU_COMPILER_ERROR
+#endif
+
+/**
+ The compiler and systems defines to identify compatibilities
+ use to mark an unknown system, processor or compiler
+*/
+#define CPPU_CURRENT_LANGUAGE_BINDING_NAME CPPU_CLBN_TMP
+#define CPPU_CURRENT_NAMESPACE CPPU_CLBN_NS_TMP
+
+#endif // _USR_MACROS_HXX_
+
+
+
diff --git a/cppu/inc/typelib/typeclass.h b/cppu/inc/typelib/typeclass.h
new file mode 100644
index 000000000000..7cace8fe0a6a
--- /dev/null
+++ b/cppu/inc/typelib/typeclass.h
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * $RCSfile: typeclass.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _TYPELIB_TYPECLASS_H_
+#define _TYPELIB_TYPECLASS_H_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+/** This type class enum is binary compatible with the IDL enum
+ com.sun.star.uno.TypeClass.
+ <br>
+*/
+enum typelib_TypeClass
+{
+ /** type class of void<br> */
+ typelib_TypeClass_VOID = 0,
+ /** type class of char<br> */
+ typelib_TypeClass_CHAR = 1,
+ /** type class of boolean<br> */
+ typelib_TypeClass_BOOLEAN = 2,
+ /** type class of byte<br> */
+ typelib_TypeClass_BYTE = 3,
+ /** type class of short<br> */
+ typelib_TypeClass_SHORT = 4,
+ /** type class of unsigned short<br> */
+ typelib_TypeClass_UNSIGNED_SHORT = 5,
+ /** type class of long<br> */
+ typelib_TypeClass_LONG = 6,
+ /** type class of unsigned long<br> */
+ typelib_TypeClass_UNSIGNED_LONG = 7,
+ /** type class of hyper<br> */
+ typelib_TypeClass_HYPER = 8,
+ /** type class of unsigned hyper<br> */
+ typelib_TypeClass_UNSIGNED_HYPER = 9,
+ /** type class of float<br> */
+ typelib_TypeClass_FLOAT = 10,
+ /** type class of double<br> */
+ typelib_TypeClass_DOUBLE = 11,
+ /** type class of string<br> */
+ typelib_TypeClass_STRING = 12,
+ /** type class of type<br> */
+ typelib_TypeClass_TYPE = 13,
+ /** type class of any<br> */
+ typelib_TypeClass_ANY = 14,
+ /** type class of enum<br> */
+ typelib_TypeClass_ENUM = 15,
+ /** type class of typedef<br> */
+ typelib_TypeClass_TYPEDEF = 16,
+ /** type class of struct<br> */
+ typelib_TypeClass_STRUCT = 17,
+ /** type class of union<br> */
+ typelib_TypeClass_UNION = 18,
+ /** type class of exception<br> */
+ typelib_TypeClass_EXCEPTION = 19,
+ /** type class of sequence<br> */
+ typelib_TypeClass_SEQUENCE = 20,
+ /** type class of array (not impl)<br> */
+ typelib_TypeClass_ARRAY = 21,
+ /** type class of interface<br> */
+ typelib_TypeClass_INTERFACE = 22,
+ /** type class of service (not impl)<br> */
+ typelib_TypeClass_SERVICE = 23,
+ /** type class of module (not impl)<br> */
+ typelib_TypeClass_MODULE = 24,
+ /** type class of interface method<br> */
+ typelib_TypeClass_INTERFACE_METHOD = 25,
+ /** type class of interface attribute<br> */
+ typelib_TypeClass_INTERFACE_ATTRIBUTE = 26,
+ /** type class of unknown<br> */
+ typelib_TypeClass_UNKNOWN = 27,
+ typelib_TypeClass_MAKE_FIXED_SIZE = SAL_MAX_ENUM
+};
+
+#endif
diff --git a/cppu/inc/typelib/typedescription.h b/cppu/inc/typelib/typedescription.h
new file mode 100644
index 000000000000..81244f0d5158
--- /dev/null
+++ b/cppu/inc/typelib/typedescription.h
@@ -0,0 +1,910 @@
+/*************************************************************************
+ *
+ * $RCSfile: typedescription.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#define _TYPELIB_TYPEDESCRIPTION_H_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _TYPELIB_UIK_H_
+#include <typelib/uik.h>
+#endif
+#ifndef _TYPELIB_TYPECLASS_H_
+#include <typelib/typeclass.h>
+#endif
+#ifndef _RTL_USTRING_H_
+#include <rtl/ustring.h>
+#endif
+
+typedef struct _typelib_TypeDescription typelib_TypeDescription;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifdef SAL_W32
+#pragma pack(push, 8)
+#elif defined(SAL_OS2)
+#pragma pack(8)
+#endif
+
+/** Holds a weak reference to a type description.
+ <br>
+*/
+typedef struct _typelib_TypeDescriptionReference
+{
+ /** reference count of reference;
+ don't ever modify this by yourself, use
+ typelib_typedescriptionreference_acquire() and
+ typelib_typedescriptionreference_release()
+ <br>
+ */
+ sal_Int32 nRefCount;
+ /** type class of type<br>
+ */
+ typelib_TypeClass eTypeClass;
+ /** fully qualified name of type<br>
+ */
+ rtl_uString * pTypeName;
+ /** pointer to full typedescription; this value is only valid if
+ the type is never swapped out<br>
+ */
+ typelib_TypeDescription * pType;
+ /** pointer to optimize the runtime; not for public use<br>
+ */
+ void * pUniqueIdentifier;
+ /** reserved for future use; 0 if not used<br>
+ */
+ void * pReserved;
+} typelib_TypeDescriptionReference;
+
+/** Full type description of a type. Memory layout of this struct
+ is identical to the typelib_TypeDescriptionReference for the first six members.
+ So a typedescription can be used as type reference.
+ <br>
+*/
+typedef struct _typelib_TypeDescription
+{
+ /** reference count;
+ don't ever modify this by yourself, use
+ typelib_typedescription_acquire() and
+ typelib_typedescription_release()
+ <br>
+ */
+ sal_Int32 nRefCount;
+ /** type class of type<br>
+ */
+ typelib_TypeClass eTypeClass;
+ /** fully qualified name of type<br>
+ */
+ rtl_uString * pTypeName;
+ /** pointer to self to distinguish reference from description;
+ for internal use only<br>
+ */
+ typelib_TypeDescription * pSelf;
+ /** pointer to optimize the runtime; not for public use<br>
+ */
+ void * pUniqueIdentifier;
+ /** reserved for future use; 0 if not used<br>
+ */
+ void * pReserved;
+
+ /** flag to determine whether the description is complete:
+ compound and union types lack of member names,
+ enums lack of member types and names,
+ interfaces lack of members and table init.
+ Call typelib_typedescription_complete() if false.
+ <br>
+ */
+ sal_Bool bComplete;
+ /** size of type<br>
+ */
+ sal_Int32 nSize;
+ /** alignment of type<br>
+ */
+ sal_Int32 nAlignment;
+ /** pointer to weak reference<br>
+ */
+ typelib_TypeDescriptionReference * pWeakRef;
+ /** determines, if type can be unloaded (and it is possible to reloaded it)<br>
+ */
+ sal_Bool bOnDemand;
+} typelib_TypeDescription;
+
+typedef struct _typelib_CompoundTypeDescription typelib_CompoundTypeDescription;
+
+/** Type description of a struct or exception.
+ <br>
+*/
+typedef struct _typelib_CompoundTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription<br>
+ */
+ typelib_TypeDescription aBase;
+
+ /** pointer to base type description, else 0<br>
+ */
+ typelib_CompoundTypeDescription * pBaseTypeDescription;
+
+ /** number of members<br>
+ */
+ sal_Int32 nMembers;
+ /** byte offsets of each member including the size the base type<br>
+ */
+ sal_Int32 * pMemberOffsets;
+ /** members of the struct or exception<br>
+ */
+ typelib_TypeDescriptionReference ** ppTypeRefs;
+ /** member names of the struct or exception<br>
+ */
+ rtl_uString ** ppMemberNames;
+} typelib_CompoundTypeDescription;
+
+/** Type description of a union.<br>
+ The type class of this description is typelib_TypeClass_UNION.
+ <br>
+*/
+typedef struct _typelib_UnionTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription<br>
+ */
+ typelib_TypeDescription aBase;
+
+ /** type of the discriminant<br>
+ */
+ typelib_TypeDescriptionReference * pDiscriminantTypeRef;
+
+ /** union default descriminant<br>
+ */
+ sal_Int64 nDefaultDiscriminant;
+ /** union default member type (may be 0)<br>
+ */
+ typelib_TypeDescriptionReference * pDefaultTypeRef;
+ /** number of union member types<br>
+ */
+ sal_Int32 nMembers;
+ /** union member discriminant values (same order as idl declaration)<br>
+ */
+ sal_Int64 * pDiscriminants;
+ /** union member value types (same order as idl declaration)<br>
+ */
+ typelib_TypeDescriptionReference ** ppTypeRefs;
+ /** union member value names (same order as idl declaration)<br>
+ */
+ rtl_uString ** ppMemberNames;
+ /** union value offset for data access<br>
+ */
+ sal_Int32 nValueOffset;
+} typelib_UnionTypeDescription;
+
+/** Type description of an array or sequence.
+ <br>
+*/
+typedef struct _typelib_IndirectTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription<br>
+ */
+ typelib_TypeDescription aBase;
+
+ /** array, sequence: pointer to element type<br>
+ */
+ typelib_TypeDescriptionReference * pType;
+} typelib_IndirectTypeDescription;
+
+/** Type description of an enum.<br>
+ The type class of this description is typelib_TypeClass_ENUM.
+ <br>
+*/
+typedef struct _typelib_EnumTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription<br>
+ */
+ typelib_TypeDescription aBase;
+
+ /** first value of the enum<br>
+ */
+ sal_Int32 nDefaultEnumValue;
+ /** number of enum values<br>
+ */
+ sal_Int32 nEnumValues;
+ /** names of enum values<br>
+ */
+ rtl_uString ** ppEnumNames;
+ /** values of enum (corresponding to names in similar order)<br>
+ */
+ sal_Int32 * pEnumValues;
+} typelib_EnumTypeDescription;
+
+/** Description of an interface method parameter.
+ <br>
+*/
+typedef struct _typelib_MethodParameter
+{
+ /** name of parameter<br>
+ */
+ rtl_uString * pName;
+ /** type of parameter<br>
+ */
+ typelib_TypeDescriptionReference * pTypeRef;
+ /** true: the call type of this parameter is [in] or [inout]
+ false: the call type of this parameter is [out]<br>
+ */
+ sal_Bool bIn;
+ /** true: the call type of this parameter is [out] or [inout]
+ false: the call type of this parameter is [in]<br>
+ */
+ sal_Bool bOut;
+} typelib_MethodParameter;
+
+/** Common base type description of
+ typelib_InterfaceMemberTypeDescription and
+ typelib_InterfaceAttributeTypeDescription.
+ <br>
+*/
+typedef struct _typelib_InterfaceMemberTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription<br>
+ */
+ typelib_TypeDescription aBase;
+
+ /** position of member in the interface including the number of members
+ of the base interface<br>
+ */
+ sal_Int32 nPosition;
+ /** name of member<br>
+ */
+ rtl_uString * pMemberName;
+} typelib_InterfaceMemberTypeDescription;
+
+/** Type description of an interface method.<br>
+ The type class of this description is typelib_TypeClass_INTERFACE_METHOD.
+ The size and the alignment are 0.
+ <br>
+*/
+typedef struct _typelib_InterfaceMethodTypeDescription
+{
+ /** inherits all members of typelib_InterfaceMemberTypeDescription<br>
+ */
+ typelib_InterfaceMemberTypeDescription aBase;
+
+ /** type of the return value<br>
+ */
+ typelib_TypeDescriptionReference * pReturnTypeRef;
+ /** number of parameters<br>
+ */
+ sal_Int32 nParams;
+ /** array of parameters<br>
+ */
+ typelib_MethodParameter * pParams;
+ /** number of exceptions<br>
+ */
+ sal_Int32 nExceptions;
+ /** array of exception types<br>
+ */
+ typelib_TypeDescriptionReference ** ppExceptions;
+ /** determines whether method is declared oneway<br>
+ */
+ sal_Bool bOneWay;
+} typelib_InterfaceMethodTypeDescription;
+
+/** The description of an interface attribute.<br>
+ The type class of this description is typelib_TypeClass_INTERFACE_ATTRIBUTE.
+ The size and the alignment are 0.
+ <br>
+*/
+typedef struct _typelib_InterfaceAttributeTypeDescription
+{
+ /** inherits all members of typelib_InterfaceMemberTypeDescription<br>
+ */
+ typelib_InterfaceMemberTypeDescription aBase;
+
+ /** determines whether attribute is read only<br>
+ */
+ sal_Bool bReadOnly;
+ /** type of the attribute<br>
+ */
+ typelib_TypeDescriptionReference * pAttributeTypeRef;
+} typelib_InterfaceAttributeTypeDescription;
+
+typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription;
+
+/** Type description of an interface.
+ <br>
+*/
+typedef struct _typelib_InterfaceTypeDescription
+{
+ /** inherits all members of typelib_TypeDescription<br>
+ */
+ typelib_TypeDescription aBase;
+
+ /** pointer to base type description, else 0<br>
+ */
+ typelib_InterfaceTypeDescription * pBaseTypeDescription;
+ /** unique identifier of interface<br>
+ */
+ typelib_Uik aUik;
+ /** number of members<br>
+ */
+ sal_Int32 nMembers;
+ /** array of members; references attributes or methods<br>
+ */
+ typelib_TypeDescriptionReference ** ppMembers;
+ /** number of members including members of base interface<br>
+ */
+ sal_Int32 nAllMembers;
+ /** array of members including members of base interface;
+ references attributes or methods<br>
+ */
+ typelib_TypeDescriptionReference ** ppAllMembers;
+ /** array mapping index of the member description to an index
+ doubling for read-write attributes (called function index);
+ size of array is nAllMembers<br>
+ */
+ sal_Int32 * pMapMemberIndexToFunctionIndex;
+ /** number of members plus number of read-write attributes<br>
+ */
+ sal_Int32 nMapFunctionIndexToMemberIndex;
+ /** array mapping function index to member index;
+ size of arry is nMapFunctionIndexToMemberIndex<br>
+ */
+ sal_Int32 * pMapFunctionIndexToMemberIndex;
+} typelib_InterfaceTypeDescription;
+
+/** Init struct of compound members for typelib_typedescription_new().
+ <br>
+*/
+typedef struct _typelib_CompoundMember_Init
+{
+ /** type class of compound member<br>
+ */
+ typelib_TypeClass eTypeClass;
+ /** name of type of compound member<br>
+ */
+ rtl_uString * pTypeName;
+ /** name of compound member<br>
+ */
+ rtl_uString * pMemberName;
+} typelib_CompoundMember_Init;
+
+/** Init struct of interface methods for typelib_typedescription_new().
+ <br>
+*/
+typedef struct _typelib_Parameter_Init
+{
+ /** type class of parameter<br>
+ */
+ typelib_TypeClass eTypeClass;
+ /** name of parameter<br>
+ */
+ rtl_uString * pTypeName;
+ /** name of parameter<br>
+ */
+ rtl_uString * pParamName;
+ /** true, if parameter is [in] or [inout]<br>
+ */
+ sal_Bool bIn;
+ /** true, if parameter is [out] or [inout]<br>
+ */
+ sal_Bool bOut;
+} typelib_Parameter_Init;
+
+/** Init struct of union types for typelib_typedescription_newUnion().
+ <br>
+*/
+typedef struct _typelib_Union_Init
+{
+ /** union member discriminant<br>
+ */
+ sal_Int64 nDiscriminant;
+ /** union member name<br>
+ */
+ rtl_uString * pMemberName;
+ /** union member type<br>
+ */
+ typelib_TypeDescriptionReference* pTypeRef;
+} typelib_Union_Init;
+
+#ifdef SAL_W32
+#pragma pack(pop)
+#elif defined(SAL_OS2)
+#pragma pack()
+#endif
+
+
+/** Creates a union type description.<br>
+ All discriminants are handled as int64 values.
+ The pDiscriminantTypeRef must be of type byte, short, ..., up to hyper.
+ <br>
+ @param ppRet inout union type description
+ @param pTypeName name of union type
+ @param pDiscriminantTypeRef discriminant type
+ @param nDefaultDiscriminant default discriminant
+ @param pDefaultTypeRef default value type of union
+ @param nMembers number of union members
+ @param pMembers init members
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newUnion(
+ typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ typelib_TypeDescriptionReference * pDiscriminantTypeRef,
+ sal_Int64 nDefaultDiscriminant,
+ typelib_TypeDescriptionReference * pDefaultTypeRef,
+ sal_Int32 nMembers,
+ typelib_Union_Init * pMembers );
+
+/** Creates an enum type description.
+ <br>
+ @param ppRet inout enum type description
+ @param pTypeName name of enum
+ @param nDefaultEnumValue default enum value
+ @param nEnumValues number of enum values
+ @param ppEnumNames names of enum values
+ @param pEnumValues enum values
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newEnum(
+ typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ sal_Int32 nDefaultValue,
+ sal_Int32 nEnumValues,
+ rtl_uString ** ppEnumNames,
+ sal_Int32 * pEnumValues );
+
+/** Creates a new type description.
+ <br>
+ @param ppRet inout type description
+ @param eTypeClass type class
+ @param pTypeName name of type
+ @param pType sequence, array: element type;
+ struct, Exception: base type;
+ @param nMembers number of members if struct, exception
+ @param pMember array of members if struct, exception
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_new(
+ typelib_TypeDescription ** ppRet,
+ typelib_TypeClass eTypeClass,
+ rtl_uString * pTypeName,
+ typelib_TypeDescriptionReference * pType,
+ sal_Int32 nMembers,
+ typelib_CompoundMember_Init * pMembers );
+
+/** Creates an interface type description.
+ <br>
+ @param ppRet inout interface type description
+ @param pTypeName the fully qualified name of the interface.
+ @param nUik1 uik part
+ @param nUik2 uik part
+ @param nUik3 uik part
+ @param nUik4 uik part
+ @param nUik5 uik part
+ @param pBaseInterface base interface type, else 0
+ @param nMembers number of members
+ @param ppMembers members; attributes or methods
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newInterface(
+ typelib_InterfaceTypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ sal_uInt32 nUik1, sal_uInt16 nUik2, sal_uInt16 nUik3, sal_uInt32 nUik4, sal_uInt32 nUik5,
+ typelib_TypeDescriptionReference * pBaseInterface,
+ sal_Int32 nMembers,
+ typelib_TypeDescriptionReference ** ppMembers );
+
+/** Creates an interface method type description.
+ <br>
+ @param ppRet inout method type description
+ @param nAbsolutePosition position of member including all members of base interfaces
+ @param bOneWay determines whether method is declared oneway
+ @param pTypeName fully qualified name of method including interface name
+ @param eReturnTypeClass type class of return type
+ @param pReturnTypeName type name of the return type
+ @param nParams number of parameters
+ @param pParams parameter types
+ @param nExceptions number of exceptions
+ @param ppExceptionNames type names of exceptions
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newInterfaceMethod(
+ typelib_InterfaceMethodTypeDescription ** ppRet,
+ sal_Int32 nAbsolutePosition,
+ sal_Bool bOneWay,
+ rtl_uString * pMethodName,
+ typelib_TypeClass eReturnTypeClass,
+ rtl_uString * pReturnTypeName,
+ sal_Int32 nParams,
+ typelib_Parameter_Init * pParams,
+ sal_Int32 nExceptions,
+ rtl_uString ** ppExceptionNames );
+
+/** Creates an interface attribute type description.
+ <br>
+ @param ppRet inout attribute type description
+ @param nAbsolutePosition position of this attribute including all members of base interfaces
+ @param pTypeName fully qualified name of attribute including interface name
+ @param eAttributeTypeClass type class of attribute type
+ @param pAttributeTypeName type name of attribute type
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newInterfaceAttribute(
+ typelib_InterfaceAttributeTypeDescription ** ppRet,
+ sal_Int32 nAbsolutePosition,
+ rtl_uString * pAttributeName,
+ typelib_TypeClass eAttributeTypeClass,
+ rtl_uString * pAttributeTypeName,
+ sal_Bool bReadOnly );
+
+/** Increments reference count of given type description.
+ <br>
+ @param pDesc type description
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_acquire( typelib_TypeDescription * pDesc );
+
+/** Decrements reference count of given type.<br>
+ If reference count reaches 0, the trype description is deleted.
+ <br>
+ @param pDesc type description
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_release( typelib_TypeDescription * pDesc );
+
+/** Registers a type description and creates a type description reference.<br>
+ Type descriptions will be registered automatically if they are provided
+ via the callback chain.
+ @param ppNewDescription inout description to be registered;
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_register(
+ typelib_TypeDescription ** ppNewDescription );
+
+/** Tests whether two types descriptions are equal, i.e. type class and names are equal.
+ <br>
+ @param p1 a type description
+ @param p2 another type description
+ @return true, if type descriptions are equal
+*/
+SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescription_equals(
+ const typelib_TypeDescription * p1, const typelib_TypeDescription * p2 );
+
+/** Retrieves a type description via its fully qualified name.
+ <br>
+ @param ppRet inout type description; *ppRet is 0, if type description was not found
+ @param pName name demanded type description
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_getByName(
+ typelib_TypeDescription ** ppRet, rtl_uString * pName );
+
+/** Sets size of type description cache.
+ <br>
+ @param nNewSize new size of cache
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_setCacheSize( sal_Int32 nNewSize );
+
+/** Function pointer declaration of callback function get additional descriptions.
+ Callbacks <b>must</b> provide <b>complete</b> type descriptions!
+ <br>
+ @param pContext callback context
+ @param ppRet inout type description
+ @param pTypeName name of demanded type description
+*/
+typedef void (SAL_CALL * typelib_typedescription_Callback)(
+ void * pContext, typelib_TypeDescription ** ppRet, rtl_uString * pTypeName );
+
+/** Registers callback function providing additional type descriptions.
+ <br>
+ @param pContext callback context
+ @param pCallback callback function
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_registerCallback(
+ void * pContext, typelib_typedescription_Callback pCallback );
+
+/** Revokes a previously registered callback function.
+ <br>
+ @param pContext callback context
+ @param pCallback registered callback function
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescription_revokeCallback(
+ void * pContext, typelib_typedescription_Callback pCallback );
+
+
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+
+/* Returns true, if the type description reference may lose the type
+ description. Otherwise pType is a valid pointer and cannot
+ be discarded through the lifetime of this reference.
+ Remark: If the pWeakObj of the type is set too, you can avoid
+ the call of ...getDescription(...) and use the description
+ direct. pWeakObj == 0 means, that the description is not
+ initialized.
+*/
+#define TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( eTypeClass ) \
+ ((eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || \
+ (eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE)
+
+/* Gets a description from the reference. The description may not be locked
+ by this call. You must use the TYPELIB_DANGER_RELEASE macro to release
+ the description fetched with this macro.
+*/
+#define TYPELIB_DANGER_GET( ppDescription, pTypeRef ) \
+{ \
+ typelib_TypeDescriptionReference * __pMacroTypeRef = (pTypeRef); \
+ if (TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( __pMacroTypeRef->eTypeClass )) \
+ { \
+ typelib_typedescriptionreference_getDescription( ppDescription, __pMacroTypeRef ); \
+ } \
+ else if (! __pMacroTypeRef->pType->pWeakRef) \
+ { \
+ typelib_typedescriptionreference_getDescription( ppDescription, __pMacroTypeRef ); \
+ typelib_typedescription_release( *(ppDescription) ); \
+ } \
+ else \
+ { \
+ *(ppDescription) = __pMacroTypeRef->pType; \
+ } \
+}
+
+/* Releases the description previouse fetched by TYPELIB_DANGER_GET.
+*/
+#define TYPELIB_DANGER_RELEASE( pDescription ) \
+{ \
+ if (TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( (pDescription)->eTypeClass )) \
+ typelib_typedescription_release( pDescription ); \
+}
+
+/** Creates a type description reference.<br>
+ This is a weak reference <b>not</b> holding the description.
+ If the description is already registered, the previous one is returned.
+ <br>
+ @param ppTDR inout type description reference
+ @param eTypeClass type class of type
+ @param pTypeName name of type
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_new(
+ typelib_TypeDescriptionReference ** ppTDR,
+ typelib_TypeClass eTypeClass,
+ rtl_uString * pTypeName );
+
+/** Creates a type description reference.<br>
+ This is a weak reference <b>not</b> holding the description.
+ If the description is already registered, the previous one is returned.
+ <br>
+ @param ppTDR inout type description reference
+ @param eTypeClass type class of type
+ @param pTypeName ascii name of type
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_newByAsciiName(
+ typelib_TypeDescriptionReference ** ppTDR,
+ typelib_TypeClass eTypeClass,
+ const sal_Char * pTypeName );
+
+/** Increments reference count of type description reference.
+ <br>
+ @param pRef type description reference
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_acquire(
+ typelib_TypeDescriptionReference * pRef );
+
+/** Increments reference count of type description reference.
+ If the reference count reaches 0, the reference is deleted.
+ <br>
+ @param pRef type description reference
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_release(
+ typelib_TypeDescriptionReference * pRef );
+
+/** Retrieves the type description for a given reference.<br>
+ If it is not possible to resolve the reference, null is returned.
+ <br>
+ @param ppRet inout type description
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_getDescription(
+ typelib_TypeDescription ** ppRet, typelib_TypeDescriptionReference * pRef );
+
+/** Tests whether two types description references are equal, i.e. type class and names are equal.
+ <br>
+ @param p1 a type description reference
+ @param p2 another type description reference
+ @return true, if type description references are equal
+*/
+SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescriptionreference_equals(
+ const typelib_TypeDescriptionReference * p1, const typelib_TypeDescriptionReference * p2 );
+
+/** Assigns a type.
+ <br>
+ @param ppDest destination type
+ @param pSource source type
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_assign(
+ typelib_TypeDescriptionReference ** ppDest,
+ typelib_TypeDescriptionReference * pSource );
+
+/** Tests if values of type pAssignable can be assigned by values of type pFrom.
+ This includes widening conversion (e.g., long assignable from short), as long
+ as there is <b>no</b> data loss.
+ <br>
+ @param pAssignable type description of value to be assigned
+ @param pFrom type description of value
+*/
+SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescription_isAssignableFrom(
+ typelib_TypeDescription * pAssignable,
+ typelib_TypeDescription * pFrom );
+
+/** Tests if values of type pAssignable can be assigned by values of type pFrom.
+ This includes widening conversion (e.g., long assignable from short), as long
+ as there is <b>no</b> data loss.
+ <br>
+ @param pAssignable type of value to be assigned
+ @param pFrom type of value
+*/
+SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescriptionreference_isAssignableFrom(
+ typelib_TypeDescriptionReference * pAssignable,
+ typelib_TypeDescriptionReference * pFrom );
+
+/** Gets static type reference of standard types by type class.
+ ==OPTIMIZATION HACK==:
+ provides Type com.sun.star.uno.Exception for typelib_TypeClass_EXCEPTION
+ and com.sun.star.uno.XInterface for typelib_TypeClass_INTERFACE.
+ <br>
+ Thread synchronizes on typelib mutex.
+ <br>
+ @param eTypeClass type class of basic type
+ @return pointer to type reference pointer
+*/
+SAL_DLLEXPORT typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass(
+ typelib_TypeClass eTypeClass );
+
+/** Inits static type reference.
+ Thread synchronizes on typelib init mutex.
+ <br>
+ @param ppRef pointer to type reference pointer
+ @param eTypeClass type class of type
+ @param pTypeName ascii name of type
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_static_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeClass eTypeClass, const sal_Char * pTypeName );
+
+/** Inits static sequence type reference.
+ Thread synchronizes on typelib init mutex.
+ <br>
+ @param ppRef pointer to type reference pointer
+ @param pElementType element type of sequence
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_static_sequence_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeDescriptionReference * pElementType );
+
+/** Inits <b>in</b>complete static compound type reference.
+ Thread synchronizes on typelib init mutex.
+ <br>
+ @param ppRef pointer to type reference pointer
+ @param eTypeClass typelib_TypeClass_STRUCT or typelib_TypeClass_EXCEPTION
+ @param pTypeName name of type
+ @param pBaseType base type
+ @param nMembers number of members
+ @param ppMembers member types
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_static_compound_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeClass eTypeClass, const sal_Char * pTypeName,
+ typelib_TypeDescriptionReference * pBaseType,
+ sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers );
+
+/** Inits <b>in</b>complete static interface type reference.
+ Thread synchronizes on typelib init mutex.
+ <br>
+ @param ppRef pointer to type reference pointer
+ @param pTypeName name of interface
+ @param pBaseType base type
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_static_interface_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ const sal_Char * pTypeName,
+ typelib_TypeDescriptionReference * pBaseType );
+
+/** Inits <b>in</b>complete static enum type reference.
+ Thread synchronizes on typelib init mutex.
+ <br>
+ @param ppRef pointer to type reference pointer
+ @param pTypeName name of enum
+ @param nDefaultEnumValue default enum value
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_static_enum_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ const sal_Char * pTypeName,
+ sal_Int32 nDefaultValue );
+
+/** Inits <b>in</b>complete static compound type reference.
+ Thread synchronizes on typelib init mutex.
+ All discriminants are handled as int64 values.
+ The pDiscriminantTypeRef must be of type byte, short, ..., up to hyper.
+ <br>
+ @param ppRef pointer to type reference pointer
+ @param pTypeName name of union type
+ @param pDiscriminantType discriminant type
+ @param nDefaultDiscriminant default discriminant
+ @param pDefaultType default value type of union
+ @param nMembers number of union members
+ @param pDiscriminants member discriminants
+ @param pMemberTypes member types
+*/
+SAL_DLLEXPORT void SAL_CALL typelib_static_union_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ const sal_Char * pTypeName,
+ typelib_TypeDescriptionReference * pDiscriminantType,
+ sal_Int64 nDefaultDiscriminant,
+ typelib_TypeDescriptionReference * pDefaultType,
+ sal_Int32 nMembers,
+ sal_Int64 * pDiscriminants,
+ typelib_TypeDescriptionReference ** pMemberTypes );
+
+/** Completes a typedescription to be used for, e.g., marshalling values.
+ COMPOUND, UNION, INTERFACE and ENUM type descriptions may be partly
+ initialized (see typelib_static_...(), typelib_TypeDescription::bComplete).
+ For interface type descriptions, this will also init index tables.
+ <br>
+ @param ppTypeDescr [inout] type description to be completed (may be exchanged!)
+ @return true, if type description is complete
+*/
+SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescription_complete(
+ typelib_TypeDescription ** ppTypeDescr );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cppu/inc/typelib/typedescription.hxx b/cppu/inc/typelib/typedescription.hxx
new file mode 100644
index 000000000000..305e54b59acc
--- /dev/null
+++ b/cppu/inc/typelib/typedescription.hxx
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * $RCSfile: typedescription.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
+#define _TYPELIB_TYPEDESCRIPTION_HXX_
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+#ifndef _COM_SUN_STAR_UNO_TYPE_H_
+#include <com/sun/star/uno/Type.h>
+#endif
+#ifndef _TYPELIB_TYPEDESCRIPTION_H
+#include <typelib/typedescription.h>
+#endif
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+/** C++ wrapper for typelib_TypeDescription.
+ Constructors by name, type, type description reference will get
+ the full type description.
+ <br>
+*/
+class TypeDescription
+{
+ /** C typelib type description<br>
+ */
+ mutable typelib_TypeDescription * _pTypeDescr;
+
+public:
+ /** Constructor:
+ <br>
+ @param pTypeDescr a type description
+ */
+ inline TypeDescription( typelib_TypeDescription * pTypeDescr = 0 );
+ /** Constructor:
+ <br>
+ @param pTypeDescrRef a type description reference
+ */
+ inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef );
+ /** Constructor:
+ <br>
+ @param rType a type
+ */
+ inline TypeDescription( const ::com::sun::star::uno::Type & rType );
+ /** Copy constructor:
+ <br>
+ @param rDescr another TypeDescription
+ */
+ inline TypeDescription( const TypeDescription & rDescr );
+ /** Constructor:
+ <br>
+ @param pTypeName a type name
+ */
+ inline TypeDescription( rtl_uString * pTypeName );
+ /** Constructor:
+ <br>
+ @param rTypeName a type name
+ */
+ inline TypeDescription( const ::rtl::OUString & rTypeName );
+ /** Destructor:
+ <br>
+ releases type description
+ */
+ inline ~TypeDescription();
+
+ /** Assignment operator:
+ acquires given type description and releases a set one.
+ <br>
+ @param pTypeDescr another type description
+ @return this TypeDescription
+ */
+ inline TypeDescription & operator = ( typelib_TypeDescription * pTypeDescr );
+ /** Assignment operator:
+ acquires given type description and releases a set one.
+ <br>
+ @param rTypeDescr another type description
+ @return this TypeDescription
+ */
+ inline TypeDescription & operator =( const TypeDescription & rTypeDescr )
+ { return this->operator =( rTypeDescr.get() ); }
+
+ /** Tests if two type descriptions are equal.
+ <br>
+ @param pTypeDescr another type description
+ @return true, if both type descriptions are equal, false otherwise
+ */
+ inline sal_Bool equals( const typelib_TypeDescription * pTypeDescr ) const;
+ /** Tests if two type descriptions are equal.
+ <br>
+ @param rTypeDescr another type description
+ @return true, if both type descriptions are equal, false otherwise
+ */
+ inline sal_Bool equals( const TypeDescription & rTypeDescr ) const
+ { return equals( rTypeDescr._pTypeDescr ); }
+
+ /** Makes stored type description complete.
+ <br>
+ */
+ inline void makeComplete() const;
+
+ /** Gets the <b>un</b>acquired type description pointer.
+ <br>
+ @return stored pointer of type description
+ */
+ inline typelib_TypeDescription * get() const
+ { return _pTypeDescr; }
+ /** Tests if a type description is set.
+ <br>
+ @return true, if a type description is set, false otherwise
+ */
+ inline sal_Bool is() const
+ { return (_pTypeDescr != 0); }
+};
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr )
+ : _pTypeDescr( pTypeDescr )
+{
+ if (_pTypeDescr)
+ typelib_typedescription_acquire( _pTypeDescr );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef )
+ : _pTypeDescr( 0 )
+{
+ if (pTypeDescrRef)
+ typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type & rType )
+ : _pTypeDescr( 0 )
+{
+ if (rType.getTypeLibType())
+ typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr )
+ : _pTypeDescr( rTypeDescr._pTypeDescr )
+{
+ if (_pTypeDescr)
+ typelib_typedescription_acquire( _pTypeDescr );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( rtl_uString * pTypeName )
+ : _pTypeDescr( 0 )
+{
+ typelib_typedescription_getByName( &_pTypeDescr , pTypeName );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName )
+ : _pTypeDescr( 0 )
+{
+ typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription::~TypeDescription()
+{
+ if (_pTypeDescr)
+ typelib_typedescription_release( _pTypeDescr );
+}
+//__________________________________________________________________________________________________
+inline TypeDescription & TypeDescription::operator =( typelib_TypeDescription * pTypeDescr )
+{
+ if (_pTypeDescr)
+ typelib_typedescription_release( _pTypeDescr );
+ if (_pTypeDescr = pTypeDescr)
+ typelib_typedescription_acquire( _pTypeDescr );
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const
+{
+ return (_pTypeDescr && pTypeDescr &&
+ typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
+}
+//__________________________________________________________________________________________________
+inline void TypeDescription::makeComplete() const
+{
+ if (_pTypeDescr && !_pTypeDescr->bComplete)
+ ::typelib_typedescription_complete( &_pTypeDescr );
+}
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/typelib/uik.h b/cppu/inc/typelib/uik.h
new file mode 100644
index 000000000000..7012817625f9
--- /dev/null
+++ b/cppu/inc/typelib/uik.h
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * $RCSfile: uik.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _TYPELIB_UIK_H_
+#define _TYPELIB_UIK_H_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#elif defined(SAL_OS2)
+# pragma pack(8)
+#endif
+
+/** Binary typelib uik struct.
+ <br>
+*/
+struct typelib_Uik
+{
+ sal_uInt32 m_Data1;
+ sal_uInt16 m_Data2;
+ sal_uInt16 m_Data3;
+ sal_uInt32 m_Data4;
+ sal_uInt32 m_Data5;
+};
+
+#ifdef SAL_W32
+# pragma pack(pop)
+#elif defined(SAL_OS2)
+# pragma pack()
+#endif
+
+#endif
diff --git a/cppu/inc/uno/any2.h b/cppu/inc/uno/any2.h
new file mode 100644
index 000000000000..2cab2d06a446
--- /dev/null
+++ b/cppu/inc/uno/any2.h
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * $RCSfile: any2.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _UNO_ANY2_H_
+#define _UNO_ANY2_H_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SAL_W32
+#pragma pack(push, 8)
+#elif defined(SAL_OS2)
+#pragma pack(8)
+#endif
+
+typedef struct _typelib_TypeDescription typelib_TypeDescription;
+
+/** This is the binary specification of an UNO any.
+ <br>
+*/
+typedef struct _uno_Any
+{
+ /** type of value<br>
+ */
+ typelib_TypeDescriptionReference * pType;
+ /** pointer to value<br>
+ */
+ void * pData;
+} uno_Any;
+
+#ifdef SAL_W32
+#pragma pack(pop)
+#elif defined(SAL_OS2)
+#pragma pack()
+#endif
+
+/** Constructs an any with a given value.
+ Interfaces are acquired by the given callback function.
+ <br>
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pTypeDescr type description of value; defaults (0) to void
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_any_construct(
+ uno_Any * pDest, void * pSource,
+ typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire );
+/** Constructs an any with a given value.
+ Interfaces are acquired by the given callback function.
+ <br>
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pType type of value; defaults (0) to void
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_any_construct(
+ uno_Any * pDest, void * pSource,
+ typelib_TypeDescriptionReference * pType,
+ uno_AcquireFunc acquire );
+
+/** Constructs an any with a given value and converts/ maps interfaces.
+ <br>
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pTypeDescr type description of value; defaults (0) to void
+ @param mapping mapping to convert/ map interfaces
+*/
+SAL_DLLEXPORT void SAL_CALL uno_any_constructAndConvert(
+ uno_Any * pDest, void * pSource,
+ typelib_TypeDescription * pTypeDescr,
+ uno_Mapping * mapping );
+/** Constructs an any with a given value and converts/ maps interfaces.
+ <br>
+ @param pDest pointer memory of destination any
+ @param pSource pointer to source value; defaults (0) to default constructed value
+ @param pType type of value; defaults (0) to void
+ @param mapping mapping to convert/ map interfaces
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_any_constructAndConvert(
+ uno_Any * pDest, void * pSource,
+ typelib_TypeDescriptionReference * pType,
+ uno_Mapping * mapping );
+
+/** Destructs an any.
+ <br>
+ @param pValue pointer to any
+ @param release function called each time an interface needs to be released. defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_any_destruct(
+ uno_Any * pValue, uno_ReleaseFunc release );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cppu/inc/uno/data.h b/cppu/inc/uno/data.h
new file mode 100644
index 000000000000..83fd327fa9a1
--- /dev/null
+++ b/cppu/inc/uno/data.h
@@ -0,0 +1,245 @@
+/*************************************************************************
+ *
+ * $RCSfile: data.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _UNO_DATA_H_
+#define _UNO_DATA_H_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct _uno_Mapping uno_Mapping;
+typedef struct _typelib_TypeDescription typelib_TypeDescription;
+typedef struct _typelib_TypeDescriptionReference typelib_TypeDescriptionReference;
+typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription;
+
+/** Generic function pointer declaration to query for an interface.
+ <br>
+ @param pInterface interface
+ @param pTypedemanded interface type
+ @return interface pointer
+*/
+typedef void * (SAL_CALL * uno_QueryInterfaceFunc)(
+ void * pInterface, typelib_TypeDescriptionReference * pType );
+/** Generic function pointer declaration to acquire an interface.
+ <br>
+ @param pInterface interface to be acquired
+*/
+typedef void (SAL_CALL * uno_AcquireFunc)( void * pInterface );
+/** Generic function pointer declaration to release an interface.
+ <br>
+ @param pInterface interface to be release
+*/
+typedef void (SAL_CALL * uno_ReleaseFunc)( void * pInterface );
+
+/** Tests if two values are equal. May compare different types (e.g., short to long).
+ <br>
+ @param pVal1 pointer to a value
+ @param pVal1TypeDescr type description of pVal1
+ @param pVal2 pointer to another value
+ @param pVal2TypeDescr type description of pVal2
+ @param queryInterface function called each time two interfaces are tested whether they belong
+ to the same object; defaults (0) to uno
+ @param release function to release queried interfaces; defaults (0) to uno
+ @return true if values are equal
+*/
+SAL_DLLEXPORT sal_Bool SAL_CALL uno_equalData(
+ void * pVal1, typelib_TypeDescription * pVal1TypeDescr,
+ void * pVal2, typelib_TypeDescription * pVal2TypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release );
+/** Tests if two values are equal. May compare different types (e.g., short to long).
+ <br>
+ @param pVal1 pointer to a value
+ @param pVal1Type type of pVal1
+ @param pVal2 pointer to another value
+ @param pVal2Type type of pVal2
+ @param queryInterface function called each time two interfaces are tested whether they belong
+ to the same object; defaults (0) to uno
+ @param release function to release queried interfaces; defaults (0) to uno
+ @return true if values are equal
+*/
+SAL_DLLEXPORT sal_Bool SAL_CALL uno_type_equalData(
+ void * pVal1, typelib_TypeDescriptionReference * pVal1Type,
+ void * pVal2, typelib_TypeDescriptionReference * pVal2Type,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release );
+
+/** Copy construct memory with given value.
+ The size of the destination value must be larger or equal to the size of the source value.
+ <br>
+ @param pDest pointer to destination value memory
+ @param pSource pointer to source value
+ @param pTypeDescr type description of source
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_copyData(
+ void * pDest, void * pSource, typelib_TypeDescription * pTypeDescr, uno_AcquireFunc acquire );
+/** Copy construct memory with given value.
+ The size of the destination value must be larger or equal to the size of the source value.
+ <br>
+ @param pDest pointer to destination value memory
+ @param pSource pointer to source value
+ @param pType type of source
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_copyData(
+ void * pDest, void * pSource, typelib_TypeDescriptionReference * pType, uno_AcquireFunc acquire );
+
+/** Copy construct memory with given value.
+ The size of the destination value must be larger or equal to the size of the source value.<br>
+ Interfaces are converted/ mapped by mapping parameter.
+ <br>
+ @param pDest pointer to destination value memory
+ @param pSource pointer to source value
+ @param pTypeDescr type description of source
+ @param mapping mapping to convert/ map interfaces
+*/
+SAL_DLLEXPORT void SAL_CALL uno_copyAndConvertData(
+ void * pDest, void * pSource, typelib_TypeDescription * pTypeDescr, uno_Mapping * mapping );
+/** Copy construct memory with given value.
+ The size of the destination value must be larger or equal to the size of the source value.<br>
+ Interfaces are converted/ mapped by mapping parameter.
+ <br>
+ @param pDest pointer to destination value memory
+ @param pSource pointer to source value
+ @param pType type of source
+ @param mapping mapping to convert/ map interfaces
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_copyAndConvertData(
+ void * pDest, void * pSource, typelib_TypeDescriptionReference * pType, uno_Mapping * mapping );
+
+/** Destructs a given value; does <b>not</b> free its memory!
+ <br>
+ @param pValue value to be destructed
+ @param pTypeDescr type description of value
+ @param release function called each time an interface pointer needs to be released; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_destructData(
+ void * pValue, typelib_TypeDescription * pTypeDescr, uno_ReleaseFunc release );
+/** Destructs a given value; does <b>not</b> free its memory!
+ <br>
+ @param pValue value to be destructed
+ @param pType type of value
+ @param release function called each time an interface pointer needs to be released; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_destructData(
+ void * pValue, typelib_TypeDescriptionReference * pType, uno_ReleaseFunc release );
+
+/** Default constructs a value. All simple types are set to 0, enums are set to their default
+ value.
+ <br>
+ @param pMem pointer to memory of value to be constructed
+ @param pTypeDescr type description of value to be constructed
+*/
+SAL_DLLEXPORT void SAL_CALL uno_constructData(
+ void * pMem, typelib_TypeDescription * pTypeDescr );
+/** Default constructs a value. All simple types are set to 0, enums are set to their default
+ value.
+ <br>
+ @param pMem pointer to memory of value to be constructed
+ @param pType type of value to be constructed
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_constructData(
+ void * pMem, typelib_TypeDescriptionReference * pType );
+
+/** Assigns a destination value with a source value. Widening conversion
+ <b>without</b> data loss is allowed (e.g., assigning a long with a short).
+ Assignment from any value to a value of type Any and vice versa is allowed.
+ <br>
+ @param pDest pointer to destination value
+ @param pDestTypeDescr type description of destination value
+ @param pSource pointer to source value; if 0, then destination value will be assigned to default value
+ @param pSourceTypeDescr type destination of source value
+ @param queryInterface function called each time an interface needs to be queried; defaults (0) to uno
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to be released; defaults (0) to uno
+ @return true if destination has been successfully assigned
+*/
+SAL_DLLEXPORT sal_Bool SAL_CALL uno_assignData(
+ void * pDest, typelib_TypeDescription * pDestTypeDescr,
+ void * pSource, typelib_TypeDescription * pSourceTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release );
+/** Assigns a destination value with a source value. Widening conversion
+ <b>without</b> data loss is allowed (e.g., assigning a long with a short).
+ Assignment from any value to a value of type Any and vice versa is allowed.
+ <br>
+ @param pDest pointer to destination value
+ @param pDestType type of destination value
+ @param pSource pointer to source value; if 0, then destination value will be assigned to default value
+ @param pSourceType type of source value
+ @param queryInterface function called each time an interface needs to be queried; defaults (0) to uno
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to be released; defaults (0) to uno
+ @return true if destination has been successfully assigned
+*/
+SAL_DLLEXPORT sal_Bool SAL_CALL uno_type_assignData(
+ void * pDest, typelib_TypeDescriptionReference * pDestType,
+ void * pSource, typelib_TypeDescriptionReference * pSourceType,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cppu/inc/uno/dispatcher.h b/cppu/inc/uno/dispatcher.h
new file mode 100644
index 000000000000..bfdf1ad4bfb7
--- /dev/null
+++ b/cppu/inc/uno/dispatcher.h
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * $RCSfile: dispatcher.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _UNO_DISPATCHER_H_
+#define _UNO_DISPATCHER_H_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _RTL_USTRING_H_
+#include <rtl/ustring.h>
+#endif
+
+#ifndef _UNO_ANY2_H_
+#include <uno/any2.h>
+#endif
+
+typedef struct _typelib_TypeDescription typelib_TypeDescription;
+typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription;
+typedef struct _uno_Interface uno_Interface;
+
+/** Function pointer declaration for the binary C uno dispatch function.<br>
+ Any pure out or return value will be constructed by the callee, iff
+ no exception is signalled.<br>
+ If an exception is signalled, the any *ppException is properly constructed
+ by the callee, otherwise the pointer *ppException is set to 0.<br>
+ An attribute <b>get</b> call is indicated by a non-null return pointer.
+ <br>
+ @param pUnoI uno interface the call is performed on
+ @param pMemberType member type description of a method or attribute
+ @param pReturn pointer to return value memory;
+ pointer may be undefined if void method, null if attribute set call.
+ @param pArgs an array of pointers to arguments values.
+ (remark: the value of an interface reference stores a
+ uno_interface *, so you get it by *(uno_Interface **)pArgs[n])
+ @param ppException pointer to pointer to unconstructed any to signal an exception.
+*/
+typedef void (SAL_CALL * uno_DispatchMethod)(
+ uno_Interface * pUnoI,
+ const typelib_TypeDescription * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException );
+
+#ifdef SAL_W32
+#pragma pack(push, 8)
+#elif defined(SAL_OS2)
+#pragma pack(8)
+#endif
+
+/** The binary C uno interface description.
+ <br>
+*/
+typedef struct _uno_Interface
+{
+ /** Acquires uno interface.
+ <br>
+ @param pInterface uno interface
+ */
+ void (SAL_CALL * acquire)( uno_Interface * pInterface );
+ /** Releases uno interface.
+ <br>
+ @param pInterface uno interface
+ */
+ void (SAL_CALL * release)( uno_Interface * pInterface );
+ /** dispatch function<br>
+ */
+ uno_DispatchMethod pDispatcher;
+} uno_Interface;
+
+#ifdef SAL_W32
+#pragma pack(pop)
+#elif defined(SAL_OS2)
+#pragma pack()
+#endif
+
+#endif
diff --git a/cppu/inc/uno/environment.h b/cppu/inc/uno/environment.h
new file mode 100644
index 000000000000..552b1bb919b9
--- /dev/null
+++ b/cppu/inc/uno/environment.h
@@ -0,0 +1,344 @@
+/*************************************************************************
+ *
+ * $RCSfile: environment.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _UNO_ENVIRONMENT_H_
+#define _UNO_ENVIRONMENT_H_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _RTL_USTRING_H_
+#include <rtl/ustring.h>
+#endif
+
+typedef struct _uno_Environment uno_Environment;
+typedef struct _uno_ExtEnvironment uno_ExtEnvironment;
+typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription;
+
+#ifdef SAL_W32
+#pragma pack(push, 8)
+#elif defined(SAL_OS2)
+#pragma pack(8)
+#endif
+
+/** The binary specification of an UNO environment.
+ <br>
+*/
+typedef struct _uno_Environment
+{
+ /** reserved for future use (0 if not used)<br>
+ */
+ void * pReserved;
+
+ /** type name of environment<br>
+ */
+ rtl_uString * pTypeName;
+
+ /** free context pointer to be used for specific classes of environments
+ (e.g., a jvm pointer)<br>
+ */
+ void * pContext;
+
+ /** pointer to extended environment (interface registration functionality), if supported<br>
+ */
+ uno_ExtEnvironment * pExtEnv;
+
+ /** Acquires this environment.
+ <br>
+ @param pEnv this environment
+ */
+ void (SAL_CALL * acquire)( uno_Environment * pEnv );
+
+ /** Releases this environment;
+ last release of environment will revoke the environment from runtime.
+ <br>
+ @param pEnv this environment
+ */
+ void (SAL_CALL * release)( uno_Environment * pEnv );
+
+ /** Call this function to <b>explicitly</b> dispose this environment
+ (e.g., release all interfaces).<br>
+ You might want to call this function before shutting down due to a runtime error.
+ <br>
+ @param pEnv this environment
+ */
+ void (SAL_CALL * dispose)( uno_Environment * pEnv );
+
+ /* ===== the following part will be late initialized by a matching bridge ===== *
+ * ===== and is NOT for public use. ===== */
+
+ /** <b>CALLBACK</b><br>
+ Disposing callback function pointer that can be set to get signalled before the environment
+ is destroyed.
+ <br>
+ @param pEnv environment that is being disposed
+ */
+ void (SAL_CALL * environmentDisposing)( uno_Environment * pEnv );
+} uno_Environment;
+
+/** Generic function pointer declaration to free a proxy object if it is not needed
+ by the environment anymore.<br>
+ Any proxy object must register itself on first acquire() call and revoke
+ itself on last release() call.
+ This can happen several times because the environment caches proxy objects
+ until the environment <b>explicitly</b> frees the proxy object calling this function.
+ <br>
+ @param pEnv environment
+ @param pProxy proxy pointer
+*/
+typedef void (SAL_CALL * uno_freeProxyFunc)( uno_ExtEnvironment * pEnv, void * pProxy );
+
+/** Generic function pointer declaration to allocate memory. Used with getRegisteredInterfaces().
+ <br>
+ @param nBytes amount of memory in bytes
+ @return pointer to allocated memory
+*/
+typedef void * (SAL_CALL * uno_memAlloc)( sal_uInt32 nBytes );
+
+/** The binary specification of an UNO environment supporting interface registration.
+ <br>
+*/
+typedef struct _uno_ExtEnvironment
+{
+ /** inherits all members of an uno_Environment<br>
+ */
+ uno_Environment aBase;
+
+ /** Registers an interface of this environment.
+ <br>
+ @param pEnv this environment
+ @param ppInterface inout parameter of interface to be registered
+ @param pOId object id of interface
+ @param pTypeDescr type description of interface
+ */
+ void (SAL_CALL * registerInterface)(
+ uno_ExtEnvironment * pEnv,
+ void ** ppInterface,
+ rtl_uString * pOId,
+ typelib_InterfaceTypeDescription * pTypeDescr );
+
+ /** Registers a proxy interface of this environment that can be reanimated and is
+ freed <b>explicitly</b> by this environment.
+ <br>
+ @param pEnv this environment
+ @param ppInterface inout parameter of interface to be registered
+ @param freeProxy function to free proxy object
+ @param pOId object id of interface
+ @param pTypeDescr type description of interface
+ */
+ void (SAL_CALL * registerProxyInterface)(
+ uno_ExtEnvironment * pEnv,
+ void ** ppProxy,
+ uno_freeProxyFunc freeProxy,
+ rtl_uString * pOId,
+ typelib_InterfaceTypeDescription * pTypeDescr );
+
+ /** Revokes an interface from this environment.<br>
+ You have to revoke <b>any</b> interface that has been registered via this method.
+ <br>
+ @param pEnv this environment
+ @param pInterface interface to be revoked
+ */
+ void (SAL_CALL * revokeInterface)(
+ uno_ExtEnvironment * pEnv,
+ void * pInterface );
+
+ /** Provides the object id of a given interface.
+ <br>
+ @param ppOut inout oid
+ @param pInterface interface of object
+ */
+ void (SAL_CALL * getObjectIdentifier)(
+ uno_ExtEnvironment * pEnv,
+ rtl_uString ** ppOId,
+ void * pInterface );
+
+ /** Retrieves an interface identified by its object id and type from this environment.
+ Interfaces are retrieved in the same order as they are registered.
+ <br>
+ @param pEnv this environment
+ @param ppInterface inout parameter for the registered interface; (0) if none was found
+ @param pOId object id of interface to be retrieved
+ @param pTypeDescr type description of interface to be retrieved
+ */
+ void (SAL_CALL * getRegisteredInterface)(
+ uno_ExtEnvironment * pEnv,
+ void ** ppInterface,
+ rtl_uString * pOId,
+ typelib_InterfaceTypeDescription * pTypeDescr );
+
+ /** Returns all currently registered interfaces of this environment.
+ The memory block allocated might be slightly larger than (*pnLen * sizeof(void *)).
+ <br>
+ @param pEnv this environment
+ @param pppInterfaces out param; pointer to array of interface pointers
+ @param pnLen out param; length of array
+ @param memAlloc function for allocating memory that is passed back
+ */
+ void (SAL_CALL * getRegisteredInterfaces)(
+ uno_ExtEnvironment * pEnv,
+ void *** pppInterfaces,
+ sal_Int32 * pnLen,
+ uno_memAlloc memAlloc );
+
+
+ /* ===== the following part will be late initialized by a matching bridge ===== *
+ * ===== and is NOT for public use. ===== */
+
+ /** Computes an object id of the given interface; is called by the environment
+ implementation.
+ <br>
+ @param pEnv corresponding environment
+ @param ppOId out param: computed id
+ @param pInterface an interface
+ */
+ void (SAL_CALL * computeObjectIdentifier)(
+ uno_ExtEnvironment * pEnv,
+ rtl_uString ** ppOId, void * pInterface );
+
+ /** Function to acquire an interface.
+ <br>
+ @param pEnv corresponding environment
+ @param pInterface an interface
+ */
+ void (SAL_CALL * acquireInterface)( uno_ExtEnvironment * pEnv, void * pInterface );
+
+ /** Function to release an interface.
+ <br>
+ @param pEnv corresponding environment
+ @param pInterface an interface
+ */
+ void (SAL_CALL * releaseInterface)( uno_ExtEnvironment * pEnv, void * pInterface );
+} uno_ExtEnvironment;
+
+#ifdef SAL_W32
+#pragma pack(pop)
+#elif defined(SAL_OS2)
+#pragma pack()
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** Function exported by some bridge library providing
+ acquireInterface(), releaseInterface(); may set a disposing callback.
+ <br>
+ @param pEnv environment to be initialized
+*/
+typedef void (SAL_CALL * uno_initEnvironmentFunc)( uno_Environment * pEnv );
+#define UNO_INIT_ENVIRONMENT "uno_initEnvironment"
+
+/** Gets a specific environment. If the specified environment does
+ not exist, then a default one is created and registered.
+ The environment revokes itself on last release() call.
+ <br>
+ @param ppEnv inout parameter of environment; given environment will be released
+ @param pEnvTypeName type name of environment
+ @param pContext some context pointer (e.g., to distinguish java vm; set 0 if not needed)
+*/
+SAL_DLLEXPORT void SAL_CALL uno_getEnvironment(
+ uno_Environment ** ppEnv, rtl_uString * pEnvTypeName, void * pContext );
+
+/** Gets all specified environments. Caller has to release returned environments and
+ free allocated memory.
+ <br>
+ @param pppEnvs out param; pointer to array of environments
+ @param pnLen out param; length of array
+ @param memAlloc function for allocating memory that is passed back
+ @param pEnvTypeName type name of environments; 0 defaults to all
+*/
+SAL_DLLEXPORT void SAL_CALL uno_getRegisteredEnvironments(
+ uno_Environment *** pppEnvs, sal_Int32 * pnLen, uno_memAlloc memAlloc,
+ rtl_uString * pEnvTypeName );
+
+/** Creates an environment. The new environment is anonymous
+ (<b>NOT</b> publicly registered/ accessible).
+ <br>
+ @param ppEnv out parameter of environment; given environment will be released
+ @param pEnvTypeName name of environment
+ @param pContext context pointer (e.g., to distinguish java vm); set 0 if not needed
+*/
+SAL_DLLEXPORT void SAL_CALL uno_createEnvironment(
+ uno_Environment ** ppEnv, rtl_uString * pEnvTypeName, void * pContext );
+
+/** Dumps out environment information, i.e. registered interfaces.
+ <br>
+ @param stream output stream (FILE *)
+ @param pEnv environment to be dumped
+ @param pFilter if not null, filters output
+*/
+SAL_DLLEXPORT void SAL_CALL uno_dumpEnvironment(
+ void * stream, uno_Environment * pEnv, const sal_Char * pFilter );
+/** Dumps out environment information, i.e. registered interfaces.
+ <br>
+ @param stream output stream (FILE *)
+ @param pEnvTypeName type name of environment to be dumped
+ @param pFilter if not null, filters output
+*/
+SAL_DLLEXPORT void SAL_CALL uno_dumpEnvironmentByName(
+ void * stream, rtl_uString * pEnvTypeName, const sal_Char * pFilter );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cppu/inc/uno/environment.hxx b/cppu/inc/uno/environment.hxx
new file mode 100644
index 000000000000..f8aa6ae3f6d7
--- /dev/null
+++ b/cppu/inc/uno/environment.hxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * $RCSfile: environment.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _UNO_ENVIRONMENT_HXX_
+#define _UNO_ENVIRONMENT_HXX_
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _UNO_ENVIRONMENT_H_
+#include <uno/environment.h>
+#endif
+
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+/** C++ wrapper for binary C uno_Environment.
+ <br>
+*/
+class Environment
+{
+ /** binary C uno_Environment<br>
+ */
+ uno_Environment * _pEnv;
+
+public:
+ /** Constructor: acquires given environment
+ <br>
+ @param pEnv environment
+ */
+ inline Environment( uno_Environment * pEnv = 0 );
+
+ /** Copy constructor: acquires given environment
+ <br>
+ @param rEnv another environment
+ */
+ inline Environment( const Environment & rEnv );
+
+ /** Destructor:
+ <br>
+ Releases a set environment.
+ */
+ inline ~Environment();
+
+ /** Sets a given environment, i.e. acquires given one and releases a set one.
+ <br>
+ @param pEnv another environment
+ @return this environment
+ */
+ inline Environment & SAL_CALL operator = ( uno_Environment * pEnv );
+ /** Sets a given environment, i.e. acquires given one and releases a set one.
+ <br>
+ @param rEnv another environment
+ @return this environment
+ */
+ inline Environment & SAL_CALL operator = ( const Environment & rEnv )
+ { return operator = ( rEnv._pEnv ); }
+
+ /** Provides <b>un</b>acquired pointer to the set C environment.
+ <br>
+ @return <b>un</b>acquired pointer to the C environment struct
+ */
+ inline uno_Environment * SAL_CALL get() const
+ { return _pEnv; }
+
+ /** Gets type name of set environment.
+ <br>
+ @return type name of set environment
+ */
+ inline ::rtl::OUString SAL_CALL getTypeName() const
+ { return _pEnv->pTypeName; }
+
+ /** Gets free context pointer of set environment.
+ <br>
+ @return free context pointer of set environment
+ */
+ inline void * SAL_CALL getContext() const
+ { return _pEnv->pContext; }
+
+ /** Tests if a environment is set.
+ <br>
+ @return true, if a environment is set, false otherwise
+ */
+ inline sal_Bool SAL_CALL is() const
+ { return (_pEnv != 0); }
+
+ /** Releases a set environment.
+ <br>
+ */
+ inline void SAL_CALL clear();
+};
+//__________________________________________________________________________________________________
+inline Environment::Environment( uno_Environment * pEnv )
+ : _pEnv( pEnv )
+{
+ if (_pEnv)
+ (*_pEnv->acquire)( _pEnv );
+}
+//__________________________________________________________________________________________________
+inline Environment::Environment( const Environment & rEnv )
+ : _pEnv( rEnv._pEnv )
+{
+ if (_pEnv)
+ (*_pEnv->acquire)( _pEnv );
+}
+//__________________________________________________________________________________________________
+inline Environment::~Environment()
+{
+ if (_pEnv)
+ (*_pEnv->release)( _pEnv );
+}
+//__________________________________________________________________________________________________
+inline void Environment::clear()
+{
+ if (_pEnv)
+ {
+ (*_pEnv->release)( _pEnv );
+ _pEnv = 0;
+ }
+}
+//__________________________________________________________________________________________________
+inline Environment & Environment::operator = ( uno_Environment * pEnv )
+{
+ if (pEnv)
+ (*pEnv->acquire)( pEnv );
+ if (_pEnv)
+ (*_pEnv->release)( _pEnv );
+ _pEnv = pEnv;
+ return *this;
+}
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/uno/lbnames.h b/cppu/inc/uno/lbnames.h
new file mode 100644
index 000000000000..5ef7c0899c6d
--- /dev/null
+++ b/cppu/inc/uno/lbnames.h
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * $RCSfile: lbnames.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _UNO_LBNAMES_H_
+#define _UNO_LBNAMES_H_
+
+/** A java 1.1 compatible virtual machine<br>
+*/
+#define UNO_LB_JAVA_NAMESPACE java
+#define UNO_LB_JAVA "java"
+/** Miscrosoft VC++ 4.2 - 6.0 compiler; RTTI is not supported<br>
+*/
+#define UNO_LB_MSCI_NAMESPACE msci
+#define UNO_LB_MSCI "msci"
+/** GCC 2 with RTTI or compatible; RTTI is not supported<br>
+*/
+#define UNO_LB_GCC2_NAMESPACE gcc2
+#define UNO_LB_GCC2 "gcc2"
+/** WorkShop Compiler 5.0 or compatible; RTTI is not supported<br>
+*/
+#define UNO_LB_SUNPRO5_NAMESPACE sunpro5
+#define UNO_LB_SUNPRO5 "sunpro5"
+
+/** Binary C UNO<br>
+*/
+#define UNO_LB_UNO_NAMESPACE uno
+#define UNO_LB_UNO "uno"
+
+#endif
diff --git a/cppu/inc/uno/mapping.h b/cppu/inc/uno/mapping.h
new file mode 100644
index 000000000000..68937cfcdff6
--- /dev/null
+++ b/cppu/inc/uno/mapping.h
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * $RCSfile: mapping.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _UNO_MAPPING_H_
+#define _UNO_MAPPING_H_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _RTL_USTRING_H_
+#include <rtl/ustring.h>
+#endif
+
+typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription;
+typedef struct _uno_Mapping uno_Mapping;
+typedef struct _uno_Environment uno_Environment;
+
+/** Function pointer declaration to map an interface from one environment to another.
+ <br>
+ @param pMapping mapping
+ @param ppOut [inout] destination interface; existing interfaces are released
+ @param pInterface source interface
+ @param pInterfaceTypeDescr type description of the interface
+*/
+typedef void (SAL_CALL * uno_MapInterfaceFunc)(
+ uno_Mapping * pMapping,
+ void ** ppOut, void * pInterface,
+ typelib_InterfaceTypeDescription * pInterfaceTypeDescr );
+
+
+#ifdef SAL_W32
+#pragma pack(push, 8)
+#elif defined(SAL_OS2)
+#pragma pack(8)
+#endif
+
+/** This is the binary specification of a mapping.
+ <br>
+*/
+typedef struct _uno_Mapping
+{
+ /** Acquires mapping
+ <br>
+ @param pMapping mapping
+ */
+ void (SAL_CALL * acquire)( uno_Mapping * pMapping );
+ /** Releases mapping.
+ The last release may unload bridges.
+ <br>
+ @param pMapping mapping
+ */
+ void (SAL_CALL * release)( uno_Mapping * pMapping );
+
+ /** mapping function<br>
+ */
+ uno_MapInterfaceFunc mapInterface;
+} uno_Mapping;
+
+#ifdef SAL_W32
+#pragma pack(pop)
+#elif defined(SAL_OS2)
+#pragma pack()
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** Gets an interface mapping from one environment to another.
+ <br>
+ @param ppMapping [inout] mapping; existing mapping will be released
+ @param pFrom source environment
+ @param pTo destination environment
+ (interfaces resulting in mapInterface() call can be used
+ in this language environment)
+ @param pAddPurpose additional purpose of mapping (e.g., protocolling); defaults to 0 (none)
+*/
+SAL_DLLEXPORT void SAL_CALL uno_getMapping(
+ uno_Mapping ** ppMapping,
+ uno_Environment * pFrom,
+ uno_Environment * pTo,
+ rtl_uString * pAddPurpose );
+
+/** Callback function pointer declaration to get a mapping.
+ <br>
+ @param ppMapping inout mapping
+ @param pFrom source environment
+ @param pTo destination environment
+ @param pAddPurpose additional purpose
+*/
+typedef void (SAL_CALL * uno_getMappingFunc)(
+ uno_Mapping ** ppMapping,
+ uno_Environment * pFrom,
+ uno_Environment * pTo,
+ rtl_uString * pAddPurpose );
+
+/** Registers a callback being called each time a mapping is demanded.
+ <br>
+ @param pCallback callback function
+*/
+SAL_DLLEXPORT void SAL_CALL uno_registerMappingCallback(
+ uno_getMappingFunc pCallback );
+
+/** Revokes a mapping callback registration.
+ <br>
+ @param pCallback callback function
+*/
+SAL_DLLEXPORT void SAL_CALL uno_revokeMappingCallback(
+ uno_getMappingFunc pCallback );
+
+/** Function pointer declaration to free a mapping.
+ <br>
+ @param pMapping mapping to be freed
+*/
+typedef void (SAL_CALL * uno_freeMappingFunc)( uno_Mapping * pMapping );
+
+/** Registers a mapping.<br>
+ A mapping registers itself on first acquire and revokes itself on last release.
+ The given freeMapping function is called by the runtime to cleanup
+ any resources.
+ <br>
+ @param ppMapping inout mapping to be registered
+ @param freeMapping called by runtime to delete mapping
+ @param pFrom source environment
+ @param pTo destination environment
+ @param pAddPurpose additional purpose string; defaults to 0
+*/
+SAL_DLLEXPORT void SAL_CALL uno_registerMapping(
+ uno_Mapping ** ppMapping, uno_freeMappingFunc freeMapping,
+ uno_Environment * pFrom, uno_Environment * pTo, rtl_uString * pAddPurpose );
+
+/** Revokes a mapping.<br>
+ A mapping registers itself on first acquire and revokes itself on last release.
+ <br>
+ @param pMapping mapping to be revoked
+*/
+SAL_DLLEXPORT void SAL_CALL uno_revokeMapping(
+ uno_Mapping * pMapping );
+
+/** Gets an interface mapping from one language environment to another by
+ corresponding environment type names.
+ <br>
+ @param ppMapping [inout] mapping; existing mapping will be released
+ @param pFrom source environment type name
+ @param pTo destination environment type name
+ (interfaces resulting in mapInterface() call can be used
+ in this language environment)
+ @param pAddPurpose additional purpose of mapping (e.g., protocolling); defaults to 0 (none)
+*/
+SAL_DLLEXPORT void SAL_CALL uno_getMappingByName(
+ uno_Mapping ** ppMapping,
+ rtl_uString * pFrom,
+ rtl_uString * pTo,
+ rtl_uString * pAddPurpose );
+
+/* symbol exported by each language binding library */
+#define UNO_EXT_GETMAPPING "uno_ext_getMapping"
+
+/** Function pointer declaration to get a mapping from a loaded bridge.<br>
+ Bridges export a function called <b>uno_ext_getMapping</b> of this signature.
+ <br>
+ @param ppMapping [inout] mapping; existing mapping will be released
+ @pFrom source environment
+ @pTo destination environment
+*/
+typedef void (SAL_CALL * uno_ext_getMappingFunc)(
+ uno_Mapping ** ppMapping,
+ uno_Environment * pFrom,
+ uno_Environment * pTo );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cppu/inc/uno/mapping.hxx b/cppu/inc/uno/mapping.hxx
new file mode 100644
index 000000000000..1b784cbb595d
--- /dev/null
+++ b/cppu/inc/uno/mapping.hxx
@@ -0,0 +1,333 @@
+/*************************************************************************
+ *
+ * $RCSfile: mapping.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _UNO_MAPPING_HXX_
+#define _UNO_MAPPING_HXX_
+
+#ifndef _CPPU_MACROS_HXX_
+#include <cppu/macros.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _UNO_MAPPING_H_
+#include <uno/mapping.h>
+#endif
+#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
+#include <com/sun/star/uno/Type.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#include <com/sun/star/uno/Reference.hxx>
+#endif
+
+typedef struct _typelib_TypeDescription typelib_TypeDescription;
+typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription;
+typedef struct _uno_Interface uno_Interface;
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+/** C++ wrapper for C uno_Mapping.
+ <br>
+*/
+class Mapping
+{
+ uno_Mapping * _pMapping;
+
+public:
+ /** Holds a mapping from the specified source to the specified destination by
+ environment type names.
+ <br>
+ @param rFrom type name of source environment
+ @param rTo type name of destination environment
+ @param rAddPurpose additional purpose
+ */
+ inline Mapping( const ::rtl::OUString & rFrom, const ::rtl::OUString & rTo,
+ const ::rtl::OUString & rAddPurpose = ::rtl::OUString() );
+
+ /** Holds a mapping from the specified source to the specified destination.
+ <br>
+ @param pFrom source environment
+ @param pTo destination environment
+ @param rAddPurpose additional purpose
+ */
+ inline Mapping( uno_Environment * pFrom, uno_Environment * pTo,
+ const ::rtl::OUString & rAddPurpose = ::rtl::OUString() );
+
+ /** Constructor.
+ <br>
+ @param pMapping another mapping
+ */
+ inline Mapping( uno_Mapping * pMapping = 0 );
+
+ /** Copy constructor.
+ <br>
+ @param rMapping another mapping
+ */
+ inline Mapping( const Mapping & rMapping );
+
+ /** Destructor.
+ <br>
+ */
+ inline ~Mapping();
+
+ /** Sets a given mapping.
+ <br>
+ @param pMapping another mapping
+ @return this mapping
+ */
+ inline Mapping & SAL_CALL operator = ( uno_Mapping * pMapping );
+ /** Sets a given mapping.
+ <br>
+ @param rMapping another mapping
+ @return this mapping
+ */
+ inline Mapping & SAL_CALL operator = ( const Mapping & rMapping )
+ { return operator = ( rMapping._pMapping ); }
+
+ /** Provides a pointer to the C mapping. The returned mapping is <b>not</b> acquired!
+ <br>
+ @return <b>un</b>acquired C mapping
+ */
+ inline uno_Mapping * SAL_CALL get() const
+ { return _pMapping; }
+
+ /** Tests if a mapping is set.
+ <br>
+ @return true if a mapping is set
+ */
+ inline sal_Bool SAL_CALL is() const
+ { return (_pMapping != 0); }
+
+ /** Releases a set mapping.
+ <br>
+ */
+ inline void SAL_CALL clear();
+
+ /** Maps an interface from one environment to another.
+ <br>
+ @param pInterface source interface
+ @param pTypeDescr type description of interface
+ @return mapped interface
+ */
+ inline void * SAL_CALL mapInterface( void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const;
+ /** Maps an interface from one environment to another.
+ <br>
+ @param pInterface source interface
+ @param pTypeDescr type description of interface
+ @return mapped interface
+ */
+ inline void * SAL_CALL mapInterface( void * pInterface, typelib_TypeDescription * pTypeDescr ) const
+ { return mapInterface( pInterface, (typelib_InterfaceTypeDescription *)pTypeDescr ); }
+
+ /** Maps an interface from one environment to another.
+ <br>
+ @param pInterface source interface
+ @param rType type of interface
+ @return mapped interface
+ */
+ inline void * SAL_CALL mapInterface( void * pInterface, const ::com::sun::star::uno::Type & rType ) const;
+
+ /** Maps an interface from one environment to another.
+ <br>
+ @param ppOut inout mapped interface
+ @param pInterface source interface
+ @param pTypeDescr type description of interface
+ */
+ inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const
+ { (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, pTypeDescr ); }
+ /** Maps an interface from one environment to another.
+ <br>
+ @param ppOut inout mapped interface
+ @param pInterface source interface
+ @param pTypeDescr type description of interface
+ */
+ inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, typelib_TypeDescription * pTypeDescr ) const
+ { (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, (typelib_InterfaceTypeDescription *)pTypeDescr ); }
+
+ /** Maps an interface from one environment to another.
+ <br>
+ @param ppOut inout mapped interface
+ @param pInterface source interface
+ @param rType type of interface to be mapped
+ */
+ inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, const ::com::sun::star::uno::Type & rType ) const;
+};
+//__________________________________________________________________________________________________
+inline Mapping::Mapping( const ::rtl::OUString & rFrom, const ::rtl::OUString & rTo,
+ const ::rtl::OUString & rAddPurpose )
+ : _pMapping( 0 )
+{
+ uno_getMappingByName( &_pMapping, rFrom.pData, rTo.pData, rAddPurpose.pData );
+}
+//__________________________________________________________________________________________________
+inline Mapping::Mapping( uno_Environment * pFrom, uno_Environment * pTo,
+ const ::rtl::OUString & rAddPurpose )
+ : _pMapping( 0 )
+{
+ uno_getMapping( &_pMapping, pFrom, pTo, rAddPurpose.pData );
+}
+//__________________________________________________________________________________________________
+inline Mapping::Mapping( uno_Mapping * pMapping )
+ : _pMapping( pMapping )
+{
+ if (_pMapping)
+ (*_pMapping->acquire)( _pMapping );
+}
+//__________________________________________________________________________________________________
+inline Mapping::Mapping( const Mapping & rMapping )
+ : _pMapping( rMapping._pMapping )
+{
+ if (_pMapping)
+ (*_pMapping->acquire)( _pMapping );
+}
+//__________________________________________________________________________________________________
+inline Mapping::~Mapping()
+{
+ if (_pMapping)
+ (*_pMapping->release)( _pMapping );
+}
+//__________________________________________________________________________________________________
+inline void Mapping::clear()
+{
+ if (_pMapping)
+ {
+ (*_pMapping->release)( _pMapping );
+ _pMapping = 0;
+ }
+}
+//__________________________________________________________________________________________________
+inline Mapping & Mapping::operator = ( uno_Mapping * pMapping )
+{
+ if (pMapping)
+ (*pMapping->acquire)( pMapping );
+ if (_pMapping)
+ (*_pMapping->release)( _pMapping );
+ _pMapping = pMapping;
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline void Mapping::mapInterface( void ** ppOut, void * pInterface,
+ const ::com::sun::star::uno::Type & rType ) const
+{
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, rType.getTypeLibType() );
+ if (pTD)
+ {
+ (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, (typelib_InterfaceTypeDescription *)pTD );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+}
+//__________________________________________________________________________________________________
+inline void * Mapping::mapInterface( void * pInterface,
+ typelib_InterfaceTypeDescription * pTypeDescr ) const
+{
+ void * pOut = 0;
+ (*_pMapping->mapInterface)( _pMapping, &pOut, pInterface, pTypeDescr );
+ return pOut;
+}
+//__________________________________________________________________________________________________
+inline void * Mapping::mapInterface( void * pInterface,
+ const ::com::sun::star::uno::Type & rType ) const
+{
+ void * pOut = 0;
+ mapInterface( &pOut, pInterface, rType );
+ return pOut;
+}
+
+//--------------------------------------------------------------------------------------------------
+template< class C >
+inline sal_Bool mapToCpp( Reference< C > * ppRet, uno_Interface * pUnoI )
+{
+ Mapping aMapping(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ) );
+ OSL_ASSERT( aMapping.is() );
+ aMapping.mapInterface( (void **)ppRet, pUnoI, ::getCppuType( ppRet ) );
+ return (0 != *ppRet);
+}
+//--------------------------------------------------------------------------------------------------
+template< class C >
+inline sal_Bool mapToUno( uno_Interface ** ppRet, const Reference< C > & x )
+{
+ Mapping aMapping(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ) );
+ OSL_ASSERT( aMapping.is() );
+ aMapping.mapInterface( (void **)ppRet, x.get(), ::getCppuType( &x ) );
+ return (0 != *ppRet);
+}
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/uno/sequence2.h b/cppu/inc/uno/sequence2.h
new file mode 100644
index 000000000000..828db39c9106
--- /dev/null
+++ b/cppu/inc/uno/sequence2.h
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * $RCSfile: sequence2.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _UNO_SEQUENCE2_H_
+#define _UNO_SEQUENCE2_H_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef sal_Sequence uno_Sequence;
+
+/** Assign a sequence.
+ <br>
+ @param ppDest destinstaion sequence
+ @param pSource source sequence
+ @param pTypeDescr type description of the <B>sequence</B> and <b>not</b> of an element
+ @param release function called each time an interface needs to be released; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_sequence_assign(
+ uno_Sequence ** ppDest,
+ uno_Sequence * pSource,
+ typelib_TypeDescription * pTypeDescr,
+ uno_ReleaseFunc release );
+/** Assign a sequence.
+ <br>
+ @param ppDest destinstaion sequence
+ @param pSource source sequence
+ @param pType type of the <B>sequence</B> and <b>not</b> of an element
+ @param release function called each time an interface needs to be released; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_sequence_assign(
+ uno_Sequence ** ppDest,
+ uno_Sequence * pSource,
+ typelib_TypeDescriptionReference * pType,
+ uno_ReleaseFunc release );
+
+/** Constructs a new sequence with given elements.
+ <br>
+ @param ppSequence <b>out</b> parameter sequence
+ @param pTypeDescr type description of the <B>sequence</B> and <b>not</b> of an element
+ @param pElements if 0, then all elements are default constructed
+ @param len number of elements
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_sequence_construct(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescription * pTypeDescr,
+ void * pElements, sal_Int32 len,
+ uno_AcquireFunc acquire );
+/** Constructs a new sequence with given elements.
+ <br>
+ @param ppSequence <b>out</b> parameter sequence
+ @param pType type of the <B>sequence</B> and <b>not</b> of an element
+ @param pElements if 0, then all elements are default constructed
+ @param len number of elements
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_sequence_construct(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescriptionReference * pType,
+ void * pElements, sal_Int32 len,
+ uno_AcquireFunc acquire );
+
+/** Assures that the reference count of the given sequence is one.
+ Otherwise a new copy of the sequence is created with a reference count of one.
+ <br>
+ @param ppSequence sequence
+ @param pTypeDescr type description of sequence
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to be released; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_sequence_reference2One(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire,
+ uno_ReleaseFunc release );
+/** Assures that the reference count of the given sequence is one.
+ Otherwise a new copy of the sequence is created with a reference count of one.
+ <br>
+ @param ppSequence sequence
+ @param pType type of sequence
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to be released; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_sequence_reference2One(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescriptionReference * pType,
+ uno_AcquireFunc acquire,
+ uno_ReleaseFunc release );
+
+/** Reallocates length of a sequence. This truncates a sequence or enlarges it
+ default constructing appended elements.
+ <br>
+ @param ppSequence sequence
+ @param pTypeDescr type description of sequence
+ @param nSize new size of sequence
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to be released; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_sequence_realloc(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescription * pTypeDescr,
+ sal_Int32 nSize,
+ uno_AcquireFunc acquire,
+ uno_ReleaseFunc release );
+/** Reallocates length of a sequence. This truncates a sequence or enlarges it
+ default constructing appended elements.
+ <br>
+ @param ppSequence sequence
+ @param pType type of sequence
+ @param nSize new size of sequence
+ @param acquire function called each time an interface needs to be acquired; defaults (0) to uno
+ @param release function called each time an interface needs to be released; defaults (0) to uno
+*/
+SAL_DLLEXPORT void SAL_CALL uno_type_sequence_realloc(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescriptionReference * pType,
+ sal_Int32 nSize,
+ uno_AcquireFunc acquire,
+ uno_ReleaseFunc release );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/cppu/inc/uno/threadpool.h b/cppu/inc/uno/threadpool.h
new file mode 100644
index 000000000000..f27564607287
--- /dev/null
+++ b/cppu/inc/uno/threadpool.h
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * $RCSfile: threadpool.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <sal/types.h>
+#include <rtl/byteseq.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***
+ * Thread identifier administration.
+ ***/
+/**
+ * Establishs an association between the current thread an the given thread identifier.
+ * There can be only one association at a time. The association must be broken by
+ * uno_releaseIdFromCurrentThread.
+ * This method is in general called by a bridge, that wants to bind a remote threadId
+ * to a new thread.
+ *
+ * @param pThreadId a byte sequence, that contains the identifier of the current thread.
+ * @return true, when the identifier was registered. <br>
+ * false, when the thread has already an identifier. The identifier was not
+ * altered. ( This is in general a bug ). <br>
+ **/
+SAL_DLLEXPORT sal_Bool SAL_CALL uno_bindIdToCurrentThread( sal_Sequence *pThreadId );
+
+
+/**
+ * Get the identifier of the current thread.
+ * If no id has been bound for the thread before, a new one is generated and bound
+ * to the thread.
+ * For each call to uno_getIdOfCurrentThread, a call to uno_releaseIdFromCurrentThread
+ * must be done.
+ *
+ * @param ppThreadId [out] Contains the (acquired) ThreadId.
+ **/
+SAL_DLLEXPORT void SAL_CALL uno_getIdOfCurrentThread( sal_Sequence **ppThreadId );
+
+
+/**
+ * If the internal refcount drops to zero, the association betwen threadId and
+ * thread is broken.
+ **/
+SAL_DLLEXPORT void SAL_CALL uno_releaseIdFromCurrentThread();
+
+
+
+
+
+
+
+/**
+ * The threadpool
+ **/
+struct uno_threadpool_Handle;
+/**
+ * Create a handle for the current thread before entering waiting pool. This method must be
+ * called, BEFORE the request is sent (to avoid a race between this thread and an incoming
+ * reply).
+ * This method shall only be called for synchronous requests.
+ *
+ * @param nDisposeId An ID, that uniquely identifies a bridge within the
+ * local process. The pointer to the bridge object should be used.
+ * @see uno_threadpool_disposeThreads
+ ***/
+SAL_DLLEXPORT struct uno_threadpool_Handle * SAL_CALL
+uno_threadpool_createHandle( sal_Int64 nDisposeId );
+
+/**
+ * This method is called to wait for a reply of a previously sent request. This is a
+ * blocking method.
+ *
+ * @param pHandle the handle that was previously created by uno_threadpool_createHandle.
+ * @param ppThreadSpecificData [out] the pointer, that was given by uno_threadpool_reply.
+ * If the threads for this bridge were disposed,
+ * *ppThreadSpecificData is null.
+ **/
+SAL_DLLEXPORT void SAL_CALL
+uno_threadpool_enter( struct uno_threadpool_Handle * pHandle , void **ppThreadSpecificData );
+
+
+/**
+ * A request is put into a queue of waiting requests. This method is non-blocking.
+ *
+ * If the request is synchronous, it is first looked up,
+ * if there exists a handle with the given
+ * identifier. If this is the case, the thread is woken up and the doRequest
+ * function is called with the given pThreadSpecificData. If no handle exists,
+ * a new thread is created and the given threadId is bound to the new thread.
+ *
+ * If the request is asynchronous, it is put into the queue of asynchronous
+ * requests for the current threadid. The requests are always executed in a new
+ * thread, even if the thread with the given Id waiting in the pool. No Id is bound
+ * to the newly created thread. The responsibilty is left to the bridge ( if it
+ * wishes to bind a name).
+ *
+ * @param pThreadId The Id of thread, that initialized this request. (In general a
+ * remote threadid).
+ * @param pThreadSpecificData The argument, that doRequest will get.
+ * @param doRequest The function, that shall be called to execute the request.
+ * @param bIsOneway True, if the request is asynchrons. False, if it is synchronous
+ *
+ **/
+SAL_DLLEXPORT void SAL_CALL
+uno_threadpool_putRequest( sal_Sequence *pThreadId,
+ void *pThreadSpecificData,
+ void ( SAL_CALL * doRequest ) ( void *pThreadSpecificData ),
+ sal_Bool bIsOneway );
+
+
+/**
+ * A reply is put into the threadpool. There MUST be a thread with the given threadId waiting
+ * for this reply. This method is non-blocking.
+ *
+ * @param pThreadSpecificData The pointer, that is returned by uno_threadpool_enter.
+ **/
+SAL_DLLEXPORT void SAL_CALL
+uno_threadpool_putReply( sal_Sequence *pThreadId, void *pThreadSpecificData );
+
+
+/**
+ * All threads, that are waiting on handles, that were created with
+ * nDisposeId, are forced out of the pool.
+ * (@see uno_threadpool_createTicket) These threads will return from
+ * uno_threadpool_enter with 0 == *ppThreadSpecificData.
+ * Later calls to uno_threadpool_enter with the given disposeId also
+ * return immeadiatly.
+ *
+ * @param nDisposeId Identfies the caller of uno_threadpool_createTicket
+ *
+ * This function is called i.e. by a bridge, that is forced to dispose itself.
+ * When disposing of the bridge has finished, the bridge MUST call
+ * uno_threadpool_stopDisposeThreads.
+ **/
+SAL_DLLEXPORT void SAL_CALL
+uno_threadpool_disposeThreads( sal_Int64 nDisposeId );
+
+
+/**
+ * Informs the threadpool, that no special treatment is needed for the given nDisposeId.
+ * This allows the threadpool to release internal resources
+ * and must be called after all threads originated from this bridge have returned.
+ * (This can in general be done in the bridge destructor).
+ *
+ * @param nDisposeId Identifies the caller of uno_threadpool_createTicket
+ * @see uno_threadpool_disposeThreads
+ **/
+SAL_DLLEXPORT void SAL_CALL
+uno_threadpool_stopDisposeThreads( sal_Int64 nDisposeId );
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/cppu/prj/d.lst b/cppu/prj/d.lst
new file mode 100644
index 000000000000..18c002a150ac
--- /dev/null
+++ b/cppu/prj/d.lst
@@ -0,0 +1,42 @@
+mkdir: %_DEST%\inc%_EXT%\cppu
+mkdir: %_DEST%\inc%_EXT%\com
+mkdir: %_DEST%\inc%_EXT%\com\sun
+mkdir: %_DEST%\inc%_EXT%\com\sun\star
+mkdir: %_DEST%\inc%_EXT%\com\sun\star\uno
+mkdir: %_DEST%\inc%_EXT%\typelib
+mkdir: %_DEST%\inc%_EXT%\uno
+
+..\inc\cppu\macros.hxx %_DEST%\inc%_EXT%\cppu\macros.hxx
+
+..\inc\com\sun\star\uno\Reference.h %_DEST%\inc%_EXT%\com\sun\star\uno\Reference.h
+..\inc\com\sun\star\uno\Reference.hxx %_DEST%\inc%_EXT%\com\sun\star\uno\Reference.hxx
+..\inc\com\sun\star\uno\Type.h %_DEST%\inc%_EXT%\com\sun\star\uno\Type.h
+..\inc\com\sun\star\uno\Type.hxx %_DEST%\inc%_EXT%\com\sun\star\uno\Type.hxx
+..\inc\com\sun\star\uno\Any.h %_DEST%\inc%_EXT%\com\sun\star\uno\Any.h
+..\inc\com\sun\star\uno\Any.hxx %_DEST%\inc%_EXT%\com\sun\star\uno\Any.hxx
+..\inc\com\sun\star\uno\Sequence.h %_DEST%\inc%_EXT%\com\sun\star\uno\Sequence.h
+..\inc\com\sun\star\uno\Sequence.hxx %_DEST%\inc%_EXT%\com\sun\star\uno\Sequence.hxx
+..\inc\com\sun\star\uno\genfunc.h %_DEST%\inc%_EXT%\com\sun\star\uno\genfunc.h
+..\inc\com\sun\star\uno\genfunc.hxx %_DEST%\inc%_EXT%\com\sun\star\uno\genfunc.hxx
+
+..\inc\typelib\typeclass.h %_DEST%\inc%_EXT%\typelib\typeclass.h
+..\inc\typelib\typedescription.h %_DEST%\inc%_EXT%\typelib\typedescription.h
+..\inc\typelib\typedescription.hxx %_DEST%\inc%_EXT%\typelib\typedescription.hxx
+..\inc\typelib\uik.h %_DEST%\inc%_EXT%\typelib\uik.h
+
+..\inc\uno\dispatcher.h %_DEST%\inc%_EXT%\uno\dispatcher.h
+..\inc\uno\any2.h %_DEST%\inc%_EXT%\uno\any2.h
+..\inc\uno\sequence2.h %_DEST%\inc%_EXT%\uno\sequence2.h
+..\inc\uno\data.h %_DEST%\inc%_EXT%\uno\data.h
+..\inc\uno\lbnames.h %_DEST%\inc%_EXT%\uno\lbnames.h
+..\inc\uno\environment.h %_DEST%\inc%_EXT%\uno\environment.h
+..\inc\uno\environment.hxx %_DEST%\inc%_EXT%\uno\environment.hxx
+..\inc\uno\mapping.h %_DEST%\inc%_EXT%\uno\mapping.h
+..\inc\uno\mapping.hxx %_DEST%\inc%_EXT%\uno\mapping.hxx
+..\inc\uno\threadpool.h %_DEST%\inc%_EXT%\uno\threadpool.h
+
+..\%__SRC%\lib\icppu.lib %_DEST%\lib%_EXT%\icppu.lib
+..\%__SRC%\bin\cppu* %_DEST%\bin%_EXT%\*
+..\%__SRC%\lib\libcppu* %_DEST%\lib%_EXT%\*
+
+..\version.mk %_DEST%\inc%_EXT%\cppu\version.mk
diff --git a/cppu/source/cppu/makefile.mk b/cppu/source/cppu/makefile.mk
new file mode 100644
index 000000000000..79e2ee6f7557
--- /dev/null
+++ b/cppu/source/cppu/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= cppu
+TARGET= cppu_cppu
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+.INCLUDE : ..$/..$/util$/target.pmk
+.INCLUDE : target.mk
diff --git a/cppu/source/threadpool/jobqueue.cxx b/cppu/source/threadpool/jobqueue.cxx
new file mode 100644
index 000000000000..46f263042221
--- /dev/null
+++ b/cppu/source/threadpool/jobqueue.cxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * $RCSfile: jobqueue.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "jobqueue.hxx"
+#include "threadpool.hxx"
+
+#include <osl/diagnose.h>
+
+using namespace ::osl;
+
+namespace cppu_threadpool {
+
+ JobQueue::JobQueue( sal_Bool bAsynchron ) :
+ m_cndWait( osl_createCondition() ),
+ m_bSuspended( sal_False ),
+ m_nToDo( 0 )
+ {
+ osl_resetCondition( m_cndWait );
+ }
+
+ JobQueue::~JobQueue()
+ {
+ osl_destroyCondition( m_cndWait );
+ }
+
+
+ void JobQueue::add( void *pThreadSpecificData ,
+ void ( SAL_CALL * doRequest ) ( void *pThreadSpecificData ) )
+ {
+ MutexGuard guard( m_mutex );
+ Job job = { pThreadSpecificData , doRequest };
+ m_lstJob.push_back( job );
+ if( ! m_bSuspended )
+ {
+ osl_setCondition( m_cndWait );
+ }
+ m_nToDo ++;
+ }
+
+ void *JobQueue::enter( sal_Int64 nDisposeId , sal_Bool bReturnWhenNoJob )
+ {
+ void *pReturn = 0;
+ {
+ // synchronize with the dispose calls
+ MutexGuard guard( m_mutex );
+ if( DisposedCallerAdmin::getInstance()->isDisposed( nDisposeId ) )
+ {
+ return 0;
+ }
+ m_lstCallstack.push_front( nDisposeId );
+ }
+
+
+ while( sal_True )
+ {
+ if( bReturnWhenNoJob )
+ {
+ MutexGuard guard( m_mutex );
+ if( m_lstJob.empty() )
+ {
+ break;
+ }
+ }
+
+ osl_waitCondition( m_cndWait , 0 );
+
+ struct Job job={0,0};
+ {
+ // synchronize with add and dispose calls
+ MutexGuard guard( m_mutex );
+
+ if( 0 == m_lstCallstack.front() )
+ {
+ // disposed !
+ break;
+ }
+
+ OSL_ASSERT( ! m_lstJob.empty() );
+ if( ! m_lstJob.empty() )
+ {
+ job = m_lstJob.front();
+ m_lstJob.pop_front();
+ }
+ if( m_lstJob.empty() )
+ {
+ osl_resetCondition( m_cndWait );
+ }
+ }
+
+ if( job.doRequest )
+ {
+ job.doRequest( job.pThreadSpecificData );
+ m_nToDo --;
+ }
+ else
+ {
+ m_nToDo --;
+ pReturn = job.pThreadSpecificData;
+ break;
+ }
+ }
+
+ {
+ // synchronize with the dispose calls
+ MutexGuard guard( m_mutex );
+ m_lstCallstack.pop_front();
+ }
+
+ return pReturn;
+ }
+
+ void JobQueue::dispose( sal_Int64 nDisposeId )
+ {
+ MutexGuard guard( m_mutex );
+ for( CallStackList::iterator ii = m_lstCallstack.begin() ;
+ ii != m_lstCallstack.end() ;
+ ++ii )
+ {
+ if( (*ii) == nDisposeId )
+ {
+ (*ii) = 0;
+ }
+ }
+
+ if( !m_lstCallstack.empty() && ! m_lstCallstack.front() )
+ {
+ // The thread is waiting for a disposed pCallerId, let it go
+ osl_setCondition( m_cndWait );
+ }
+ }
+
+ void JobQueue::suspend()
+ {
+ MutexGuard guard( m_mutex );
+ m_bSuspended = sal_True;
+ }
+
+ void JobQueue::resume()
+ {
+ MutexGuard guard( m_mutex );
+ m_bSuspended = sal_False;
+ if( ! m_lstJob.empty() )
+ {
+ osl_setCondition( m_cndWait );
+ }
+ }
+
+ sal_Bool JobQueue::isEmpty()
+ {
+ MutexGuard guard( m_mutex );
+ return m_lstJob.empty();
+ }
+
+ sal_Bool JobQueue::isCallstackEmpty()
+ {
+ MutexGuard guard( m_mutex );
+ return m_lstCallstack.empty();
+ }
+
+ sal_Bool JobQueue::isBusy()
+ {
+ return m_nToDo > 0;
+ }
+
+
+}
diff --git a/cppu/source/threadpool/jobqueue.hxx b/cppu/source/threadpool/jobqueue.hxx
new file mode 100644
index 000000000000..53ba018a71a5
--- /dev/null
+++ b/cppu/source/threadpool/jobqueue.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * $RCSfile: jobqueue.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPU_THREADPOOL_JOBQUEUE_HXX_
+#define _CPPU_THREADPOOL_JOBQUEUE_HXX_
+
+#include <list>
+
+#include <osl/types.h>
+#include <osl/conditn.h>
+#include <osl/mutex.hxx>
+
+namespace cppu_threadpool
+{
+ struct Job
+ {
+ void *pThreadSpecificData;
+ void ( SAL_CALL *doRequest ) ( void * );
+ };
+
+ typedef ::std::list < struct Job > JobList;
+
+ typedef ::std::list < sal_Int64 > CallStackList;
+
+ class JobQueue
+ {
+ public:
+ JobQueue( sal_Bool bAsynchron );
+ ~JobQueue();
+
+ void add( void *pThreadSpecificData ,
+ void ( SAL_CALL * doRequest ) ( void *pThreadSpecificData ) );
+
+ void *enter( sal_Int64 nDisposeId , sal_Bool bReturnWhenNoJob = sal_False );
+ void dispose( sal_Int64 nDisposeId );
+
+ void suspend();
+ void resume();
+
+ sal_Bool isEmpty();
+ sal_Bool isCallstackEmpty();
+ sal_Bool isBusy();
+
+ private:
+ ::osl::Mutex m_mutex;
+ JobList m_lstJob;
+ CallStackList m_lstCallstack;
+ sal_Int32 m_nToDo;
+ sal_Bool m_bSuspended;
+ oslCondition m_cndWait;
+ };
+}
+
+#endif
diff --git a/cppu/source/threadpool/makefile.mk b/cppu/source/threadpool/makefile.mk
new file mode 100644
index 000000000000..7a82725ba517
--- /dev/null
+++ b/cppu/source/threadpool/makefile.mk
@@ -0,0 +1,88 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=cppu
+TARGET=cppu_threadpool
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : ..$/..$/util$/makefile.pmk
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/threadpool.obj\
+ $(SLO)$/jobqueue.obj\
+ $(SLO)$/thread.obj\
+ $(SLO)$/threadident.obj
+
+# $(SLO)$/threadpool.obj \
+# $(SLO)$/process.obj \
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : ..$/..$/util$/target.pmk
+.INCLUDE : target.mk
diff --git a/cppu/source/threadpool/thread.cxx b/cppu/source/threadpool/thread.cxx
new file mode 100644
index 000000000000..9d006ff142f2
--- /dev/null
+++ b/cppu/source/threadpool/thread.cxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * $RCSfile: thread.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdio.h>
+#include <osl/diagnose.h>
+#include <uno/threadpool.h>
+
+#include "thread.hxx"
+#include "jobqueue.hxx"
+#include "threadpool.hxx"
+
+
+extern "C" {
+
+void SAL_CALL cppu_requestThreadWorker( void *pVoid )
+{
+ ::cppu_threadpool::ORequestThread *pThread = ( ::cppu_threadpool::ORequestThread * ) pVoid;
+
+ pThread->run();
+ pThread->onTerminated();
+}
+
+}
+namespace cppu_threadpool {
+
+ ORequestThread::ORequestThread( JobQueue *pQueue,
+ const ByteSequence &aThreadId,
+ sal_Bool bAsynchron )
+ : m_pQueue( pQueue )
+ , m_thread( 0 )
+ , m_aThreadId( aThreadId )
+ , m_bAsynchron( bAsynchron )
+ {
+
+ }
+
+
+ ORequestThread::~ORequestThread()
+ {
+ if (m_thread != 0)
+ {
+ osl_freeThreadHandle(m_thread);
+ }
+ }
+
+
+ void ORequestThread::setTask( JobQueue *pQueue,
+ const ByteSequence &aThreadId,
+ sal_Bool bAsynchron )
+ {
+ m_pQueue = pQueue;
+ m_aThreadId = aThreadId;
+ m_bAsynchron = bAsynchron;
+ }
+
+ sal_Bool ORequestThread::create()
+ {
+ OSL_ASSERT(m_thread == 0); // only one running thread per instance
+
+ if ( m_thread = osl_createSuspendedThread( cppu_requestThreadWorker, (void*)this))
+ {
+ osl_resumeThread( m_thread );
+ }
+
+ return m_thread != 0;
+ }
+
+ void ORequestThread::onTerminated()
+ {
+ delete this;
+ }
+
+ // hack during no proper threadlocalstorage support
+ void SAL_CALL destructCurrentId();
+
+ void ORequestThread::run()
+ {
+ while ( m_pQueue )
+ {
+ if( ! m_bAsynchron )
+ {
+ sal_Bool bReturn = uno_bindIdToCurrentThread( m_aThreadId.getHandle() );
+ OSL_ASSERT( bReturn );
+ }
+
+ while( ! m_pQueue->isEmpty() )
+ {
+ // Note : Oneways should not get a disposable disposeid,
+ // It does not make sense to dispose a call in this state.
+ // That's way we put it an disposeid, that can't be used otherwise.
+ m_pQueue->enter( (sal_Int64 ) this , sal_True );
+
+ if( m_pQueue->isEmpty() )
+ {
+ ThreadPool::getInstance()->revokeQueue( m_aThreadId , m_bAsynchron );
+ // Note : revokeQueue might have failed because m_pQueue.isEmpty()
+ // may be false (race).
+ }
+ }
+
+ delete m_pQueue;
+ m_pQueue = 0;
+
+ if( ! m_bAsynchron )
+ {
+ uno_releaseIdFromCurrentThread();
+ }
+
+ cppu_threadpool::ThreadPool::getInstance()->waitInPool( this );
+ }
+ destructCurrentId();
+ }
+}
diff --git a/cppu/source/threadpool/thread.hxx b/cppu/source/threadpool/thread.hxx
new file mode 100644
index 000000000000..0099150b71ee
--- /dev/null
+++ b/cppu/source/threadpool/thread.hxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * $RCSfile: thread.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPU_THREADPOOL_THREAD_HXX
+#define _CPPU_THREADPOOL_THREAD_HXX
+
+#include <osl/types.h>
+#include <osl/thread.h>
+
+#include "jobqueue.hxx"
+
+namespace cppu_threadpool {
+
+ class JobQueue;
+
+ //-----------------------------------------
+ // private thread class for the threadpool
+ // independent from vos
+ //-----------------------------------------
+ class ORequestThread
+ {
+ public:
+ ORequestThread( JobQueue * ,
+ const ::rtl::ByteSequence &aThreadId,
+ sal_Bool bAsynchron );
+ ~ORequestThread();
+
+ void setTask( JobQueue * , const ::rtl::ByteSequence & aThreadId , sal_Bool bAsynchron );
+
+ sal_Bool create();
+ void onTerminated();
+ void run();
+
+ private:
+ oslThread m_thread;
+ JobQueue *m_pQueue;
+ ::rtl::ByteSequence m_aThreadId;
+ sal_Bool m_bAsynchron;
+ };
+
+} // end cppu_threadpool
+
+
+#endif
+
diff --git a/cppu/source/threadpool/threadident.cxx b/cppu/source/threadpool/threadident.cxx
new file mode 100644
index 000000000000..cedf69b6e869
--- /dev/null
+++ b/cppu/source/threadpool/threadident.cxx
@@ -0,0 +1,218 @@
+/*************************************************************************
+ *
+ * $RCSfile: threadident.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdio.h>
+#include <assert.h>
+
+#include <list>
+#include <hash_map>
+
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <osl/diagnose.h>
+
+#include <rtl/process.h>
+#include <rtl/byteseq.hxx>
+
+#include <uno/threadpool.h>
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+using namespace ::std;
+using namespace ::osl;
+using namespace ::rtl;
+
+
+static sal_Bool g_bInitialized;
+static oslThreadKey g_key;
+
+namespace cppu_threadpool
+{
+struct IdContainer
+{
+ sal_Sequence *pLocalThreadId;
+ sal_Int32 nRefCountOfCurrentId;
+ sal_Sequence *pCurrentId;
+};
+}
+using namespace cppu_threadpool;
+
+static inline oslThreadKey getKey()
+{
+ if( ! g_bInitialized )
+ {
+ ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! g_bInitialized )
+ {
+ g_key = osl_createThreadKey();
+ g_bInitialized = sal_True;
+ }
+ }
+ return g_key;
+}
+
+static inline void createLocalId( sal_Sequence **ppThreadId )
+{
+ rtl_byte_sequence_constructNoDefault( ppThreadId , 4 + 16 );
+ *((sal_Int32*) ((*ppThreadId)->elements)) = osl_getThreadIdentifier(0);
+
+ rtl_getGlobalProcessId( (sal_uInt8 * ) &( (*ppThreadId)->elements[4]) );
+}
+
+
+static void SAL_CALL destructIdContainer( void *p )
+{
+ if( p )
+ {
+ IdContainer *pId = (IdContainer * ) p;
+ rtl_byte_sequence_release( pId->pLocalThreadId );
+ rtl_byte_sequence_release( pId->pCurrentId );
+ rtl_freeMemory( p );
+ }
+}
+
+
+//--------------------------------------------------------
+// private hack as long as no proper threadlocal storage is provided
+//--------------------------------------------------------
+namespace cppu_threadpool {
+void SAL_CALL destructCurrentId()
+{
+ destructIdContainer( osl_getThreadKeyData( getKey() ) );
+}
+}
+
+
+extern "C" SAL_DLLEXPORT void SAL_CALL
+uno_getIdOfCurrentThread( sal_Sequence **ppThreadId )
+{
+ IdContainer * p = (IdContainer * ) osl_getThreadKeyData( getKey() );
+ if( ! p )
+ {
+ // first time, that the thread enters the bridge
+ createLocalId( ppThreadId );
+
+ // TODO
+ // note : this is a leak !
+ IdContainer *p = (IdContainer *) rtl_allocateMemory( sizeof( IdContainer ) );
+ p->pLocalThreadId = *ppThreadId;
+ p->pCurrentId = *ppThreadId;
+ p->nRefCountOfCurrentId = 1;
+ rtl_byte_sequence_acquire( p->pLocalThreadId );
+ rtl_byte_sequence_acquire( p->pCurrentId );
+
+ OSL_VERIFY( osl_setThreadKeyData( getKey(), p ) );
+ }
+ else
+ {
+ p->nRefCountOfCurrentId ++;
+ if( *ppThreadId )
+ {
+ rtl_byte_sequence_release( *ppThreadId );
+ }
+ *ppThreadId = p->pCurrentId;
+ rtl_byte_sequence_acquire( *ppThreadId );
+ }
+}
+
+
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_releaseIdFromCurrentThread()
+{
+ IdContainer *p = (IdContainer * ) osl_getThreadKeyData( getKey() );
+ OSL_ASSERT( p );
+ OSL_ASSERT( p->nRefCountOfCurrentId );
+
+ p->nRefCountOfCurrentId --;
+ if( ! p->nRefCountOfCurrentId && (p->pLocalThreadId != p->pCurrentId) )
+ {
+ rtl_byte_sequence_assign( &(p->pCurrentId) , p->pLocalThreadId );
+ }
+}
+
+extern "C" SAL_DLLEXPORT sal_Bool SAL_CALL uno_bindIdToCurrentThread( sal_Sequence *pThreadId )
+{
+ IdContainer *p = (IdContainer * ) osl_getThreadKeyData( getKey() );
+ if( ! p )
+ {
+ IdContainer *p = (IdContainer * ) rtl_allocateMemory( sizeof( IdContainer ) );
+
+ p->pLocalThreadId = 0;
+ createLocalId( &(p->pLocalThreadId) );
+ p->nRefCountOfCurrentId = 1;
+ p->pCurrentId = pThreadId;
+ rtl_byte_sequence_acquire( p->pCurrentId );
+ osl_setThreadKeyData( getKey() , p );
+ }
+ else
+ {
+ OSL_ASSERT( 0 == p->nRefCountOfCurrentId );
+ if( 0 == p->nRefCountOfCurrentId )
+ {
+ rtl_byte_sequence_assign(&( p->pCurrentId ), pThreadId );
+ p->nRefCountOfCurrentId ++;
+ }
+ else
+ {
+ return sal_False;
+ }
+
+ }
+ return sal_True;
+}
diff --git a/cppu/source/threadpool/threadpool.cxx b/cppu/source/threadpool/threadpool.cxx
new file mode 100644
index 000000000000..7133eeb149e3
--- /dev/null
+++ b/cppu/source/threadpool/threadpool.cxx
@@ -0,0 +1,473 @@
+/*************************************************************************
+ *
+ * $RCSfile: threadpool.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+
+#include <uno/threadpool.h>
+
+#include "threadpool.hxx"
+#include "thread.hxx"
+
+using namespace ::std;
+using namespace ::osl;
+
+struct uno_threadpool_Handle
+{
+ /**
+ * Global Threadidentifier of the waiting thread
+ **/
+ uno_threadpool_Handle( const ByteSequence &aThreadId_ , sal_Int64 nDisposeId_ )
+ : aThreadId( aThreadId_ )
+ , nDisposeId( nDisposeId_ )
+ {}
+
+ ByteSequence aThreadId;
+ sal_Int64 nDisposeId;
+};
+
+namespace cppu_threadpool
+{
+ DisposedCallerAdmin *DisposedCallerAdmin::getInstance()
+ {
+ static DisposedCallerAdmin *pDisposedCallerAdmin = 0;
+ if( ! pDisposedCallerAdmin )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pDisposedCallerAdmin )
+ {
+ static DisposedCallerAdmin admin;
+ pDisposedCallerAdmin = &admin;
+ }
+ }
+ return pDisposedCallerAdmin;
+ }
+
+ DisposedCallerAdmin::~DisposedCallerAdmin()
+ {
+#ifdef DEBUG
+ if( !m_lst.empty() )
+ {
+ printf( "DisposedCallerList : %d left\n" , m_lst.size( ));
+ }
+#endif
+ }
+
+ void DisposedCallerAdmin::dispose( sal_Int64 nDisposeId )
+ {
+ MutexGuard guard( m_mutex );
+ m_lst.push_back( nDisposeId );
+ }
+
+ void DisposedCallerAdmin::stopDisposing( sal_Int64 nDisposeId )
+ {
+ MutexGuard guard( m_mutex );
+ for( DisposedCallerList::iterator ii = m_lst.begin() ;
+ ii != m_lst.end() ;
+ ++ ii )
+ {
+ if( (*ii) == nDisposeId )
+ {
+ m_lst.erase( ii );
+ break;
+ }
+ }
+ }
+
+ sal_Bool DisposedCallerAdmin::isDisposed( sal_Int64 nDisposeId )
+ {
+ MutexGuard guard( m_mutex );
+ for( DisposedCallerList::iterator ii = m_lst.begin() ;
+ ii != m_lst.end() ;
+ ++ ii )
+ {
+ if( (*ii) == nDisposeId )
+ {
+ return sal_True;
+ }
+ }
+ return sal_False;
+ }
+
+
+ //-------------------------------------------------------------------------------
+ ThreadPool::~ThreadPool()
+ {
+#ifdef DEBUG
+ if( m_mapQueue.size() )
+ {
+ printf( "ThreadIdHashMap : %d left\n" , m_mapQueue.size() );
+ }
+#endif
+ }
+ ThreadPool *ThreadPool::getInstance()
+ {
+ static ThreadPool *pThreadPool = 0;
+ if( ! pThreadPool )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pThreadPool )
+ {
+ static ThreadPool pool;
+ pThreadPool = &pool;
+ }
+ }
+ return pThreadPool;
+ }
+
+
+ void ThreadPool::dispose( sal_Int64 nDisposeId )
+ {
+ DisposedCallerAdmin::getInstance()->dispose( nDisposeId );
+
+ MutexGuard guard( m_mutex );
+ for( ThreadIdHashMap::iterator ii = m_mapQueue.begin() ;
+ ii != m_mapQueue.end();
+ ++ii)
+ {
+ if( (*ii).second.first )
+ {
+ (*ii).second.first->dispose( nDisposeId );
+ }
+ if( (*ii).second.second )
+ {
+ (*ii).second.second->dispose( nDisposeId );
+ }
+ }
+ }
+
+ void ThreadPool::stopDisposing( sal_Int64 nDisposeId )
+ {
+ DisposedCallerAdmin::getInstance()->stopDisposing( nDisposeId );
+ }
+
+ /******************
+ * This methods lets the thread wait a certain amount of time. If within this timespan
+ * a new request comes in, this thread is reused. This is done only to improve performance,
+ * it is not required for threadpool functionality.
+ ******************/
+ void ThreadPool::waitInPool( ORequestThread * pThread )
+ {
+ struct WaitingThread waitingThread;
+ waitingThread.condition = osl_createCondition();
+ waitingThread.thread = pThread;
+ {
+ MutexGuard guard( m_mutexWaitingThreadList );
+ m_lstThreads.push_front( &waitingThread );
+ }
+
+ // let the thread wait 2 seconds
+ osl_resetCondition( waitingThread.condition );
+ TimeValue time = { 2 , 0 };
+ osl_waitCondition( waitingThread.condition , &time );
+
+ {
+ MutexGuard guard ( m_mutexWaitingThreadList );
+ if( waitingThread.thread )
+ {
+ // thread wasn't reused, remove it from the list
+ WaitingThreadList::iterator ii = find(
+ m_lstThreads.begin(), m_lstThreads.end(), &waitingThread );
+ OSL_ASSERT( ii != m_lstThreads.end() );
+ m_lstThreads.erase( ii );
+ }
+ }
+
+ osl_destroyCondition( waitingThread.condition );
+ }
+
+ void ThreadPool::createThread( JobQueue *pQueue ,
+ const ByteSequence &aThreadId,
+ sal_Bool bAsynchron )
+ {
+ sal_Bool bCreate = sal_True;
+ {
+ // Can a thread be reused ?
+ MutexGuard guard( m_mutexWaitingThreadList );
+ if( ! m_lstThreads.empty() )
+ {
+ // inform the thread and let it go
+ struct WaitingThread *pWaitingThread = m_lstThreads.back();
+ pWaitingThread->thread->setTask( pQueue , aThreadId , bAsynchron );
+ pWaitingThread->thread = 0;
+
+ // remove from list
+ m_lstThreads.pop_back();
+
+ // let the thread go
+ osl_setCondition( pWaitingThread->condition );
+ bCreate = sal_False;
+ }
+ }
+
+ if( bCreate )
+ {
+ ORequestThread *pThread =
+ new ORequestThread( pQueue , aThreadId, bAsynchron);
+ // deletes itself !
+ pThread->create();
+ }
+ }
+
+ sal_Bool ThreadPool::revokeQueue( const ByteSequence &aThreadId, sal_Bool bAsynchron )
+ {
+ MutexGuard guard( m_mutex );
+
+ ThreadIdHashMap::iterator ii = m_mapQueue.find( aThreadId );
+ OSL_ASSERT( ii != m_mapQueue.end() );
+
+ if( bAsynchron )
+ {
+ if( ! (*ii).second.second->isEmpty() )
+ {
+ // another thread has put something into the queue
+ return sal_False;
+ }
+
+ (*ii).second.second = 0;
+ if( (*ii).second.first )
+ {
+ // all oneway request have been processed, now
+ // synchronus requests may go on
+ (*ii).second.first->resume();
+ }
+ }
+ else
+ {
+ if( ! (*ii).second.first->isEmpty() )
+ {
+ // another thread has put something into the queue
+ return sal_False;
+ }
+ (*ii).second.first = 0;
+ }
+
+ if( 0 == (*ii).second.first && 0 == (*ii).second.second )
+ {
+ m_mapQueue.erase( ii );
+ }
+
+ return sal_True;
+ }
+
+
+ void ThreadPool::addJob(
+ const ByteSequence &aThreadId ,
+ sal_Bool bAsynchron,
+ void *pThreadSpecificData,
+ void ( SAL_CALL * doRequest ) ( void * ) )
+ {
+ sal_Bool bCreateThread = sal_False;
+ JobQueue *pQueue = 0;
+ {
+ MutexGuard guard( m_mutex );
+
+ ThreadIdHashMap::iterator ii = m_mapQueue.find( aThreadId );
+
+ if( ii == m_mapQueue.end() )
+ {
+ m_mapQueue[ aThreadId ] = pair < JobQueue * , JobQueue * > ( 0 , 0 );
+ ii = m_mapQueue.find( aThreadId );
+ OSL_ASSERT( ii != m_mapQueue.end() );
+ }
+
+ if( bAsynchron )
+ {
+ if( ! (*ii).second.second )
+ {
+ (*ii).second.second = new JobQueue( bAsynchron );
+ bCreateThread = sal_True;
+ }
+ pQueue = (*ii).second.second;
+ }
+ else
+ {
+ if( ! (*ii).second.first )
+ {
+ (*ii).second.first = new JobQueue( bAsynchron );
+ bCreateThread = sal_True;
+ }
+ pQueue = (*ii).second.first;
+
+ if( (*ii).second.second && ( (*ii).second.second->isBusy() ) )
+ {
+ pQueue->suspend();
+ }
+ }
+ pQueue->add( pThreadSpecificData , doRequest );
+ }
+
+ if( bCreateThread )
+ {
+ createThread( pQueue , aThreadId , bAsynchron);
+ }
+ }
+
+ void ThreadPool::prepare( const ByteSequence &aThreadId )
+ {
+ MutexGuard guard( m_mutex );
+
+ ThreadIdHashMap::iterator ii = m_mapQueue.find( aThreadId );
+
+ if( ii == m_mapQueue.end() )
+ {
+ JobQueue *p = new JobQueue( sal_False );
+ m_mapQueue[ aThreadId ] = pair< JobQueue * , JobQueue * > ( p , 0 );
+ }
+ else if( 0 == (*ii).second.first )
+ {
+ (*ii).second.first = new JobQueue( sal_False );
+ }
+ }
+
+ void * ThreadPool::enter( const ByteSequence & aThreadId , sal_Int64 nDisposeId )
+ {
+ JobQueue *pQueue = 0;
+ {
+ MutexGuard guard( m_mutex );
+
+ ThreadIdHashMap::iterator ii = m_mapQueue.find( aThreadId );
+
+ OSL_ASSERT( ii != m_mapQueue.end() );
+ pQueue = (*ii).second.first;
+ }
+
+ OSL_ASSERT( pQueue );
+ void *pReturn = pQueue->enter( nDisposeId );
+
+ if( pQueue->isCallstackEmpty() )
+ {
+ if( revokeQueue( aThreadId , sal_False) )
+ {
+ // remove queue
+ delete pQueue;
+ }
+ }
+ return pReturn;
+ }
+}
+
+
+using namespace cppu_threadpool;
+
+
+//------------------------------
+//
+// The C-Interface
+//
+//-------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_threadpool_putRequest(
+ sal_Sequence *pThreadId, void *pThreadSpecificData,
+ void ( SAL_CALL * doRequest ) ( void *pThreadSpecificData ), sal_Bool bIsOneway )
+{
+ ThreadPool::getInstance()->addJob( pThreadId, bIsOneway, pThreadSpecificData,doRequest );
+}
+
+
+
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_threadpool_putReply(
+ sal_Sequence *pThreadId, void *pThreadSpecificData )
+{
+ ThreadPool::getInstance()->addJob( pThreadId, sal_False, pThreadSpecificData, 0 );
+}
+
+
+extern "C" SAL_DLLEXPORT struct uno_threadpool_Handle * SAL_CALL
+uno_threadpool_createHandle( sal_Int64 nDisposeId )
+{
+ sal_Sequence *pThreadId = 0;
+ uno_getIdOfCurrentThread( &pThreadId );
+
+ struct uno_threadpool_Handle *pHandle = new uno_threadpool_Handle( pThreadId, nDisposeId );
+ ThreadPool::getInstance()->prepare( pThreadId );
+
+ rtl_byte_sequence_release( pThreadId );
+
+ return pHandle;
+}
+
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_threadpool_enter(
+ struct uno_threadpool_Handle *pHandle , void **ppThreadSpecificData )
+{
+ OSL_ASSERT( ppThreadSpecificData );
+
+ *ppThreadSpecificData =
+ ThreadPool::getInstance()->enter( pHandle->aThreadId , pHandle->nDisposeId );
+
+ uno_releaseIdFromCurrentThread();
+ delete pHandle;
+}
+
+
+extern "C" SAL_DLLEXPORT void SAL_CALL
+uno_threadpool_disposeThreads( sal_Int64 nDisposeId )
+{
+ ThreadPool::getInstance()->dispose( nDisposeId );
+}
+
+extern "C" SAL_DLLEXPORT void SAL_CALL
+uno_threadpool_stopDisposeThreads( sal_Int64 nDisposeId )
+{
+ ThreadPool::getInstance()->stopDisposing( nDisposeId );
+}
diff --git a/cppu/source/threadpool/threadpool.hxx b/cppu/source/threadpool/threadpool.hxx
new file mode 100644
index 000000000000..46b822b8b09b
--- /dev/null
+++ b/cppu/source/threadpool/threadpool.hxx
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * $RCSfile: threadpool.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <hash_map>
+
+#include <osl/conditn.h>
+
+#include <rtl/byteseq.hxx>
+
+#include "jobqueue.hxx"
+
+
+using namespace ::rtl;
+namespace cppu_threadpool {
+ class ORequestThread;
+
+ struct EqualThreadId
+ {
+ sal_Int32 operator () ( const ::rtl::ByteSequence &a , const ::rtl::ByteSequence &b ) const
+ {
+ return a == b;
+ }
+ };
+
+ struct HashThreadId
+ {
+ sal_Int32 operator () ( const ::rtl::ByteSequence &a ) const
+ {
+ if( a.getLength() >= 4 )
+ {
+ return *(sal_Int32 *)a.getConstArray();
+ }
+ return 0;
+ }
+ };
+
+ typedef ::std::hash_map
+ <
+ ByteSequence, // ThreadID
+ ::std::pair < JobQueue * , JobQueue * >,
+ HashThreadId,
+ EqualThreadId
+ > ThreadIdHashMap;
+
+ typedef ::std::list < sal_Int64 > DisposedCallerList;
+
+
+ struct WaitingThread
+ {
+ oslCondition condition;
+ ORequestThread *thread;
+ };
+
+ typedef ::std::list < struct ::cppu_threadpool::WaitingThread * > WaitingThreadList;
+
+ class DisposedCallerAdmin
+ {
+ public:
+ ~DisposedCallerAdmin();
+
+ static DisposedCallerAdmin *getInstance();
+
+ void dispose( sal_Int64 nDisposeId );
+ void stopDisposing( sal_Int64 nDisposeId );
+ sal_Bool isDisposed( sal_Int64 nDisposeId );
+
+ private:
+ ::osl::Mutex m_mutex;
+ DisposedCallerList m_lst;
+ };
+
+ class ThreadPool
+ {
+ public:
+ ~ThreadPool();
+ static ThreadPool *getInstance();
+
+ void dispose( sal_Int64 nDisposeId );
+ void stopDisposing( sal_Int64 nDisposeId );
+
+ void addJob( const ByteSequence &aThreadId,
+ sal_Bool bAsynchron,
+ void *pThreadSpecificData,
+ void ( SAL_CALL * doRequest ) ( void * ) );
+
+ void prepare( const ByteSequence &aThreadId );
+ void * enter( const ByteSequence &aThreadId, sal_Int64 nDisposeId );
+
+ /********
+ * @return true, if queue could be succesfully revoked.
+ ********/
+ sal_Bool revokeQueue( const ByteSequence & aThreadId , sal_Bool bAsynchron );
+
+ void waitInPool( ORequestThread *pThread );
+ private:
+ void createThread( JobQueue *pQueue, const ByteSequence &aThreadId, sal_Bool bAsynchron);
+
+
+ ThreadIdHashMap m_mapQueue;
+ ::osl::Mutex m_mutex;
+
+ ::osl::Mutex m_mutexWaitingThreadList;
+ WaitingThreadList m_lstThreads;
+ };
+
+} // end namespace cppu_threadpool
diff --git a/cppu/source/typelib/makefile.mk b/cppu/source/typelib/makefile.mk
new file mode 100644
index 000000000000..4b10ad15e65b
--- /dev/null
+++ b/cppu/source/typelib/makefile.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=cppu
+TARGET=cppu_typelib
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : ..$/..$/util$/makefile.pmk
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/typelib.obj \
+ $(SLO)$/static_types.obj
+
+.INCLUDE : ..$/..$/util$/target.pmk
+.INCLUDE : target.mk
diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx
new file mode 100644
index 000000000000..5705596a3352
--- /dev/null
+++ b/cppu/source/typelib/static_types.cxx
@@ -0,0 +1,626 @@
+/*************************************************************************
+ *
+ * $RCSfile: static_types.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <osl/mutex.hxx>
+#include <osl/interlck.h>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/memory.h>
+
+#include <typelib/typedescription.h>
+
+
+using namespace osl;
+using namespace rtl;
+
+//------------------------------------------------------------------------
+sal_Int32 SAL_CALL typelib_typedescription_getAlignedUnoSize(
+ const typelib_TypeDescription * pTypeDescription,
+ sal_Int32 nOffset,
+ sal_Int32 & rMaxIntegralTypeSize );
+//------------------------------------------------------------------------
+void SAL_CALL typelib_typedescription_newEmpty(
+ typelib_TypeDescription ** ppRet,
+ typelib_TypeClass eTypeClass,
+ rtl_uString * pTypeName );
+//-----------------------------------------------------------------------------
+void SAL_CALL typelib_typedescriptionreference_getByName(
+ typelib_TypeDescriptionReference ** ppRet,
+ rtl_uString * pName );
+
+extern "C"
+{
+
+#ifdef SAL_W32
+#pragma pack(push, 8)
+#elif defined(SAL_OS2)
+#pragma pack(8)
+#endif
+
+/**
+ * The double member determin the alignment.
+ * Under Os2 and MS-Windows the Alignment is min( 8, sizeof( type ) ).
+ * The aligment of a strukture is min( 8, sizeof( max basic type ) ), the greatest basic type
+ * determine the aligment.
+ */
+struct AlignSize_Impl
+{
+ sal_Int16 nInt16;
+ double dDouble;
+};
+
+#ifdef SAL_W32
+#pragma pack(pop)
+#elif defined(SAL_OS2)
+#pragma pack()
+#endif
+
+// the value of the maximal alignment
+static sal_Int32 nMaxAlignment = (sal_Int32)&((AlignSize_Impl *) 16)->dDouble - 16;
+
+static inline sal_Int32 adjustAlignment( sal_Int32 nRequestedAlignment )
+{
+ if( nRequestedAlignment > nMaxAlignment )
+ nRequestedAlignment = nMaxAlignment;
+ return nRequestedAlignment;
+}
+
+/**
+ * Calculate the new size of the struktur.
+ */
+static inline sal_Int32 newAlignedSize( sal_Int32 OldSize, sal_Int32 ElementSize, sal_Int32 NeededAlignment )
+{
+ NeededAlignment = adjustAlignment( NeededAlignment );
+ return (OldSize + NeededAlignment -1) / NeededAlignment * NeededAlignment + ElementSize;
+}
+
+//--------------------------------------------------------------------------------------------------
+static Mutex & typelib_getStaticInitMutex()
+{
+ static Mutex * s_pMutex = 0;
+ if (! s_pMutex)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pMutex)
+ {
+ static Mutex s_aMutex;
+ s_pMutex = &s_aMutex;
+ }
+ }
+ return *s_pMutex;
+}
+
+//##################################################################################################
+SAL_DLLEXPORT typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass(
+ typelib_TypeClass eTypeClass )
+{
+ static typelib_TypeDescriptionReference * s_aTypes[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0 };
+
+ if (! s_aTypes[eTypeClass])
+ {
+ MutexGuard aGuard( typelib_getStaticInitMutex() );
+ if (! s_aTypes[eTypeClass])
+ {
+ static const char * s_aTypeNames[] = {
+ "void", "char", "boolean", "byte",
+ "short", "unsigned short", "long", "unsigned long",
+ "hyper", "unsigned hyper", "float", "double",
+ "string", "type", "any" };
+
+ switch (eTypeClass)
+ {
+ case typelib_TypeClass_EXCEPTION:
+ case typelib_TypeClass_INTERFACE:
+ {
+ // type
+ if (! s_aTypes[typelib_TypeClass_TYPE])
+ {
+ OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("type") );
+ ::typelib_typedescriptionreference_new(
+ &s_aTypes[typelib_TypeClass_TYPE], typelib_TypeClass_TYPE, sTypeName.pData );
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&s_aTypes[typelib_TypeClass_TYPE]->pReserved);
+#endif
+ }
+ // any
+ if (! s_aTypes[typelib_TypeClass_ANY])
+ {
+ OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("any") );
+ ::typelib_typedescriptionreference_new(
+ &s_aTypes[typelib_TypeClass_ANY], typelib_TypeClass_ANY, sTypeName.pData );
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&s_aTypes[typelib_TypeClass_ANY]->pReserved);
+#endif
+ }
+ // string
+ if (! s_aTypes[typelib_TypeClass_STRING])
+ {
+ OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("string") );
+ ::typelib_typedescriptionreference_new(
+ &s_aTypes[typelib_TypeClass_STRING], typelib_TypeClass_STRING, sTypeName.pData );
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&s_aTypes[typelib_TypeClass_STRING]->pReserved);
+#endif
+ }
+ // XInterface
+ if (! s_aTypes[typelib_TypeClass_INTERFACE])
+ {
+ OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface") );
+
+ typelib_InterfaceTypeDescription * pTD = 0;
+
+ typelib_TypeDescriptionReference * pMembers[3] = { 0,0,0 };
+ OUString sMethodName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::queryInterface") );
+ ::typelib_typedescriptionreference_new(
+ &pMembers[0], typelib_TypeClass_INTERFACE_METHOD, sMethodName0.pData );
+ OUString sMethodName1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::acquire") );
+ ::typelib_typedescriptionreference_new(
+ &pMembers[1], typelib_TypeClass_INTERFACE_METHOD, sMethodName1.pData );
+ OUString sMethodName2( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::release") );
+ ::typelib_typedescriptionreference_new(
+ &pMembers[2], typelib_TypeClass_INTERFACE_METHOD, sMethodName2.pData );
+
+ ::typelib_typedescription_newInterface(
+ &pTD, sTypeName.pData, 0xe227a391, 0x33d6, 0x11d1, 0xaabe00a0, 0x249d5590,
+ 0, 3, pMembers );
+
+ ::typelib_typedescription_register( (typelib_TypeDescription **)&pTD );
+ ::typelib_typedescriptionreference_acquire(
+ s_aTypes[typelib_TypeClass_INTERFACE] = ((typelib_TypeDescription *)pTD)->pWeakRef );
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&s_aTypes[typelib_TypeClass_INTERFACE]->pReserved);
+#endif
+ ::typelib_typedescription_release( (typelib_TypeDescription*)pTD );
+
+ ::typelib_typedescriptionreference_release( pMembers[0] );
+ ::typelib_typedescriptionreference_release( pMembers[1] );
+ ::typelib_typedescriptionreference_release( pMembers[2] );
+ // Exception
+ OSL_ASSERT( ! s_aTypes[typelib_TypeClass_EXCEPTION] );
+ {
+ typelib_TypeDescription * pTD = 0;
+ OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception") );
+
+ typelib_CompoundMember_Init aMembers[2];
+ OUString sMemberType0( RTL_CONSTASCII_USTRINGPARAM("string") );
+ OUString sMemberName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception::Message") );
+ aMembers[0].eTypeClass = typelib_TypeClass_STRING;
+ aMembers[0].pTypeName = sMemberType0.pData;
+ aMembers[0].pMemberName = sMemberName0.pData;
+ OUString sMemberType1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface") );
+ OUString sMemberName1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception::Context") );
+ aMembers[1].eTypeClass = typelib_TypeClass_INTERFACE;
+ aMembers[1].pTypeName = sMemberType1.pData;
+ aMembers[1].pMemberName = sMemberName1.pData;
+
+ ::typelib_typedescription_new(
+ &pTD, typelib_TypeClass_EXCEPTION, sTypeName.pData, 0, 2, aMembers );
+ typelib_typedescription_register( &pTD );
+ typelib_typedescriptionreference_acquire(
+ s_aTypes[typelib_TypeClass_EXCEPTION] = pTD->pWeakRef );
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&s_aTypes[typelib_TypeClass_EXCEPTION]->pReserved);
+#endif
+ // RuntimeException
+ OUString sTypeName2( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException") );
+ ::typelib_typedescription_new(
+ &pTD, typelib_TypeClass_EXCEPTION, sTypeName2.pData, s_aTypes[typelib_TypeClass_EXCEPTION], 0, 0 );
+ ::typelib_typedescription_register( &pTD );
+ ::typelib_typedescription_release( pTD );
+ }
+ // XInterface members
+ typelib_InterfaceMethodTypeDescription * pMethod = 0;
+ typelib_Parameter_Init aParameters[1];
+ OUString sParamName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::aType") );
+ OUString sParamType0( RTL_CONSTASCII_USTRINGPARAM("type") );
+ aParameters[0].pParamName = sParamName0.pData;
+ aParameters[0].eTypeClass = typelib_TypeClass_TYPE;
+ aParameters[0].pTypeName = sParamType0.pData;
+ aParameters[0].bIn = sal_True;
+ aParameters[0].bOut = sal_False;
+ rtl_uString * pExceptions[1];
+ OUString sExceptionName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException") );
+ pExceptions[0] = sExceptionName0.pData;
+ OUString sReturnType0( RTL_CONSTASCII_USTRINGPARAM("any") );
+ typelib_typedescription_newInterfaceMethod(
+ &pMethod, 0, sal_False, sMethodName0.pData,
+ typelib_TypeClass_ANY, sReturnType0.pData,
+ 1, aParameters, 1, pExceptions );
+ ::typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );
+
+ OUString sReturnType1( RTL_CONSTASCII_USTRINGPARAM("void") );
+ ::typelib_typedescription_newInterfaceMethod(
+ &pMethod, 1, sal_True, sMethodName1.pData,
+ typelib_TypeClass_VOID, sReturnType1.pData, 0, 0, 0, 0 );
+ ::typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );
+
+ ::typelib_typedescription_newInterfaceMethod(
+ &pMethod, 2, sal_True, sMethodName2.pData,
+ typelib_TypeClass_VOID, sReturnType1.pData,
+ 0, 0, 0, 0 );
+ ::typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );
+ ::typelib_typedescription_release( (typelib_TypeDescription*)pMethod );
+ }
+ break;
+ }
+ default:
+ {
+ OUString aTypeName( OUString::createFromAscii( s_aTypeNames[eTypeClass] ) );
+ ::typelib_typedescriptionreference_new( &s_aTypes[eTypeClass], eTypeClass, aTypeName.pData );
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&s_aTypes[eTypeClass]->pReserved);
+#endif
+ }
+ }
+ }
+ }
+ return &s_aTypes[eTypeClass];
+}
+
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL typelib_static_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeClass eTypeClass, const sal_Char * pTypeName )
+{
+ if (! *ppRef)
+ {
+ MutexGuard aGuard( typelib_getStaticInitMutex() );
+ if (! *ppRef)
+ {
+ OUString aTypeName( OUString::createFromAscii( pTypeName ) );
+ ::typelib_typedescriptionreference_new( ppRef, eTypeClass, aTypeName.pData );
+
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&(*ppRef)->pReserved);
+#endif
+ }
+ }
+}
+
+// !for NOT REALLY WEAK TYPES only!
+static inline typelib_TypeDescriptionReference * __getTypeByName( rtl_uString * pTypeName )
+{
+ typelib_TypeDescriptionReference * pRef = 0;
+ ::typelib_typedescriptionreference_getByName( &pRef, pTypeName );
+ if (pRef && pRef->pType && pRef->pType->pWeakRef) // found initialized td
+ return pRef;
+ else
+ return 0;
+}
+
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL typelib_static_sequence_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeDescriptionReference * pElementType )
+{
+ if (! *ppRef)
+ {
+ MutexGuard aGuard( typelib_getStaticInitMutex() );
+ if (! *ppRef)
+ {
+ OUStringBuffer aBuf( 32 );
+ aBuf.appendAscii( "[]" );
+ aBuf.append( pElementType->pTypeName );
+ OUString aTypeName( aBuf.makeStringAndClear() );
+
+ OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_SEQUENCE) );
+ if (! (*ppRef = __getTypeByName( aTypeName.pData )))
+ {
+ typelib_TypeDescription * pReg = 0;
+ ::typelib_typedescription_new(
+ &pReg, typelib_TypeClass_SEQUENCE,
+ aTypeName.pData, pElementType, 0, 0 );
+
+ ::typelib_typedescription_register( &pReg );
+ *ppRef = (typelib_TypeDescriptionReference *)pReg;
+ OSL_ASSERT( *ppRef == pReg->pWeakRef );
+ }
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&(*ppRef)->pReserved);
+#endif
+ }
+ }
+}
+
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL typelib_static_compound_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ typelib_TypeClass eTypeClass, const sal_Char * pTypeName,
+ typelib_TypeDescriptionReference * pBaseType,
+ sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers )
+{
+ OSL_ENSHURE( typelib_TypeClass_STRUCT == eTypeClass ||
+ typelib_TypeClass_EXCEPTION == eTypeClass, "### unexpected type class!" );
+
+ if (! *ppRef)
+ {
+ MutexGuard aGuard( typelib_getStaticInitMutex() );
+ if (! *ppRef)
+ {
+ OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(eTypeClass) );
+ OUString aTypeName( OUString::createFromAscii( pTypeName ) );
+ if (! (*ppRef = __getTypeByName( aTypeName.pData )))
+ {
+ typelib_CompoundTypeDescription * pComp = 0;
+ ::typelib_typedescription_newEmpty(
+ (typelib_TypeDescription **)&pComp, eTypeClass, aTypeName.pData );
+
+ sal_Int32 nOffset = 0;
+ if (pBaseType)
+ {
+ ::typelib_typedescriptionreference_getDescription(
+ (typelib_TypeDescription **)&pComp->pBaseTypeDescription, pBaseType );
+ OSL_ASSERT( pComp->pBaseTypeDescription );
+ nOffset = ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize;
+ OSL_ENSHURE( newAlignedSize( 0, ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize, ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nAlignment ) == ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize, "### unexpected offset!" );
+ }
+
+ if (nMembers)
+ {
+ pComp->nMembers = nMembers;
+ pComp->pMemberOffsets = new sal_Int32[ nMembers ];
+ pComp->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ];
+ for ( sal_Int32 i = 0 ; i < nMembers; ++i )
+ {
+ ::typelib_typedescriptionreference_acquire(
+ pComp->ppTypeRefs[i] = ppMembers[i] );
+ // write offset
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, pComp->ppTypeRefs[i] );
+ OSL_ENSHURE( pTD->nSize, "### void member?" );
+ nOffset = newAlignedSize( nOffset, pTD->nSize, pTD->nAlignment );
+ pComp->pMemberOffsets[i] = nOffset - pTD->nSize;
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ }
+
+ typelib_TypeDescription * pReg = (typelib_TypeDescription *)pComp;
+ pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg;
+ // sizeof( void ) not allowed
+ pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
+ pReg->nAlignment = adjustAlignment( pReg->nAlignment );
+ pReg->bComplete = sal_False;
+
+ ::typelib_typedescription_register( &pReg );
+ *ppRef = (typelib_TypeDescriptionReference *)pReg;
+ OSL_ASSERT( *ppRef == pReg->pWeakRef );
+ }
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&(*ppRef)->pReserved);
+#endif
+ }
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL typelib_static_interface_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ const sal_Char * pTypeName,
+ typelib_TypeDescriptionReference * pBaseType )
+{
+ if (! *ppRef)
+ {
+ MutexGuard aGuard( typelib_getStaticInitMutex() );
+ if (! *ppRef)
+ {
+ OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_INTERFACE) );
+ OUString aTypeName( OUString::createFromAscii( pTypeName ) );
+ if (! (*ppRef = __getTypeByName( aTypeName.pData )))
+ {
+ typelib_InterfaceTypeDescription * pIface = 0;
+ ::typelib_typedescription_newEmpty(
+ (typelib_TypeDescription **)&pIface, typelib_TypeClass_INTERFACE, aTypeName.pData );
+
+ if (pBaseType)
+ {
+ ::typelib_typedescriptionreference_getDescription(
+ (typelib_TypeDescription **)&pIface->pBaseTypeDescription, pBaseType );
+ }
+ else
+ {
+ ::typelib_typedescriptionreference_getDescription(
+ (typelib_TypeDescription **)&pIface->pBaseTypeDescription,
+ * ::typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE ) );
+ }
+ OSL_ASSERT( pIface->pBaseTypeDescription );
+
+ typelib_TypeDescription * pReg = (typelib_TypeDescription *)pIface;
+ pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg;
+ // sizeof( void ) not allowed
+ pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
+
+ pReg->nAlignment = adjustAlignment( pReg->nAlignment );
+ pReg->bComplete = sal_False;
+
+ ::typelib_typedescription_register( &pReg );
+ *ppRef = (typelib_TypeDescriptionReference *)pReg;
+ OSL_ASSERT( *ppRef == pReg->pWeakRef );
+ }
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&(*ppRef)->pReserved);
+#endif
+ }
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL typelib_static_enum_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ const sal_Char * pTypeName,
+ sal_Int32 nDefaultValue )
+{
+ if (! *ppRef)
+ {
+ MutexGuard aGuard( typelib_getStaticInitMutex() );
+ if (! *ppRef)
+ {
+ OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ENUM) );
+ OUString aTypeName( OUString::createFromAscii( pTypeName ) );
+ if (! (*ppRef = __getTypeByName( aTypeName.pData )))
+ {
+ typelib_TypeDescription * pReg = 0;
+ ::typelib_typedescription_newEmpty(
+ &pReg, typelib_TypeClass_ENUM, aTypeName.pData );
+ typelib_EnumTypeDescription * pEnum = (typelib_EnumTypeDescription *)pReg;
+
+ pEnum->nDefaultEnumValue = nDefaultValue;
+
+ pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg;
+ // sizeof( void ) not allowed
+ pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
+ pReg->nAlignment = ::adjustAlignment( pReg->nAlignment );
+ pReg->bComplete = sal_False;
+
+ ::typelib_typedescription_register( &pReg );
+ *ppRef = (typelib_TypeDescriptionReference *)pReg;
+ OSL_ASSERT( *ppRef == pReg->pWeakRef );
+ }
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&(*ppRef)->pReserved);
+#endif
+ }
+ }
+}
+
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL typelib_static_union_type_init(
+ typelib_TypeDescriptionReference ** ppRef,
+ const sal_Char * pTypeName,
+ typelib_TypeDescriptionReference * pDiscriminantTypeRef,
+ sal_Int64 nDefaultDiscriminant,
+ typelib_TypeDescriptionReference * pDefaultTypeRef,
+ sal_Int32 nMembers,
+ sal_Int64 * pDiscriminants,
+ typelib_TypeDescriptionReference ** pMemberTypes )
+{
+ if (! *ppRef)
+ {
+ MutexGuard aGuard( typelib_getStaticInitMutex() );
+ if (! *ppRef)
+ {
+ OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_UNION) );
+ OUString aTypeName( OUString::createFromAscii( pTypeName ) );
+ if (! (*ppRef = __getTypeByName( aTypeName.pData )))
+ {
+ typelib_UnionTypeDescription * pUnion = 0;
+ ::typelib_typedescription_newEmpty(
+ (typelib_TypeDescription **)&pUnion, typelib_TypeClass_UNION, aTypeName.pData );
+ // discriminant type
+ ::typelib_typedescriptionreference_acquire( pUnion->pDiscriminantTypeRef = pDiscriminantTypeRef );
+
+ sal_Int32 nPos;
+
+ pUnion->nMembers = nMembers;
+ // default discriminant
+ if (nMembers)
+ {
+ pUnion->pDiscriminants = new sal_Int64[ nMembers ];
+ for ( nPos = nMembers; nPos--; )
+ {
+ pUnion->pDiscriminants[nPos] = pDiscriminants[nPos];
+ }
+ }
+ // default default discriminant
+ pUnion->nDefaultDiscriminant = nDefaultDiscriminant;
+
+ // union member types
+ pUnion->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ];
+ for ( nPos = nMembers; nPos--; )
+ {
+ ::typelib_typedescriptionreference_acquire(
+ pUnion->ppTypeRefs[nPos] = pMemberTypes[nPos] );
+ }
+
+ // default union type
+ ::typelib_typedescriptionreference_acquire( pUnion->pDefaultTypeRef = pDefaultTypeRef );
+
+ typelib_TypeDescription * pReg = (typelib_TypeDescription *)pUnion;
+
+ pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg;
+ pReg->nSize = typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
+ pReg->nAlignment = adjustAlignment( pReg->nAlignment );
+ pReg->bComplete = sal_False;
+
+ ::typelib_typedescription_register( &pReg );
+ *ppRef = (typelib_TypeDescriptionReference *)pReg;
+ OSL_ASSERT( *ppRef == pReg->pWeakRef );
+ }
+#ifndef CPPU_LEAK_STATIC_DATA
+ // another static ref
+ ++(*(sal_Int32 *)&(*ppRef)->pReserved);
+#endif
+ }
+ }
+}
+
+}
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
new file mode 100644
index 000000000000..573a4961cce3
--- /dev/null
+++ b/cppu/source/typelib/typelib.cxx
@@ -0,0 +1,2112 @@
+/*************************************************************************
+ *
+ * $RCSfile: typelib.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef CPPU_ASSERTIONS
+#define CPPU_TRACE(x) OSL_TRACE(x)
+#else
+#define CPPU_TRACE(x)
+#endif
+
+#include <stl/hash_map>
+#include <stl/list>
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <memory.h>
+#ifdef MACOSX
+#include <sys/types.h>
+#include <sys/malloc.h>
+#else
+#include <malloc.h>
+#endif
+#if defined(SOLARIS)
+#include <alloca.h>
+#endif
+#include <new.h>
+
+#ifndef _OSL_INTERLCK_H_
+#include <osl/interlck.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+#ifndef _UNO_ANY2_H_
+#include <uno/any2.h>
+#endif
+
+using namespace rtl;
+using namespace std;
+using namespace osl;
+
+
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+#ifdef SAL_W32
+#pragma pack(push, 8)
+#elif defined(SAL_OS2)
+#pragma pack(8)
+#endif
+
+/**
+ * The double member determin the alignment.
+ * Under Os2 and MS-Windows the Alignment is min( 8, sizeof( type ) ).
+ * The aligment of a strukture is min( 8, sizeof( max basic type ) ), the greatest basic type
+ * determine the aligment.
+ */
+struct AlignSize_Impl
+{
+ sal_Int16 nInt16;
+ double dDouble;
+};
+
+#ifdef SAL_W32
+#pragma pack(pop)
+#elif defined(SAL_OS2)
+#pragma pack()
+#endif
+
+// the value of the maximal alignment
+static sal_Int32 nMaxAlignment = (sal_Int32)&((AlignSize_Impl *) 16)->dDouble - 16;
+
+static inline sal_Int32 adjustAlignment( sal_Int32 nRequestedAlignment )
+{
+ if( nRequestedAlignment > nMaxAlignment )
+ nRequestedAlignment = nMaxAlignment;
+ return nRequestedAlignment;
+}
+
+/**
+ * Calculate the new size of the struktur.
+ */
+static inline sal_Int32 newAlignedSize( sal_Int32 OldSize, sal_Int32 ElementSize, sal_Int32 NeededAlignment )
+{
+ NeededAlignment = adjustAlignment( NeededAlignment );
+ return (OldSize + NeededAlignment -1) / NeededAlignment * NeededAlignment + ElementSize;
+}
+
+inline sal_Bool reallyWeak( typelib_TypeClass eTypeClass )
+{
+ return TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( eTypeClass );
+}
+
+inline sal_Int32 getDescriptionSize( typelib_TypeClass eTypeClass )
+{
+ OSL_ASSERT( typelib_TypeClass_TYPEDEF != eTypeClass );
+
+ sal_Int32 nSize;
+ // The reference is the description
+ // if the description is empty, than it must be filled with
+ // the new description
+ switch( eTypeClass )
+ {
+ case typelib_TypeClass_ARRAY:
+ case typelib_TypeClass_SEQUENCE:
+ nSize = (sal_Int32)sizeof( typelib_IndirectTypeDescription );
+ break;
+
+ case typelib_TypeClass_UNION:
+ nSize = (sal_Int32)sizeof( typelib_UnionTypeDescription );
+ break;
+
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ nSize = (sal_Int32)sizeof( typelib_CompoundTypeDescription );
+ break;
+
+ case typelib_TypeClass_ENUM:
+ nSize = (sal_Int32)sizeof( typelib_EnumTypeDescription );
+ break;
+
+ case typelib_TypeClass_INTERFACE:
+ nSize = (sal_Int32)sizeof( typelib_InterfaceTypeDescription );
+ break;
+
+ case typelib_TypeClass_INTERFACE_METHOD:
+ nSize = (sal_Int32)sizeof( typelib_InterfaceMethodTypeDescription );
+ break;
+
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ nSize = (sal_Int32)sizeof( typelib_InterfaceAttributeTypeDescription );
+ break;
+
+ default:
+ nSize = (sal_Int32)sizeof( typelib_TypeDescription );
+ }
+ return nSize;
+}
+
+
+//-----------------------------------------------------------------------------
+void SAL_CALL typelib_typedescriptionreference_getByName(
+ typelib_TypeDescriptionReference ** ppRet,
+ rtl_uString * pName );
+
+//-----------------------------------------------------------------------------
+struct equalStr_Impl
+{
+ sal_Bool operator()(const sal_Unicode * const & s1, const sal_Unicode * const & s2) const
+ { return 0 == rtl_ustr_compare( s1, s2 ); }
+};
+
+//-----------------------------------------------------------------------------
+struct hashStr_Impl
+{
+ size_t operator()(const sal_Unicode * const & s) const
+ { return rtl_ustr_hashCode( s ); }
+};
+
+
+//-----------------------------------------------------------------------------
+// Heavy hack, the const sal_Unicode * is hold by the typedescription reference
+typedef hash_map< const sal_Unicode *, typelib_TypeDescriptionReference *,
+ hashStr_Impl, equalStr_Impl > WeakMap_Impl;
+
+typedef pair< void *, typelib_typedescription_Callback > CallbackEntry;
+typedef list< CallbackEntry > CallbackSet_Impl;
+typedef list< typelib_TypeDescription * > TypeDescriptionList_Impl;
+
+// # of cached elements
+static sal_Int32 nCacheSize = 256;
+
+//-----------------------------------------------------------------------------
+/**
+ * All members must set initial to 0 and no constructor is needed. So it
+ * doesn't care, when this class is static initialized.<BR>
+ */
+struct TypeDescriptor_Init_Impl
+{
+ //sal_Bool bDesctructorCalled;
+ // all type description references
+ WeakMap_Impl * pWeakMap;
+ // all type description callbacks
+ CallbackSet_Impl * pCallbacks;
+ // A cache to hold descriptions
+ TypeDescriptionList_Impl * pCache;
+ // The mutex to guard all type library accesses
+ Mutex * pMutex;
+
+ inline Mutex & getMutex();
+
+ inline void callChain(
+ typelib_TypeDescription ** ppRet, rtl_uString * pName );
+
+#ifdef CPPU_ASSERTIONS
+ // only for debugging
+ sal_Int32 nTypeDescriptionCount;
+ sal_Int32 nCompoundTypeDescriptionCount;
+ sal_Int32 nUnionTypeDescriptionCount;
+ sal_Int32 nIndirectTypeDescriptionCount;
+ sal_Int32 nEnumTypeDescriptionCount;
+ sal_Int32 nInterfaceMethodTypeDescriptionCount;
+ sal_Int32 nInterfaceAttributeTypeDescriptionCount;
+ sal_Int32 nInterfaceTypeDescriptionCount;
+ sal_Int32 nTypeDescriptionReferenceCount;
+#endif
+ ~TypeDescriptor_Init_Impl();
+};
+//__________________________________________________________________________________________________
+inline Mutex & TypeDescriptor_Init_Impl::getMutex()
+{
+ if( !pMutex )
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if( !pMutex )
+ pMutex = new Mutex();
+ }
+ return * pMutex;
+}
+//__________________________________________________________________________________________________
+inline void TypeDescriptor_Init_Impl::callChain(
+ typelib_TypeDescription ** ppRet, rtl_uString * pName )
+{
+ if (pCallbacks)
+ {
+ CallbackSet_Impl::const_iterator aIt = pCallbacks->begin();
+ while( aIt != pCallbacks->end() )
+ {
+ const CallbackEntry & rEntry = *aIt;
+ (*rEntry.second)( rEntry.first, ppRet, pName );
+ if( *ppRet )
+ return;
+ ++aIt;
+ }
+ }
+ if (*ppRet)
+ {
+ typelib_typedescription_release( *ppRet );
+ *ppRet = 0;
+ }
+}
+
+// never called
+#if defined(CPPU_LEAK_STATIC_DATA) && defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
+static void dumb_sunpro5_must_have_dtor_stl_hashmap_code_if_compiled_with_minus_g()
+{
+ delete (WeakMap_Impl *)0xbeef1e;
+}
+#endif
+//__________________________________________________________________________________________________
+TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl()
+{
+#ifndef CPPU_LEAK_STATIC_DATA
+ if( pCache )
+ {
+ TypeDescriptionList_Impl::const_iterator aIt = pCache->begin();
+ while( aIt != pCache->end() )
+ {
+ typelib_typedescription_release( (*aIt) );
+ aIt++;
+ }
+ delete pCache;
+ pCache = 0;
+ }
+
+ if( pWeakMap )
+ {
+ sal_Int32 nSize = pWeakMap->size();
+ typelib_TypeDescriptionReference ** ppTDR = new typelib_TypeDescriptionReference *[ nSize ];
+ // save al weak references
+ WeakMap_Impl::const_iterator aIt = pWeakMap->begin();
+ sal_Int32 i = 0;
+ while( aIt != pWeakMap->end() )
+ {
+ typelib_typedescriptionreference_acquire( ppTDR[i++] = (*aIt).second );
+ ++aIt;
+ }
+
+ for( i = 0; i < nSize; i++ )
+ {
+ sal_Int32 nStaticCounts = (sal_Int32)ppTDR[i]->pReserved;
+ OSL_ASSERT( ppTDR[i]->nRefCount > nStaticCounts );
+ ppTDR[i]->nRefCount -= nStaticCounts;
+
+ if( ppTDR[i]->pType && !ppTDR[i]->pType->bOnDemand )
+ {
+ ppTDR[i]->pType->bOnDemand = sal_True;
+ typelib_typedescription_release( ppTDR[i]->pType );
+ }
+ typelib_typedescriptionreference_release( ppTDR[i] );
+ }
+
+ delete[] ppTDR;
+
+#ifdef CPPU_ASSERTIONS
+ aIt = pWeakMap->begin();
+ while( aIt != pWeakMap->end() )
+ {
+ CPPU_TRACE( "\n" );
+ typelib_TypeDescriptionReference * pTDR = (*aIt).second;
+ if (pTDR)
+ {
+ OString aTypeName( OUStringToOString( pTDR->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
+ OString aRef( OString::valueOf( pTDR->nRefCount ) );
+ CPPU_TRACE( "### remaining type: " );
+ CPPU_TRACE( aTypeName.getStr() );
+ CPPU_TRACE( ", ref count = " );
+ CPPU_TRACE( aRef.getStr() );
+ }
+ else
+ {
+ CPPU_TRACE( "### remaining null type entry!?" );
+ }
+ ++aIt;
+ }
+#endif
+
+ delete pWeakMap;
+ pWeakMap = 0;
+ }
+#ifdef CPPU_ASSERTIONS
+ OSL_ASSERT( nTypeDescriptionCount == 0 );
+ OSL_ASSERT( nCompoundTypeDescriptionCount == 0 );
+ OSL_ASSERT( nUnionTypeDescriptionCount == 0 );
+ OSL_ASSERT( nIndirectTypeDescriptionCount == 0 );
+ OSL_ASSERT( nEnumTypeDescriptionCount == 0 );
+ OSL_ASSERT( nInterfaceMethodTypeDescriptionCount == 0 );
+ OSL_ASSERT( nInterfaceAttributeTypeDescriptionCount == 0 );
+ OSL_ASSERT( nInterfaceTypeDescriptionCount == 0 );
+ OSL_ASSERT( nTypeDescriptionReferenceCount == 0 );
+
+ OSL_ASSERT( !pCallbacks || pCallbacks->empty() );
+#endif
+ delete pCallbacks;
+ pCallbacks = 0;
+#endif // CPPU_LEAK_STATIC_DATA
+
+ // todo: maybe into leak block
+ if( pMutex )
+ {
+ delete pMutex;
+ pMutex = 0;
+ }
+};
+
+static TypeDescriptor_Init_Impl aInit;
+
+
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_registerCallback(
+ void * pContext, typelib_typedescription_Callback pCallback )
+{
+ // todo mt safe: guard is no solution, can not acquire while calling callback!
+// OslGuard aGuard( aInit.getMutex() );
+ if( !aInit.pCallbacks )
+ aInit.pCallbacks = new CallbackSet_Impl;
+ aInit.pCallbacks->push_back( CallbackEntry( pContext, pCallback ) );
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_revokeCallback(
+ void * pContext, typelib_typedescription_Callback pCallback )
+{
+ if( aInit.pCallbacks )
+ {
+ // todo mt safe: guard is no solution, can not acquire while calling callback!
+// OslGuard aGuard( aInit.getMutex() );
+ CallbackEntry aEntry( pContext, pCallback );
+ CallbackSet_Impl::iterator iPos( aInit.pCallbacks->begin() );
+ while (!(iPos == aInit.pCallbacks->end()))
+ {
+ if (*iPos == aEntry)
+ {
+ aInit.pCallbacks->erase( iPos );
+ iPos = aInit.pCallbacks->begin();
+ }
+ else
+ {
+ ++iPos;
+ }
+ }
+ }
+}
+
+
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+sal_Int32 SAL_CALL typelib_typedescription_getAlignedUnoSize(
+ const typelib_TypeDescription * pTypeDescription,
+ sal_Int32 nOffset,
+ sal_Int32 & rMaxIntegralTypeSize );
+
+//------------------------------------------------------------------------
+inline static void typelib_typedescription_initTables(
+ typelib_TypeDescription * pTD )
+{
+ typelib_InterfaceTypeDescription * pITD = (typelib_InterfaceTypeDescription *)pTD;
+ OSL_ASSERT( !pITD->nMapFunctionIndexToMemberIndex );
+ {
+ sal_Bool * pReadWriteAttributes = (sal_Bool *)alloca( pITD->nAllMembers );
+// {
+// MutexGuard aGuard( aInit.getMutex() );
+ for ( sal_Int32 i = pITD->nAllMembers; i--; )
+ {
+ pReadWriteAttributes[i] = sal_False;
+ if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pITD->ppAllMembers[i]->eTypeClass )
+ {
+ typelib_TypeDescription * pM = 0;
+ TYPELIB_DANGER_GET( &pM, pITD->ppAllMembers[i] );
+ OSL_ASSERT( pM );
+ if (pM)
+ {
+ pReadWriteAttributes[i] = !((typelib_InterfaceAttributeTypeDescription *)pM)->bReadOnly;
+ TYPELIB_DANGER_RELEASE( pM );
+ }
+#ifdef CPPU_ASSERTIONS
+ else
+ {
+ OString aStr( OUStringToOString( pITD->ppAllMembers[i]->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
+ CPPU_TRACE( "\n### cannot get attribute type description: " );
+ CPPU_TRACE( aStr.getStr() );
+ }
+#endif
+ }
+ }
+// }
+
+ if( !pITD->nMapFunctionIndexToMemberIndex )
+ {
+ // create the index table from member to function table
+ pITD->pMapMemberIndexToFunctionIndex = new sal_Int32[ pITD->nAllMembers ];
+ sal_Int32 nAdditionalOffset = 0; // +1 for read/write attributes
+ sal_Int32 i;
+ for( i = 0; i < pITD->nAllMembers; i++ )
+ {
+ // index to the get method of the attribute
+ pITD->pMapMemberIndexToFunctionIndex[i] = i + nAdditionalOffset;
+ // extra offset if it is a read/write attribute?
+ if( pReadWriteAttributes[i] )
+ {
+ // a read/write attribute
+ nAdditionalOffset++;
+ }
+ }
+
+ // create the index table from function to member table
+ pITD->pMapFunctionIndexToMemberIndex = new sal_Int32[ pITD->nAllMembers + nAdditionalOffset ];
+ nAdditionalOffset = 0; // +1 for read/write attributes
+ for( i = 0; i < pITD->nAllMembers; i++ )
+ {
+ // index to the get method of the attribute
+ pITD->pMapFunctionIndexToMemberIndex[i + nAdditionalOffset] = i;
+ // extra offset if it is a read/write attribute?
+ if( pReadWriteAttributes[i] )
+ {
+ // a read/write attribute
+ pITD->pMapFunctionIndexToMemberIndex[i + ++nAdditionalOffset] = i;
+ }
+ }
+ // must be the last action after all initialization is done
+ pITD->nMapFunctionIndexToMemberIndex = pITD->nAllMembers + nAdditionalOffset;
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL typelib_typedescription_newEmpty(
+ typelib_TypeDescription ** ppRet,
+ typelib_TypeClass eTypeClass,
+ rtl_uString * pTypeName )
+{
+ if( *ppRet )
+ {
+ typelib_typedescription_release( *ppRet );
+ *ppRet = 0;
+ }
+
+ OSL_ASSERT( typelib_TypeClass_TYPEDEF != eTypeClass );
+
+ typelib_TypeDescription * pRet;
+ switch( eTypeClass )
+ {
+ case typelib_TypeClass_ARRAY:
+ case typelib_TypeClass_SEQUENCE:
+ {
+ typelib_IndirectTypeDescription * pTmp = new typelib_IndirectTypeDescription();
+ pRet = (typelib_TypeDescription *)pTmp;
+#ifdef CPPU_ASSERTIONS
+ osl_incrementInterlockedCount( &aInit.nIndirectTypeDescriptionCount );
+#endif
+ pTmp->pType = 0;
+ }
+ break;
+
+ case typelib_TypeClass_UNION:
+ {
+ typelib_UnionTypeDescription * pTmp;
+ pTmp = new typelib_UnionTypeDescription();
+ pRet = (typelib_TypeDescription *)pTmp;
+#ifdef CPPU_ASSERTIONS
+ osl_incrementInterlockedCount( &aInit.nUnionTypeDescriptionCount );
+#endif
+ pTmp->nMembers = 0;
+ pTmp->pDiscriminantTypeRef = 0;
+ pTmp->pDiscriminants = 0;
+ pTmp->ppTypeRefs = 0;
+ pTmp->ppMemberNames = 0;
+ pTmp->pDefaultTypeRef = 0;
+ }
+ break;
+
+ case typelib_TypeClass_EXCEPTION:
+ case typelib_TypeClass_STRUCT:
+ {
+ // FEATURE_EMPTYCLASS
+ typelib_CompoundTypeDescription * pTmp;
+ pTmp = new typelib_CompoundTypeDescription();
+ pRet = (typelib_TypeDescription *)pTmp;
+#ifdef CPPU_ASSERTIONS
+ osl_incrementInterlockedCount( &aInit.nCompoundTypeDescriptionCount );
+#endif
+ pTmp->pBaseTypeDescription = 0;
+ pTmp->nMembers = 0;
+ pTmp->pMemberOffsets = 0;
+ pTmp->ppTypeRefs = 0;
+ pTmp->ppMemberNames = 0;
+ }
+ break;
+ case typelib_TypeClass_ENUM:
+ {
+ typelib_EnumTypeDescription * pTmp = new typelib_EnumTypeDescription();
+ pRet = (typelib_TypeDescription *)pTmp;
+#ifdef CPPU_ASSERTIONS
+ osl_incrementInterlockedCount( &aInit.nEnumTypeDescriptionCount );
+#endif
+ pTmp->nDefaultEnumValue = 0;
+ pTmp->nEnumValues = 0;
+ pTmp->ppEnumNames = 0;
+ pTmp->pEnumValues = 0;
+ }
+ break;
+
+ case typelib_TypeClass_INTERFACE:
+ {
+ typelib_InterfaceTypeDescription * pTmp = new typelib_InterfaceTypeDescription();
+ pRet = (typelib_TypeDescription *)pTmp;
+#ifdef CPPU_ASSERTIONS
+ osl_incrementInterlockedCount( &aInit.nInterfaceTypeDescriptionCount );
+#endif
+ pTmp->pBaseTypeDescription = 0;
+ pTmp->nMembers = 0;
+ pTmp->ppMembers = 0;
+ pTmp->nAllMembers = 0;
+ pTmp->ppAllMembers = 0;
+ pTmp->nMapFunctionIndexToMemberIndex = 0;
+ pTmp->pMapFunctionIndexToMemberIndex = 0;
+ pTmp->pMapMemberIndexToFunctionIndex= 0;
+ }
+ break;
+
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ typelib_InterfaceMethodTypeDescription * pTmp = new typelib_InterfaceMethodTypeDescription();
+ pRet = (typelib_TypeDescription *)pTmp;
+#ifdef CPPU_ASSERTIONS
+ osl_incrementInterlockedCount( &aInit.nInterfaceMethodTypeDescriptionCount );
+#endif
+ pTmp->aBase.pMemberName = 0;
+ pTmp->pReturnTypeRef = 0;
+ pTmp->nParams = 0;
+ pTmp->pParams = 0;
+ pTmp->nExceptions = 0;
+ pTmp->ppExceptions = 0;
+ }
+ break;
+
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ typelib_InterfaceAttributeTypeDescription * pTmp = new typelib_InterfaceAttributeTypeDescription();
+ pRet = (typelib_TypeDescription *)pTmp;
+#ifdef CPPU_ASSERTIONS
+ osl_incrementInterlockedCount( &aInit.nInterfaceAttributeTypeDescriptionCount );
+#endif
+ pTmp->aBase.pMemberName = 0;
+ pTmp->pAttributeTypeRef = 0;
+ }
+ break;
+
+ default:
+ {
+ pRet = new typelib_TypeDescription();
+#ifdef CPPU_ASSERTIONS
+ osl_incrementInterlockedCount( &aInit.nTypeDescriptionCount );
+#endif
+ }
+ }
+
+ pRet->nRefCount = 1; // reference count is initially 1
+ pRet->eTypeClass = eTypeClass;
+ pRet->pTypeName = 0;
+ pRet->pUniqueIdentifier = 0;
+ pRet->pReserved = 0;
+ rtl_uString_acquire( pRet->pTypeName = pTypeName );
+ pRet->pSelf = pRet;
+ pRet->bComplete = sal_True;
+ pRet->nSize = 0;
+ pRet->nAlignment = 0;
+ pRet->pWeakRef = 0;
+ pRet->bOnDemand = sal_False;
+ *ppRet = pRet;
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_new(
+ typelib_TypeDescription ** ppRet,
+ typelib_TypeClass eTypeClass,
+ rtl_uString * pTypeName,
+ typelib_TypeDescriptionReference * pType,
+ sal_Int32 nMembers,
+ typelib_CompoundMember_Init * pMembers )
+{
+ if (typelib_TypeClass_TYPEDEF == eTypeClass)
+ {
+ CPPU_TRACE( "### unexpected typedef!" );
+ typelib_typedescriptionreference_getDescription( ppRet, pType );
+ return;
+ }
+
+ typelib_typedescription_newEmpty( ppRet, eTypeClass, pTypeName );
+
+ switch( eTypeClass )
+ {
+ case typelib_TypeClass_ARRAY:
+ case typelib_TypeClass_SEQUENCE:
+ {
+ OSL_ASSERT( nMembers == 0 );
+ typelib_typedescriptionreference_acquire( pType );
+ ((typelib_IndirectTypeDescription *)*ppRet)->pType = pType;
+ }
+ break;
+
+ case typelib_TypeClass_EXCEPTION:
+ case typelib_TypeClass_STRUCT:
+ {
+ // FEATURE_EMPTYCLASS
+ typelib_CompoundTypeDescription * pTmp = (typelib_CompoundTypeDescription*)*ppRet;
+
+ sal_Int32 nOffset = 0;
+ if( pType )
+ {
+ typelib_typedescriptionreference_getDescription(
+ (typelib_TypeDescription **)&pTmp->pBaseTypeDescription, pType );
+ nOffset = ((typelib_TypeDescription *)pTmp->pBaseTypeDescription)->nSize;
+ OSL_ENSHURE( newAlignedSize( 0, ((typelib_TypeDescription *)pTmp->pBaseTypeDescription)->nSize, ((typelib_TypeDescription *)pTmp->pBaseTypeDescription)->nAlignment ) == ((typelib_TypeDescription *)pTmp->pBaseTypeDescription)->nSize, "### unexpected offset!" );
+ }
+ if( nMembers )
+ {
+ pTmp->nMembers = nMembers;
+ pTmp->pMemberOffsets = new sal_Int32[ nMembers ];
+ pTmp->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ];
+ pTmp->ppMemberNames = new rtl_uString *[ nMembers ];
+ for( sal_Int32 i = 0 ; i < nMembers; i++ )
+ {
+ // read the type name
+ pTmp->ppTypeRefs[i] = 0;
+ typelib_typedescriptionreference_new(
+ pTmp->ppTypeRefs +i, pMembers[i].eTypeClass, pMembers[i].pTypeName );
+ // read the member name
+ rtl_uString_acquire( pTmp->ppMemberNames[i] = pMembers[i].pMemberName );
+ // write offset
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, pTmp->ppTypeRefs[i] );
+ OSL_ENSHURE( pTD->nSize, "### void member?" );
+ nOffset = newAlignedSize( nOffset, pTD->nSize, pTD->nAlignment );
+ pTmp->pMemberOffsets[i] = nOffset - pTD->nSize;
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ }
+ }
+ }
+
+ if( !reallyWeak( eTypeClass ) )
+ (*ppRet)->pWeakRef = (typelib_TypeDescriptionReference *)*ppRet;
+ if( eTypeClass != typelib_TypeClass_VOID )
+ {
+ // sizeof( void ) not allowed
+ (*ppRet)->nSize = typelib_typedescription_getAlignedUnoSize( (*ppRet), 0, (*ppRet)->nAlignment );
+ (*ppRet)->nAlignment = adjustAlignment( (*ppRet)->nAlignment );
+ }
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newUnion(
+ typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ typelib_TypeDescriptionReference * pDiscriminantTypeRef,
+ sal_Int64 nDefaultDiscriminant,
+ typelib_TypeDescriptionReference * pDefaultTypeRef,
+ sal_Int32 nMembers,
+ typelib_Union_Init * pMembers )
+{
+ typelib_typedescription_newEmpty( ppRet, typelib_TypeClass_UNION, pTypeName );
+ // discriminant type
+ typelib_UnionTypeDescription * pTmp = (typelib_UnionTypeDescription *)*ppRet;
+ typelib_typedescriptionreference_acquire( pTmp->pDiscriminantTypeRef = pDiscriminantTypeRef );
+
+ sal_Int32 nPos;
+
+ pTmp->nMembers = nMembers;
+ // default discriminant
+ if (nMembers)
+ {
+ pTmp->pDiscriminants = new sal_Int64[ nMembers ];
+ for ( nPos = nMembers; nPos--; )
+ {
+ pTmp->pDiscriminants[nPos] = pMembers[nPos].nDiscriminant;
+ }
+ }
+ // default default discriminant
+ pTmp->nDefaultDiscriminant = nDefaultDiscriminant;
+
+ // union member types
+ pTmp->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ];
+ for ( nPos = nMembers; nPos--; )
+ {
+ typelib_typedescriptionreference_acquire( pTmp->ppTypeRefs[nPos] = pMembers[nPos].pTypeRef );
+ }
+ // union member names
+ pTmp->ppMemberNames = new rtl_uString *[ nMembers ];
+ for ( nPos = nMembers; nPos--; )
+ {
+ rtl_uString_acquire( pTmp->ppMemberNames[nPos] = pMembers[nPos].pMemberName );
+ }
+
+ // default union type
+ typelib_typedescriptionreference_acquire( pTmp->pDefaultTypeRef = pDefaultTypeRef );
+
+ if (! reallyWeak( typelib_TypeClass_UNION ))
+ (*ppRet)->pWeakRef = (typelib_TypeDescriptionReference *)*ppRet;
+ (*ppRet)->nSize = typelib_typedescription_getAlignedUnoSize( (*ppRet), 0, (*ppRet)->nAlignment );
+ (*ppRet)->nAlignment = adjustAlignment( (*ppRet)->nAlignment );
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newEnum(
+ typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ sal_Int32 nDefaultValue,
+ sal_Int32 nEnumValues,
+ rtl_uString ** ppEnumNames,
+ sal_Int32 * pEnumValues )
+{
+ typelib_typedescription_newEmpty( ppRet, typelib_TypeClass_ENUM, pTypeName );
+ typelib_EnumTypeDescription * pEnum = (typelib_EnumTypeDescription *)*ppRet;
+
+ pEnum->nDefaultEnumValue = nDefaultValue;
+ pEnum->nEnumValues = nEnumValues;
+ pEnum->ppEnumNames = new rtl_uString * [ nEnumValues ];
+ for ( sal_Int32 nPos = nEnumValues; nPos--; )
+ {
+ rtl_uString_acquire( pEnum->ppEnumNames[nPos] = ppEnumNames[nPos] );
+ }
+ pEnum->pEnumValues = new sal_Int32[ nEnumValues ];
+ ::memcpy( pEnum->pEnumValues, pEnumValues, nEnumValues * sizeof(sal_Int32) );
+
+ (*ppRet)->pWeakRef = (typelib_TypeDescriptionReference *)*ppRet;
+ // sizeof( void ) not allowed
+ (*ppRet)->nSize = typelib_typedescription_getAlignedUnoSize( (*ppRet), 0, (*ppRet)->nAlignment );
+ (*ppRet)->nAlignment = adjustAlignment( (*ppRet)->nAlignment );
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newInterface(
+ typelib_InterfaceTypeDescription ** ppRet,
+ rtl_uString * pTypeName,
+ sal_uInt32 nUik1, sal_uInt16 nUik2, sal_uInt16 nUik3, sal_uInt32 nUik4, sal_uInt32 nUik5,
+ typelib_TypeDescriptionReference * pBaseInterface,
+ sal_Int32 nMembers,
+ typelib_TypeDescriptionReference ** ppMembers )
+{
+ typelib_InterfaceTypeDescription * pITD = 0;
+ typelib_typedescription_newEmpty(
+ (typelib_TypeDescription **)&pITD, typelib_TypeClass_INTERFACE, pTypeName );
+
+ if( pBaseInterface )
+ {
+ // set the base interface, may be 0
+ ::typelib_typedescriptionreference_getDescription(
+ (typelib_TypeDescription **)&pITD->pBaseTypeDescription, pBaseInterface );
+ OSL_ASSERT( pITD->pBaseTypeDescription );
+ }
+ // set the
+ pITD->aUik.m_Data1 = nUik1;
+ pITD->aUik.m_Data2 = nUik2;
+ pITD->aUik.m_Data3 = nUik3;
+ pITD->aUik.m_Data4 = nUik4;
+ pITD->aUik.m_Data5 = nUik5;
+
+ sal_Int32 nSuperMembers = pITD->pBaseTypeDescription ? pITD->pBaseTypeDescription->nAllMembers : 0;
+ pITD->nAllMembers = nMembers + nSuperMembers;
+ pITD->nMembers = nMembers;
+
+ if( pITD->nAllMembers )
+ {
+ // at minimum one member exist, allocate the memory
+ pITD->ppAllMembers = new typelib_TypeDescriptionReference *[ pITD->nAllMembers ];
+ // the superclass references must not acquired
+ if( nSuperMembers )
+ {
+ rtl_moveMemory( pITD->ppAllMembers, pITD->pBaseTypeDescription->ppAllMembers,
+ nSuperMembers * sizeof( void * ) );
+ }
+
+ if( nMembers )
+ {
+ pITD->ppMembers = pITD->ppAllMembers + nSuperMembers;
+ }
+
+ sal_Int32 n = 0;
+ // add own members
+ for( sal_Int32 i = nSuperMembers; i < pITD->nAllMembers; i++ )
+ {
+ typelib_typedescriptionreference_acquire( ppMembers[n] );
+ pITD->ppAllMembers[i] = ppMembers[n];
+ ++n;
+ }
+ }
+
+ typelib_TypeDescription * pTmp = (typelib_TypeDescription *)pITD;
+ if( !reallyWeak( typelib_TypeClass_INTERFACE ) )
+ pTmp->pWeakRef = (typelib_TypeDescriptionReference *)pTmp;
+ pTmp->nSize = typelib_typedescription_getAlignedUnoSize( pTmp, 0, pTmp->nAlignment );
+ pTmp->nAlignment = adjustAlignment( pTmp->nAlignment );
+ pTmp->bComplete = sal_False;
+
+ if (*ppRet)
+ ::typelib_typedescription_release( (typelib_TypeDescription *)*ppRet );
+ *ppRet = pITD;
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newInterfaceMethod(
+ typelib_InterfaceMethodTypeDescription ** ppRet,
+ sal_Int32 nAbsolutePosition,
+ sal_Bool bOneWay,
+ rtl_uString * pTypeName,
+ typelib_TypeClass eReturnTypeClass,
+ rtl_uString * pReturnTypeName,
+ sal_Int32 nParams,
+ typelib_Parameter_Init * pParams,
+ sal_Int32 nExceptions,
+ rtl_uString ** ppExceptionNames )
+{
+ typelib_typedescription_newEmpty(
+ (typelib_TypeDescription **)ppRet, typelib_TypeClass_INTERFACE_METHOD, pTypeName );
+ typelib_TypeDescription * pTmp = (typelib_TypeDescription *)*ppRet;
+
+ sal_Int32 nOffset = rtl_ustr_lastIndexOfChar_WithLength(
+ pTypeName->buffer, pTypeName->length, ':' );
+
+ if( nOffset == -1 )
+ {
+ // not found
+ rtl_uString_acquire( (*ppRet)->aBase.pMemberName = pTypeName );
+ }
+ else
+ {
+ rtl_uString_newFromStr_WithLength( &(*ppRet)->aBase.pMemberName,
+ pTypeName->buffer + nOffset +1,
+ pTypeName->length - nOffset -1 );
+ }
+
+ (*ppRet)->aBase.nPosition = nAbsolutePosition;
+ (*ppRet)->bOneWay = bOneWay;
+ typelib_typedescriptionreference_new( &(*ppRet)->pReturnTypeRef, eReturnTypeClass, pReturnTypeName );
+ (*ppRet)->nParams = nParams;
+ (*ppRet)->nExceptions = nExceptions;
+ if( nParams )
+ {
+ (*ppRet)->pParams = new typelib_MethodParameter[ nParams ];
+
+ for( sal_Int32 i = 0; i < nParams; i++ )
+ {
+ // get the name of the parameter
+ (*ppRet)->pParams[ i ].pName = 0;
+ rtl_uString_acquire( (*ppRet)->pParams[ i ].pName = pParams[i].pParamName );
+ (*ppRet)->pParams[ i ].pTypeRef = 0;
+ // get the type name of the parameter and create the weak reference
+ typelib_typedescriptionreference_new(
+ &(*ppRet)->pParams[ i ].pTypeRef, pParams[i].eTypeClass, pParams[i].pTypeName );
+ (*ppRet)->pParams[ i ].bIn = pParams[i].bIn;
+ (*ppRet)->pParams[ i ].bOut = pParams[i].bOut;
+ }
+ }
+ if( nExceptions )
+ {
+ (*ppRet)->ppExceptions = new typelib_TypeDescriptionReference *[ nExceptions ];
+
+ for( sal_Int32 i = 0; i < nExceptions; i++ )
+ {
+ (*ppRet)->ppExceptions[i] = 0;
+ typelib_typedescriptionreference_new(
+ (*ppRet)->ppExceptions + i, typelib_TypeClass_EXCEPTION, ppExceptionNames[i] );
+ }
+ }
+ if( !reallyWeak( typelib_TypeClass_INTERFACE_METHOD ) )
+ pTmp->pWeakRef = (typelib_TypeDescriptionReference *)pTmp;
+}
+
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newInterfaceAttribute(
+ typelib_InterfaceAttributeTypeDescription ** ppRet,
+ sal_Int32 nAbsolutePosition,
+ rtl_uString * pTypeName,
+ typelib_TypeClass eAttributeTypeClass,
+ rtl_uString * pAttributeTypeName,
+ sal_Bool bReadOnly )
+{
+ typelib_typedescription_newEmpty(
+ (typelib_TypeDescription **)ppRet, typelib_TypeClass_INTERFACE_ATTRIBUTE, pTypeName );
+ typelib_TypeDescription * pTmp = (typelib_TypeDescription *)*ppRet;
+
+ sal_Int32 nOffset = rtl_ustr_lastIndexOfChar_WithLength(
+ pTypeName->buffer, pTypeName->length, ':' );
+
+ if( nOffset == -1 )
+ {
+ // not found
+ rtl_uString_acquire( (*ppRet)->aBase.pMemberName = pTypeName );
+ }
+ else
+ {
+ rtl_uString_newFromStr_WithLength( &(*ppRet)->aBase.pMemberName,
+ pTypeName->buffer + nOffset +1,
+ pTypeName->length - nOffset -1 );
+ }
+
+ (*ppRet)->aBase.nPosition = nAbsolutePosition;
+ typelib_typedescriptionreference_new( &(*ppRet)->pAttributeTypeRef, eAttributeTypeClass, pAttributeTypeName );
+ (*ppRet)->bReadOnly = bReadOnly;
+
+ if( !reallyWeak( typelib_TypeClass_INTERFACE_ATTRIBUTE ) )
+ pTmp->pWeakRef = (typelib_TypeDescriptionReference *)pTmp;
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_acquire(
+ typelib_TypeDescription * pTypeDescription )
+{
+ osl_incrementInterlockedCount( &pTypeDescription->nRefCount );
+}
+
+//------------------------------------------------------------------------
+// frees anything except typelib_TypeDescription base!
+static inline void typelib_typedescription_destructExtendedMembers(
+ typelib_TypeDescription * pTD )
+{
+ OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTD->eTypeClass );
+
+ switch( pTD->eTypeClass )
+ {
+ case typelib_TypeClass_ARRAY:
+ case typelib_TypeClass_SEQUENCE:
+ if( ((typelib_IndirectTypeDescription*)pTD)->pType )
+ typelib_typedescriptionreference_release( ((typelib_IndirectTypeDescription*)pTD)->pType );
+ break;
+ case typelib_TypeClass_UNION:
+ {
+ typelib_typedescriptionreference_release(
+ ((typelib_UnionTypeDescription *)pTD)->pDiscriminantTypeRef );
+ typelib_typedescriptionreference_release(
+ ((typelib_UnionTypeDescription *)pTD)->pDefaultTypeRef );
+ sal_Int32 nPos;
+ for ( nPos = ((typelib_UnionTypeDescription *)pTD)->nMembers; nPos--; )
+ {
+ typelib_typedescriptionreference_release(
+ ((typelib_UnionTypeDescription *)pTD)->ppTypeRefs[nPos] );
+ }
+
+ for ( nPos = ((typelib_UnionTypeDescription *)pTD)->nMembers; nPos--; )
+ {
+ rtl_uString_release(
+ ((typelib_UnionTypeDescription *)pTD)->ppMemberNames[nPos] );
+ }
+ delete [] ((typelib_UnionTypeDescription *)pTD)->ppMemberNames;
+ delete [] ((typelib_UnionTypeDescription *)pTD)->pDiscriminants;
+ delete [] ((typelib_UnionTypeDescription *)pTD)->ppTypeRefs;
+ }
+ break;
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_CompoundTypeDescription * pCTD = (typelib_CompoundTypeDescription*)pTD;
+ if( pCTD->pBaseTypeDescription )
+ typelib_typedescription_release( (typelib_TypeDescription *)pCTD->pBaseTypeDescription );
+ sal_Int32 i;
+ for( i = 0; i < pCTD->nMembers; i++ )
+ {
+ typelib_typedescriptionreference_release( pCTD->ppTypeRefs[i] );
+ }
+ if (pCTD->ppMemberNames)
+ {
+ for ( i = 0; i < pCTD->nMembers; i++ )
+ {
+ rtl_uString_release( pCTD->ppMemberNames[i] );
+ }
+ delete [] pCTD->ppMemberNames;
+ }
+ delete [] pCTD->ppTypeRefs;
+ delete [] pCTD->pMemberOffsets;
+ }
+ break;
+ case typelib_TypeClass_INTERFACE:
+ {
+ typelib_InterfaceTypeDescription * pITD = (typelib_InterfaceTypeDescription*)pTD;
+ // The members in this array are not allocated
+ sal_Int32 nSuperMembers = pITD->pBaseTypeDescription ? pITD->pBaseTypeDescription->nAllMembers : 0;
+ // release only the descriptions of this class and not the one of the superclass
+ for( sal_Int32 i = nSuperMembers; i < pITD->nAllMembers; i++ )
+ {
+ typelib_typedescriptionreference_release( pITD->ppAllMembers[i] );
+ }
+ delete [] pITD->ppAllMembers;
+ delete [] pITD->pMapMemberIndexToFunctionIndex;
+ delete [] pITD->pMapFunctionIndexToMemberIndex;
+ if (pITD->pBaseTypeDescription)
+ typelib_typedescription_release( (typelib_TypeDescription *)pITD->pBaseTypeDescription );
+ break;
+ }
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ typelib_InterfaceMethodTypeDescription * pIMTD = (typelib_InterfaceMethodTypeDescription*)pTD;
+ if( pIMTD->pReturnTypeRef )
+ typelib_typedescriptionreference_release( pIMTD->pReturnTypeRef );
+ sal_Int32 i;
+ for( i = 0; i < pIMTD->nParams; i++ )
+ {
+ rtl_uString_release( pIMTD->pParams[ i ].pName );
+ typelib_typedescriptionreference_release( pIMTD->pParams[ i ].pTypeRef );
+ }
+ delete [] pIMTD->pParams;
+ for( i = 0; i < pIMTD->nExceptions; i++ )
+ {
+ typelib_typedescriptionreference_release( pIMTD->ppExceptions[ i ] );
+ }
+ delete [] pIMTD->ppExceptions;
+ rtl_uString_release( pIMTD->aBase.pMemberName );
+ }
+ break;
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ typelib_InterfaceAttributeTypeDescription * pIATD = (typelib_InterfaceAttributeTypeDescription*)pTD;
+ if( pIATD->pAttributeTypeRef )
+ typelib_typedescriptionreference_release( pIATD->pAttributeTypeRef );
+ if( pIATD->aBase.pMemberName )
+ rtl_uString_release( pIATD->aBase.pMemberName );
+ }
+ break;
+ case typelib_TypeClass_ENUM:
+ {
+ typelib_EnumTypeDescription * pEnum = (typelib_EnumTypeDescription *)pTD;
+ for ( sal_Int32 nPos = pEnum->nEnumValues; nPos--; )
+ {
+ rtl_uString_release( pEnum->ppEnumNames[nPos] );
+ }
+ delete [] pEnum->ppEnumNames;
+ delete [] pEnum->pEnumValues;
+ }
+ break;
+ }
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_release(
+ typelib_TypeDescription * pTD )
+{
+ OSL_ASSERT(pTD->nRefCount > 0);
+
+ if( !osl_decrementInterlockedCount( &pTD->nRefCount ) )
+ {
+ if( reallyWeak( pTD->eTypeClass ) )
+ {
+ if( pTD->pWeakRef )
+ {
+ {
+ MutexGuard aGuard( aInit.getMutex() );
+ // remove this description from the weak reference
+ pTD->pWeakRef->pType = 0;
+ }
+ typelib_typedescriptionreference_release( pTD->pWeakRef );
+ }
+ }
+ else
+ {
+ // this description is a reference too, so remove it from the hash table
+ if( aInit.pWeakMap )
+ {
+ MutexGuard aGuard( aInit.getMutex() );
+ WeakMap_Impl::iterator aIt = aInit.pWeakMap->find( (sal_Unicode*)pTD->pTypeName->buffer );
+ if( aIt != aInit.pWeakMap->end() && (void *)(*aIt).second == (void *)pTD )
+ {
+ // remove only if it contains the same object
+ aInit.pWeakMap->erase( aIt );
+ }
+ }
+ }
+
+ typelib_typedescription_destructExtendedMembers( pTD );
+ rtl_uString_release( pTD->pTypeName );
+
+#ifdef CPPU_ASSERTIONS
+ switch( pTD->eTypeClass )
+ {
+ case typelib_TypeClass_ARRAY:
+ case typelib_TypeClass_SEQUENCE:
+ osl_decrementInterlockedCount( &aInit.nIndirectTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_UNION:
+ osl_decrementInterlockedCount( &aInit.nUnionTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ osl_decrementInterlockedCount( &aInit.nCompoundTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_INTERFACE:
+ osl_decrementInterlockedCount( &aInit.nInterfaceTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_INTERFACE_METHOD:
+ osl_decrementInterlockedCount( &aInit.nInterfaceMethodTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ osl_decrementInterlockedCount( &aInit.nInterfaceAttributeTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_ENUM:
+ osl_decrementInterlockedCount( &aInit.nEnumTypeDescriptionCount );
+ break;
+ default:
+ osl_decrementInterlockedCount( &aInit.nTypeDescriptionCount );
+ }
+#endif
+
+ delete pTD;
+ }
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_register(
+ typelib_TypeDescription ** ppNewDescription )
+{
+ // connect the description with the weak reference
+ ClearableMutexGuard aGuard( aInit.getMutex() );
+
+ typelib_TypeDescriptionReference * pTDR = 0;
+ typelib_typedescriptionreference_getByName( &pTDR, (*ppNewDescription)->pTypeName );
+
+ OSL_ASSERT( (*ppNewDescription)->pWeakRef || reallyWeak( (*ppNewDescription)->eTypeClass ) );
+ if( pTDR )
+ {
+ OSL_ASSERT( (*ppNewDescription)->eTypeClass == pTDR->eTypeClass );
+ if( pTDR->pType )
+ {
+ if (reallyWeak( pTDR->eTypeClass ))
+ {
+ // pRef->pType->pWeakRef == 0 means that the description is empty
+ if (pTDR->pType->pWeakRef)
+ {
+ if (osl_incrementInterlockedCount( &pTDR->pType->nRefCount ) > 1)
+ {
+ // The refence is incremented. The object cannot be destroyed.
+ // Release the guard at the earliest point.
+ aGuard.clear();
+ ::typelib_typedescription_release( *ppNewDescription );
+ *ppNewDescription = pTDR->pType;
+ ::typelib_typedescriptionreference_release( pTDR );
+ return;
+ }
+ else
+ {
+ // destruction of this type in progress (another thread!)
+ osl_decrementInterlockedCount( &pTDR->pType->nRefCount );
+ }
+ }
+ // take new descr
+ pTDR->pType = *ppNewDescription;
+ OSL_ASSERT( ! (*ppNewDescription)->pWeakRef );
+ (*ppNewDescription)->pWeakRef = pTDR;
+ return;
+ }
+ // !reallyWeak
+
+ if (((void *)pTDR != (void *)*ppNewDescription) && // if different
+ (!pTDR->pType->pWeakRef || // uninit: ref data only set
+ // new one is complete:
+ (!pTDR->pType->bComplete && (*ppNewDescription)->bComplete) ||
+ // new one may be partly initialized interface (except of tables):
+ (typelib_TypeClass_INTERFACE == pTDR->pType->eTypeClass &&
+ !((typelib_InterfaceTypeDescription *)pTDR->pType)->ppAllMembers &&
+ (*(typelib_InterfaceTypeDescription **)ppNewDescription)->ppAllMembers)))
+ {
+ // uninitialized or incomplete
+
+ if (pTDR->pType->pWeakRef) // if init
+ {
+ typelib_typedescription_destructExtendedMembers( pTDR->pType );
+ }
+
+ // pTDR->pType->pWeakRef == 0 means that the description is empty
+ // description is not weak and the not the same
+ sal_Int32 nSize = getDescriptionSize( (*ppNewDescription)->eTypeClass );
+
+ // copy all specific data for the descriptions
+ ::rtl_copyMemory(
+ pTDR->pType +1,
+ *ppNewDescription +1,
+ nSize - sizeof(typelib_TypeDescription) );
+
+ pTDR->pType->bComplete = (*ppNewDescription)->bComplete;
+ pTDR->pType->nSize = (*ppNewDescription)->nSize;
+ pTDR->pType->nAlignment = (*ppNewDescription)->nAlignment;
+
+ ::rtl_zeroMemory(
+ *ppNewDescription +1, nSize - sizeof( typelib_TypeDescription ) );
+
+ if( pTDR->pType->bOnDemand && !(*ppNewDescription)->bOnDemand )
+ {
+ // switch from OnDemand to !OnDemand, so the description must be acquired
+ typelib_typedescription_acquire( pTDR->pType );
+ }
+ else if( !pTDR->pType->bOnDemand && (*ppNewDescription)->bOnDemand )
+ {
+ // switch from !OnDemand to OnDemand, so the description must be relesed
+ typelib_typedescription_release( pTDR->pType );
+ }
+
+ pTDR->pType->bOnDemand = (*ppNewDescription)->bOnDemand;
+ // initialized
+ pTDR->pType->pWeakRef = pTDR;
+ }
+
+ typelib_typedescription_release( *ppNewDescription );
+ // pTDR was acquired by getByName(), so it must not be acquired again
+ *ppNewDescription = pTDR->pType;
+ return;
+ }
+ }
+ else if( reallyWeak( (*ppNewDescription)->eTypeClass) )
+ {
+ typelib_typedescriptionreference_new(
+ &pTDR, (*ppNewDescription)->eTypeClass, (*ppNewDescription)->pTypeName );
+ }
+ else
+ {
+ pTDR = (typelib_TypeDescriptionReference *)*ppNewDescription;
+ if( !aInit.pWeakMap )
+ aInit.pWeakMap = new WeakMap_Impl;
+
+ // description is the weak itself, so register it
+ (*aInit.pWeakMap)[pTDR->pTypeName->buffer] = pTDR;
+ OSL_ASSERT( (void *)*ppNewDescription == (void *)pTDR );
+ }
+
+ // By default this reference is not really weak. The reference hold the description
+ // and the description hold the reference.
+ if( !(*ppNewDescription)->bOnDemand )
+ {
+ // nor OnDemand so the description must be acquired if registered
+ typelib_typedescription_acquire( *ppNewDescription );
+ }
+
+ pTDR->pType = *ppNewDescription;
+ (*ppNewDescription)->pWeakRef = pTDR;
+ OSL_ASSERT( rtl_ustr_compare( pTDR->pTypeName->buffer, (*ppNewDescription)->pTypeName->buffer ) == 0 );
+ OSL_ASSERT( pTDR->eTypeClass == (*ppNewDescription)->eTypeClass );
+}
+
+//------------------------------------------------------------------------
+inline static sal_Bool type_equals(
+ typelib_TypeDescriptionReference * p1, typelib_TypeDescriptionReference * p2 )
+{
+ return (p1 == p2 ||
+ (p1->eTypeClass == p2->eTypeClass &&
+ p1->pTypeName->length == p2->pTypeName->length &&
+ rtl_ustr_compare( p1->pTypeName->buffer, p2->pTypeName->buffer ) == 0));
+}
+extern "C" SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescription_equals(
+ const typelib_TypeDescription * p1, const typelib_TypeDescription * p2 )
+{
+ return type_equals(
+ (typelib_TypeDescriptionReference *)p1, (typelib_TypeDescriptionReference *)p2 );
+}
+
+//------------------------------------------------------------------------
+sal_Int32 SAL_CALL typelib_typedescription_getAlignedUnoSize(
+ const typelib_TypeDescription * pTypeDescription,
+ sal_Int32 nOffset,
+ sal_Int32 & rMaxIntegralTypeSize )
+{
+ sal_Int32 nSize;
+ if( pTypeDescription->nSize )
+ {
+ // size and alignment are set
+ rMaxIntegralTypeSize = pTypeDescription->nAlignment;
+ nSize = pTypeDescription->nSize;
+ }
+ else
+ {
+ nSize = 0;
+ rMaxIntegralTypeSize = 1;
+
+ OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTypeDescription->eTypeClass );
+
+ switch( pTypeDescription->eTypeClass )
+ {
+ case typelib_TypeClass_INTERFACE:
+ // FEATURE_INTERFACE
+ nSize = rMaxIntegralTypeSize = sizeof( void * );
+ break;
+ case typelib_TypeClass_UNION:
+ {
+ nSize = rMaxIntegralTypeSize = sizeof(sal_Int64);
+ for ( sal_Int32 nPos = ((typelib_UnionTypeDescription *)pTypeDescription)->nMembers; nPos--; )
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, ((typelib_UnionTypeDescription *)pTypeDescription)->ppTypeRefs[nPos] );
+ sal_Int32 nMaxIntegralTypeSize;
+ sal_Int32 nMemberSize = typelib_typedescription_getAlignedUnoSize( pTD, sizeof(sal_Int64), nMaxIntegralTypeSize );
+ TYPELIB_DANGER_RELEASE( pTD );
+ if (nSize < nMemberSize)
+ nSize = nMemberSize;
+ if (rMaxIntegralTypeSize < nMaxIntegralTypeSize)
+ rMaxIntegralTypeSize = nMaxIntegralTypeSize;
+ }
+ ((typelib_UnionTypeDescription *)pTypeDescription)->nValueOffset = rMaxIntegralTypeSize;
+ }
+ break;
+ case typelib_TypeClass_ENUM:
+ nSize = rMaxIntegralTypeSize = sizeof( typelib_TypeClass );
+ break;
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ // FEATURE_EMPTYCLASS
+ {
+ typelib_CompoundTypeDescription * pTmp = (typelib_CompoundTypeDescription *)pTypeDescription;
+ sal_Int32 nStructSize = 0;
+ if( pTmp->pBaseTypeDescription )
+ {
+ // inherit structs extends the base struct.
+ nStructSize = pTmp->pBaseTypeDescription->aBase.nSize;
+ rMaxIntegralTypeSize = pTmp->pBaseTypeDescription->aBase.nAlignment;
+ }
+ for( sal_Int32 i = 0; i < pTmp->nMembers; i++ )
+ {
+ typelib_TypeDescription * pMemberType = 0;
+ typelib_TypeDescriptionReference * pMemberRef = pTmp->ppTypeRefs[i];
+
+ sal_Int32 nMaxIntegral;
+ if (pMemberRef->eTypeClass == typelib_TypeClass_INTERFACE ||
+ pMemberRef->eTypeClass == typelib_TypeClass_SEQUENCE)
+ {
+ nMaxIntegral = sizeof(void *);
+ nStructSize = newAlignedSize( nStructSize, nMaxIntegral, nMaxIntegral );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pMemberType, pMemberRef );
+ nStructSize = typelib_typedescription_getAlignedUnoSize(
+ pMemberType, nStructSize, nMaxIntegral );
+ TYPELIB_DANGER_RELEASE( pMemberType );
+ }
+ if( nMaxIntegral > rMaxIntegralTypeSize )
+ rMaxIntegralTypeSize = nMaxIntegral;
+ }
+ // Example: A { double; int; } structure has a size of 16 instead of 10. The
+ // compiler must follow this rule if it is possible to access memvers in arrays through:
+ // (Element *)((char *)pArray + sizeof( Element ) * ElementPos)
+ nStructSize = (nStructSize + rMaxIntegralTypeSize -1)
+ / rMaxIntegralTypeSize * rMaxIntegralTypeSize;
+ nSize += nStructSize;
+ }
+ break;
+ case typelib_TypeClass_ARRAY:
+ OSL_ENSHURE( sal_False, "not implemented" );
+ break;
+ case typelib_TypeClass_SEQUENCE:
+ nSize = rMaxIntegralTypeSize = sizeof( void * );
+ break;
+ case typelib_TypeClass_ANY:
+ // FEATURE_ANY
+ nSize = sizeof( uno_Any );
+ rMaxIntegralTypeSize = sizeof( void * );
+ break;
+ case typelib_TypeClass_TYPE:
+ nSize = rMaxIntegralTypeSize = sizeof( typelib_TypeDescriptionReference * );
+ break;
+ case typelib_TypeClass_BOOLEAN:
+ nSize = rMaxIntegralTypeSize = sizeof( sal_Bool );
+ break;
+ case typelib_TypeClass_CHAR:
+ nSize = rMaxIntegralTypeSize = sizeof( sal_Unicode );
+ break;
+ case typelib_TypeClass_STRING:
+ // FEATURE_STRING
+ nSize = rMaxIntegralTypeSize = sizeof( rtl_uString * );
+ break;
+ case typelib_TypeClass_FLOAT:
+ nSize = rMaxIntegralTypeSize = sizeof( float );
+ break;
+ case typelib_TypeClass_DOUBLE:
+ nSize = rMaxIntegralTypeSize = sizeof( double );
+ break;
+
+ case typelib_TypeClass_BYTE:
+ nSize = rMaxIntegralTypeSize = sizeof( sal_Int8 );
+ break;
+
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ nSize = rMaxIntegralTypeSize = sizeof( sal_Int16 );
+ break;
+
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ nSize = rMaxIntegralTypeSize = sizeof( sal_Int32 );
+ break;
+
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ nSize = rMaxIntegralTypeSize = sizeof( sal_Int64 );
+ break;
+
+ case typelib_TypeClass_UNKNOWN:
+ case typelib_TypeClass_SERVICE:
+ case typelib_TypeClass_MODULE:
+ default:
+ OSL_ENSHURE( sal_False, "not convertable type" );
+ };
+ }
+
+ return newAlignedSize( nOffset, nSize, rMaxIntegralTypeSize );
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescription_getByName(
+ typelib_TypeDescription ** ppRet, rtl_uString * pName )
+{
+ if( *ppRet )
+ {
+ typelib_typedescription_release( (*ppRet) );
+ *ppRet = 0;
+ }
+
+ static sal_Bool bInited = sal_False;
+
+ if( !bInited )
+ {
+ // guard against multi thread access
+ MutexGuard aGuard( aInit.getMutex() );
+ if( !bInited )
+ {
+ // avoid recursion during the next ...new calls
+ bInited = sal_True;
+
+ rtl_uString * pTypeName = 0;
+ typelib_TypeDescription * pType = 0;
+ rtl_uString_newFromAscii( &pTypeName, "type" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_TYPE, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "void" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_VOID, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "boolean" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_BOOLEAN, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "char" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_CHAR, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "byte" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_BYTE, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "string" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_STRING, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "short" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_SHORT, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "unsigned short" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_UNSIGNED_SHORT, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "long" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_LONG, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "unsigned long" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_UNSIGNED_LONG, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "hyper" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_HYPER, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "unsigned hyper" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_UNSIGNED_HYPER, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "float" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_FLOAT, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "double" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_DOUBLE, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ rtl_uString_newFromAscii( &pTypeName, "any" );
+ typelib_typedescription_new( &pType, typelib_TypeClass_ANY, pTypeName, 0, 0, 0 );
+ typelib_typedescription_register( &pType );
+ typelib_typedescription_release( pType );
+ rtl_uString_release( pTypeName );
+ }
+ }
+
+ typelib_TypeDescriptionReference * pTDR = 0;
+ typelib_typedescriptionreference_getByName( &pTDR, pName );
+ if( pTDR )
+ {
+ {
+ // guard against multi thread access
+ MutexGuard aGuard( aInit.getMutex() );
+ // pTDR->pType->pWeakRef == 0 means that the description is empty
+ if( pTDR->pType && pTDR->pType->pWeakRef )
+ {
+ typelib_typedescription_acquire( pTDR->pType );
+ *ppRet = pTDR->pType;
+ }
+ }
+ typelib_typedescriptionreference_release( pTDR );
+ }
+
+ if( !*ppRet )
+ {
+ // on demand access
+ aInit.callChain( ppRet, pName );
+ if( *ppRet )
+ {
+ // typedescription found
+ if (typelib_TypeClass_TYPEDEF == (*ppRet)->eTypeClass)
+ {
+ typelib_TypeDescription * pTD = 0;
+ typelib_typedescriptionreference_getDescription(
+ &pTD, ((typelib_IndirectTypeDescription *)*ppRet)->pType );
+ typelib_typedescription_release( *ppRet );
+ *ppRet = pTD;
+ }
+ else
+ {
+ // set to on demand
+ (*ppRet)->bOnDemand = sal_True;
+ // The type description is hold by the reference until
+ // on demand is activated.
+ typelib_typedescription_register( ppRet );
+
+ // insert into the chache
+ MutexGuard aGuard( aInit.getMutex() );
+ if( !aInit.pCache )
+ aInit.pCache = new TypeDescriptionList_Impl;
+ if( aInit.pCache->size() >= nCacheSize )
+ {
+ typelib_typedescription_release( aInit.pCache->front() );
+ aInit.pCache->pop_front();
+ }
+ // descriptions in the cache must be acquired!
+ typelib_typedescription_acquire( *ppRet );
+ aInit.pCache->push_back( *ppRet );
+ }
+ }
+ }
+}
+
+
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_newByAsciiName(
+ typelib_TypeDescriptionReference ** ppTDR,
+ typelib_TypeClass eTypeClass,
+ const sal_Char * pTypeName )
+{
+ OUString aTypeName( OUString::createFromAscii( pTypeName ) );
+ typelib_typedescriptionreference_new( ppTDR, eTypeClass, aTypeName.pData );
+}
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_new(
+ typelib_TypeDescriptionReference ** ppTDR,
+ typelib_TypeClass eTypeClass,
+ rtl_uString * pTypeName )
+{
+ if( eTypeClass == typelib_TypeClass_TYPEDEF )
+ {
+ // on demand access
+ typelib_TypeDescription * pRet = 0;
+ aInit.callChain( &pRet, pTypeName );
+ if( pRet )
+ {
+ // typedescription found
+ if (typelib_TypeClass_TYPEDEF == pRet->eTypeClass)
+ {
+ typelib_typedescriptionreference_acquire(
+ ((typelib_IndirectTypeDescription *)pRet)->pType );
+ if (*ppTDR)
+ typelib_typedescriptionreference_release( *ppTDR );
+ *ppTDR = ((typelib_IndirectTypeDescription *)pRet)->pType;
+ typelib_typedescription_release( pRet );
+ }
+ else
+ {
+ // set to on demand
+ pRet->bOnDemand = sal_True;
+ // The type description is hold by the reference until
+ // on demand is activated.
+ typelib_typedescription_register( &pRet );
+
+ // insert into the chache
+ MutexGuard aGuard( aInit.getMutex() );
+ if( !aInit.pCache )
+ aInit.pCache = new TypeDescriptionList_Impl;
+ if( aInit.pCache->size() >= nCacheSize )
+ {
+ typelib_typedescription_release( aInit.pCache->front() );
+ aInit.pCache->pop_front();
+ }
+ aInit.pCache->push_back( pRet );
+ // pRet kept acquired for cache
+
+ typelib_typedescriptionreference_acquire( pRet->pWeakRef );
+ if (*ppTDR)
+ typelib_typedescriptionreference_release( *ppTDR );
+ *ppTDR = pRet->pWeakRef;
+ }
+ }
+ else if (*ppTDR)
+ {
+#ifdef CPPU_ASSERTIONS
+ OString aStr( OUStringToOString( pTypeName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( !"### typedef not found: ", aStr.getStr() );
+#endif
+ typelib_typedescriptionreference_release( *ppTDR );
+ *ppTDR = 0;
+ }
+ return;
+ }
+
+ MutexGuard aGuard( aInit.getMutex() );
+ typelib_typedescriptionreference_getByName( ppTDR, pTypeName );
+ if( *ppTDR )
+ return;
+
+ if( reallyWeak( eTypeClass ) )
+ {
+ typelib_TypeDescriptionReference * pTDR = new typelib_TypeDescriptionReference();
+#ifdef CPPU_ASSERTIONS
+ osl_incrementInterlockedCount( &aInit.nTypeDescriptionReferenceCount );
+#endif
+ pTDR->nRefCount = 1;
+ pTDR->eTypeClass = eTypeClass;
+ pTDR->pUniqueIdentifier = 0;
+ pTDR->pReserved = 0;
+ rtl_uString_acquire( pTDR->pTypeName = pTypeName );
+ pTDR->pType = 0;
+ *ppTDR = pTDR;
+ }
+ else
+ {
+ typelib_typedescription_newEmpty( (typelib_TypeDescription ** )ppTDR, eTypeClass, pTypeName );
+ // description will be registered but not acquired
+ (*(typelib_TypeDescription ** )ppTDR)->bOnDemand = sal_True;
+ (*(typelib_TypeDescription ** )ppTDR)->bComplete = sal_False;
+ }
+
+ if( !aInit.pWeakMap )
+ aInit.pWeakMap = new WeakMap_Impl;
+ // Heavy hack, the const sal_Unicode * is hold by the typedescription reference
+ // not registered
+ aInit.pWeakMap->operator[]( (*ppTDR)->pTypeName->buffer ) = *ppTDR;
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_acquire(
+ typelib_TypeDescriptionReference * pRef )
+{
+ osl_incrementInterlockedCount( &pRef->nRefCount );
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_release(
+ typelib_TypeDescriptionReference * pRef )
+{
+ // Is it a type description?
+ if( reallyWeak( pRef->eTypeClass ) )
+ {
+ if( !osl_decrementInterlockedCount( &pRef->nRefCount ) )
+ {
+ if( aInit.pWeakMap )
+ {
+ MutexGuard aGuard( aInit.getMutex() );
+ WeakMap_Impl::iterator aIt = aInit.pWeakMap->find( (sal_Unicode*)pRef->pTypeName->buffer );
+ if( !(aIt == aInit.pWeakMap->end()) && (*aIt).second == pRef )
+ {
+ // remove only if it contains the same object
+ aInit.pWeakMap->erase( aIt );
+ }
+ }
+
+ rtl_uString_release( pRef->pTypeName );
+ OSL_ASSERT( pRef->pType == 0 );
+#ifdef CPPU_ASSERTIONS
+ osl_decrementInterlockedCount( &aInit.nTypeDescriptionReferenceCount );
+#endif
+ delete pRef;
+ }
+ }
+ else
+ {
+ typelib_typedescription_release( (typelib_TypeDescription *)pRef );
+ }
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_getDescription(
+ typelib_TypeDescription ** ppRet,
+ typelib_TypeDescriptionReference * pRef )
+{
+ if( *ppRet )
+ {
+ typelib_typedescription_release( *ppRet );
+ *ppRet = 0;
+ }
+
+ if( !reallyWeak( pRef->eTypeClass ) && pRef->pType && pRef->pType->pWeakRef )
+ {
+ // reference is a description and initialized
+ osl_incrementInterlockedCount( &((typelib_TypeDescription *)pRef)->nRefCount );
+ *ppRet = (typelib_TypeDescription *)pRef;
+ return;
+ }
+
+ {
+ MutexGuard aGuard( aInit.getMutex() );
+ // pRef->pType->pWeakRef == 0 means that the description is empty
+ if( pRef->pType && pRef->pType->pWeakRef )
+ {
+ sal_Int32 n = osl_incrementInterlockedCount( &pRef->pType->nRefCount );
+ if( n > 1 )
+ {
+ // The refence is incremented. The object cannot be destroyed.
+ // Release the guard at the earliest point.
+ *ppRet = pRef->pType;
+ return;
+ }
+ else
+ {
+ osl_decrementInterlockedCount( &pRef->pType->nRefCount );
+ // detruction of this type in progress (another thread!)
+ // no acces through this weak reference
+ pRef->pType = 0;
+ }
+ }
+ }
+
+ typelib_typedescription_getByName( ppRet, pRef->pTypeName );
+ OSL_ASSERT( !*ppRet || rtl_ustr_compare( pRef->pTypeName->buffer, (*ppRet)->pTypeName->buffer ) == 0 );
+ OSL_ASSERT( !*ppRet || pRef->eTypeClass == (*ppRet)->eTypeClass );
+ OSL_ASSERT( !*ppRet || pRef == (*ppRet)->pWeakRef );
+ pRef->pType = *ppRet;
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL typelib_typedescriptionreference_getByName(
+ typelib_TypeDescriptionReference ** ppRet,
+ rtl_uString * pName )
+{
+ if( *ppRet )
+ {
+ typelib_typedescriptionreference_release( *ppRet );
+ *ppRet = 0;
+ }
+ if( aInit.pWeakMap )
+ {
+ MutexGuard aGuard( aInit.getMutex() );
+ WeakMap_Impl::const_iterator aIt = aInit.pWeakMap->find( (sal_Unicode*)pName->buffer );
+ if( !(aIt == aInit.pWeakMap->end()) ) // != failed on msc4.2
+ {
+ sal_Int32 n = osl_incrementInterlockedCount( &(*aIt).second->nRefCount );
+ if( n > 1 )
+ // The refence is incremented. The object cannot be destroyed.
+ // Release the guard at the earliest point.
+ *ppRet = (*aIt).second;
+ else
+ // detruction of this type in progress (another thread!)
+ // no acces through this weak reference
+ osl_decrementInterlockedCount( &(*aIt).second->nRefCount );
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+extern "C" SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescriptionreference_equals(
+ const typelib_TypeDescriptionReference * p1,
+ const typelib_TypeDescriptionReference * p2 )
+{
+ return (p1 == p2 ||
+ (p1->eTypeClass == p2->eTypeClass &&
+ p1->pTypeName->length == p2->pTypeName->length &&
+ rtl_ustr_compare( p1->pTypeName->buffer, p2->pTypeName->buffer ) == 0));
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_assign(
+ typelib_TypeDescriptionReference ** ppDest,
+ typelib_TypeDescriptionReference * pSource )
+{
+ if (*ppDest != pSource)
+ {
+ ::typelib_typedescriptionreference_acquire( pSource );
+ ::typelib_typedescriptionreference_release( *ppDest );
+ *ppDest = pSource;
+ }
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL typelib_setCacheSize( sal_Int32 nNewSize )
+{
+ OSL_ENSHURE( nNewSize >= 0, "### illegal cache size given!" );
+ if (nNewSize >= 0)
+ {
+ MutexGuard aGuard( aInit.getMutex() );
+ if ((nNewSize < nCacheSize) && aInit.pCache)
+ {
+ while (aInit.pCache->size() != nNewSize)
+ {
+ typelib_typedescription_release( aInit.pCache->front() );
+ aInit.pCache->pop_front();
+ }
+ }
+ nCacheSize = nNewSize;
+ }
+}
+
+
+static sal_Bool s_aAssignableFromTab[11][11] =
+{
+ /* from CH,BO,BY,SH,US,LO,UL,HY,UH,FL,DO */
+/* TypeClass_CHAR */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_BOOLEAN */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_BYTE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_UNSIGNED_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+/* TypeClass_UNSIGNED_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+/* TypeClass_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
+/* TypeClass_UNSIGNED_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
+/* TypeClass_FLOAT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0 },
+/* TypeClass_DOUBLE */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1 }
+};
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescriptionreference_isAssignableFrom(
+ typelib_TypeDescriptionReference * pAssignable,
+ typelib_TypeDescriptionReference * pFrom )
+{
+ if (pAssignable && pFrom)
+ {
+ typelib_TypeClass eAssignable = pAssignable->eTypeClass;
+ typelib_TypeClass eFrom = pFrom->eTypeClass;
+
+ if (eAssignable == typelib_TypeClass_ANY) // anything can be assigned to an any .)
+ return sal_True;
+ if (eAssignable == eFrom)
+ {
+ if (type_equals( pAssignable, pFrom )) // first shot
+ {
+ return sal_True;
+ }
+ else
+ {
+ switch (eAssignable)
+ {
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pFromDescr = 0;
+ TYPELIB_DANGER_GET( &pFromDescr, pFrom );
+ if (! ((typelib_CompoundTypeDescription *)pFromDescr)->pBaseTypeDescription)
+ {
+ TYPELIB_DANGER_RELEASE( pFromDescr );
+ return sal_False;
+ }
+ sal_Bool bRet = typelib_typedescriptionreference_isAssignableFrom(
+ pAssignable,
+ ((typelib_TypeDescription *)((typelib_CompoundTypeDescription *)pFromDescr)->pBaseTypeDescription)->pWeakRef );
+ TYPELIB_DANGER_RELEASE( pFromDescr );
+ return bRet;
+ }
+ case typelib_TypeClass_INTERFACE:
+ {
+ typelib_TypeDescription * pFromDescr = 0;
+ TYPELIB_DANGER_GET( &pFromDescr, pFrom );
+ if ( !((typelib_InterfaceTypeDescription *)pFromDescr)->pBaseTypeDescription )
+ {
+ TYPELIB_DANGER_RELEASE( pFromDescr );
+ return sal_False;
+ }
+ sal_Bool bRet = typelib_typedescriptionreference_isAssignableFrom(
+ pAssignable,
+ ((typelib_TypeDescription *)((typelib_InterfaceTypeDescription *)pFromDescr)->pBaseTypeDescription)->pWeakRef );
+ TYPELIB_DANGER_RELEASE( pFromDescr );
+ return bRet;
+ }
+ }
+ return sal_False;
+ }
+ }
+ return (eAssignable >= typelib_TypeClass_CHAR && eAssignable <= typelib_TypeClass_DOUBLE &&
+ eFrom >= typelib_TypeClass_CHAR && eFrom <= typelib_TypeClass_DOUBLE &&
+ s_aAssignableFromTab[eAssignable-1][eFrom-1]);
+ }
+ return sal_False;
+}
+//##################################################################################################
+extern "C" SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescription_isAssignableFrom(
+ typelib_TypeDescription * pAssignable,
+ typelib_TypeDescription * pFrom )
+{
+ return typelib_typedescriptionreference_isAssignableFrom(
+ pAssignable->pWeakRef, pFrom->pWeakRef );
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescription_complete(
+ typelib_TypeDescription ** ppTypeDescr )
+{
+ if (! (*ppTypeDescr)->bComplete)
+ {
+ OSL_ASSERT( (typelib_TypeClass_STRUCT == (*ppTypeDescr)->eTypeClass ||
+ typelib_TypeClass_EXCEPTION == (*ppTypeDescr)->eTypeClass ||
+ typelib_TypeClass_UNION == (*ppTypeDescr)->eTypeClass ||
+ typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass) &&
+ !reallyWeak( (*ppTypeDescr)->eTypeClass ) );
+
+ if (typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass &&
+ ((typelib_InterfaceTypeDescription *)*ppTypeDescr)->ppAllMembers)
+ {
+ // complete except of tables init
+ MutexGuard aGuard( aInit.getMutex() ); // type is registered
+ if (! (*ppTypeDescr)->bComplete)
+ {
+ typelib_typedescription_initTables( *ppTypeDescr );
+ (*ppTypeDescr)->bComplete = sal_True;
+ }
+ return sal_True;
+ }
+ // obsolete
+// else
+// {
+// MutexGuard aGuard( aInit.getMutex() );
+// typelib_TypeDescriptionReference * pRef = 0;
+// ::typelib_typedescriptionreference_getByName( &pRef, (*ppTypeDescr)->pTypeName );
+// if (pRef)
+// {
+// if (pRef->pType && pRef->pType->pWeakRef && pRef->pType->bComplete)
+// {
+// // found registered and complete td
+// ::typelib_typedescription_release( *ppTypeDescr );
+// *ppTypeDescr = pRef->pType;
+// return sal_True;
+// }
+// ::typelib_typedescriptionreference_release( pRef );
+// }
+// }
+
+ typelib_TypeDescription * pTD = 0;
+ // on demand access of complete td
+ aInit.callChain( &pTD, (*ppTypeDescr)->pTypeName );
+ if (pTD)
+ {
+ if (typelib_TypeClass_TYPEDEF == pTD->eTypeClass)
+ {
+ typelib_typedescriptionreference_getDescription(
+ &pTD, ((typelib_IndirectTypeDescription *)pTD)->pType );
+ OSL_ASSERT( pTD );
+ if (! pTD)
+ return sal_False;
+ }
+
+ OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTD->eTypeClass );
+ // typedescription found
+ // set to on demand
+ pTD->bOnDemand = sal_True;
+
+ if (typelib_TypeClass_INTERFACE == pTD->eTypeClass && !pTD->bComplete)
+ {
+ // mandatory info from callback chain
+ OSL_ASSERT( ((typelib_InterfaceTypeDescription *)pTD)->ppAllMembers );
+ // complete except of tables init
+ typelib_typedescription_initTables( pTD );
+ pTD->bComplete = sal_True;
+ }
+
+ // The type description is hold by the reference until
+ // on demand is activated.
+ ::typelib_typedescription_register( &pTD ); // replaces incomplete one
+ OSL_ASSERT( pTD == *ppTypeDescr ); // has to merge into existing one
+
+ // insert into the chache
+ MutexGuard aGuard( aInit.getMutex() );
+ if( !aInit.pCache )
+ aInit.pCache = new TypeDescriptionList_Impl;
+ if( aInit.pCache->size() >= nCacheSize )
+ {
+ typelib_typedescription_release( aInit.pCache->front() );
+ aInit.pCache->pop_front();
+ }
+ // descriptions in the cache must be acquired!
+ typelib_typedescription_acquire( pTD );
+ aInit.pCache->push_back( pTD );
+
+ OSL_ASSERT( pTD->bComplete );
+
+ ::typelib_typedescription_release( *ppTypeDescr );
+ *ppTypeDescr = pTD;
+ }
+ else
+ {
+#ifdef CPPU_ASSERTIONS
+ OString aStr( OUStringToOString( (*ppTypeDescr)->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
+ CPPU_TRACE( "\n### type cannot be completed: " );
+ CPPU_TRACE( aStr.getStr() );
+#endif
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+
diff --git a/cppu/source/uno/any.cxx b/cppu/source/uno/any.cxx
new file mode 100644
index 000000000000..9aa695b891ae
--- /dev/null
+++ b/cppu/source/uno/any.cxx
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * $RCSfile: any.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "copy.hxx"
+#include "destr.hxx"
+
+using namespace cppu;
+
+
+extern "C"
+{
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_any_construct(
+ uno_Any * pDest, void * pSource,
+ typelib_TypeDescriptionReference * pType,
+ uno_AcquireFunc acquire )
+{
+ if (pType)
+ {
+ __copyConstructAny( pDest, pSource, pType, 0, acquire, 0 );
+ }
+ else
+ {
+ __CONSTRUCT_EMPTY_ANY( (uno_Any *)pDest );
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_any_construct(
+ uno_Any * pDest, void * pSource,
+ typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire )
+{
+ if (pTypeDescr)
+ {
+ __copyConstructAny( pDest, pSource, pTypeDescr->pWeakRef, pTypeDescr, acquire, 0 );
+ }
+ else
+ {
+ __CONSTRUCT_EMPTY_ANY( pDest );
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_any_constructAndConvert(
+ uno_Any * pDest, void * pSource,
+ typelib_TypeDescriptionReference * pType,
+ uno_Mapping * mapping )
+{
+ if (pType)
+ {
+ __copyConstructAny( pDest, pSource, pType, 0, 0, mapping );
+ }
+ else
+ {
+ __CONSTRUCT_EMPTY_ANY( pDest );
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_any_constructAndConvert(
+ uno_Any * pDest, void * pSource,
+ typelib_TypeDescription * pTypeDescr,
+ uno_Mapping * mapping )
+{
+ if (pTypeDescr)
+ {
+ __copyConstructAny( pDest, pSource, pTypeDescr->pWeakRef, pTypeDescr, 0, mapping );
+ }
+ else
+ {
+ __CONSTRUCT_EMPTY_ANY( pDest );
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_any_destruct( uno_Any * pValue, uno_ReleaseFunc release )
+{
+ __destructAny( pValue, release );
+}
+}
diff --git a/cppu/source/uno/assign.hxx b/cppu/source/uno/assign.hxx
new file mode 100644
index 000000000000..aabd48326b7e
--- /dev/null
+++ b/cppu/source/uno/assign.hxx
@@ -0,0 +1,545 @@
+/*************************************************************************
+ *
+ * $RCSfile: assign.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef __ASSIGN_HXX__
+#define __ASSIGN_HXX__
+
+#include "prim.hxx"
+#include "destr.hxx"
+#include "constr.hxx"
+#include "copy.hxx"
+
+namespace cppu
+{
+
+
+//##################################################################################################
+//#### assignment ##################################################################################
+//##################################################################################################
+
+
+//--------------------------------------------------------------------------------------------------
+inline void __assignInterface(
+ void ** ppDest, void * pSource,
+ uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ void * pDest = *ppDest;
+ if (pSource)
+ {
+ if (acquire)
+ (*acquire)( pSource );
+ else
+ (*((uno_Interface *)pSource)->acquire)( (uno_Interface *)pSource );
+ }
+ if (pDest)
+ {
+ if (release)
+ (*release)( pDest );
+ else
+ (*((uno_Interface *)pDest)->release)( (uno_Interface *)pDest );
+ }
+ *ppDest = pSource;
+}
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool __queryAndAssignInterface(
+ void ** ppDest, void * pSource,
+ typelib_TypeDescriptionReference * pDestType,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+{
+ void * pDest = *ppDest;
+ if (pSource)
+ {
+ if (queryInterface)
+ {
+ pSource = (*queryInterface)( pSource, pDestType );
+ }
+ else
+ {
+ uno_Any aRet, aExc;
+ uno_Any * pExc = &aExc;
+
+ void * aArgs[1];
+ aArgs[0] = &pDestType;
+
+ typelib_TypeDescription * pMTqueryInterface = __getQueryInterfaceTypeDescr();
+ (*((uno_Interface *)pSource)->pDispatcher)(
+ (uno_Interface *)pSource, pMTqueryInterface, &aRet, aArgs, &pExc );
+
+ OSL_ENSHURE( !pExc, "### Exception occured during queryInterface()!" );
+ if (pExc)
+ {
+ __destructAny( pExc, 0 );
+ pSource = 0;
+ }
+ else
+ {
+ if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass)
+ {
+ // tweaky... avoiding acquire/ release pair
+ ::typelib_typedescriptionreference_release( aRet.pType );
+ pSource = *(void **)aRet.pData; // serving acquired interface
+ ::rtl_freeMemory( aRet.pData );
+ }
+ else
+ {
+ pSource = 0;
+ }
+ }
+ ::typelib_typedescription_release( pMTqueryInterface );
+ }
+ }
+ if (pDest)
+ {
+ if (release)
+ (*release)( pDest );
+ else
+ (*((uno_Interface *)pDest)->release)( (uno_Interface *)pDest );
+ }
+ *ppDest = pSource;
+ return (pSource != 0);
+}
+//==================================================================================================
+sal_Bool assignStruct(
+ void * pDest, void * pSource,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release );
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool __assignStruct(
+ void * pDest, void * pSource,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ if (pTypeDescr->pBaseTypeDescription)
+ {
+ // copy base value
+ if (! assignStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription,
+ queryInterface, acquire, release ))
+ {
+ return sal_False;
+ }
+ }
+ // then copy members
+ typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
+ sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
+ sal_Int32 nDescr = pTypeDescr->nMembers;
+ while (nDescr--)
+ {
+ if (! ::uno_type_assignData( (char *)pDest + pMemberOffsets[nDescr],
+ ppTypeRefs[nDescr],
+ (char *)pSource + pMemberOffsets[nDescr],
+ ppTypeRefs[nDescr],
+ queryInterface, acquire, release ))
+ {
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool __assignData(
+ void * pDest,
+ typelib_TypeDescriptionReference * pDestType, typelib_TypeDescription * pDestTypeDescr,
+ void * pSource,
+ typelib_TypeDescriptionReference * pSourceType, typelib_TypeDescription * pSourceTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ if (pDest == pSource)
+ return sal_True;
+
+ if (! pSource)
+ {
+ __destructData( pDest, pDestType, pDestTypeDescr, release );
+ __defaultConstructData( pDest, pDestType, pDestTypeDescr );
+ return sal_True;
+ }
+ while (typelib_TypeClass_ANY == pSourceType->eTypeClass)
+ {
+ pSourceTypeDescr = 0;
+ pSourceType = ((uno_Any *)pSource)->pType;
+ pSource = ((uno_Any *)pSource)->pData;
+ }
+
+ switch (pDestType->eTypeClass)
+ {
+ case typelib_TypeClass_VOID:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_VOID:
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_CHAR:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ *(sal_Unicode *)pDest = *(sal_Unicode *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_BOOLEAN:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BOOLEAN:
+ *(sal_Bool *)pDest = *(sal_Bool *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_BYTE:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ *(sal_Int8 *)pDest = *(sal_Int8 *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_SHORT:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ *(sal_Int16 *)pDest = *(sal_Int8 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(sal_Int16 *)pDest = *(sal_Int16 *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ *(sal_uInt16 *)pDest = *(sal_Int8 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(sal_uInt16 *)pDest = *(sal_uInt16 *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_LONG:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ *(sal_Int32 *)pDest = *(sal_Int8 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ *(sal_Int32 *)pDest = *(sal_Int16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(sal_Int32 *)pDest = *(sal_uInt16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ *(sal_Int32 *)pDest = *(sal_Int32 *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ *(sal_uInt32 *)pDest = *(sal_Int8 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ *(sal_uInt32 *)pDest = *(sal_Int16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(sal_uInt32 *)pDest = *(sal_uInt16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ *(sal_uInt32 *)pDest = *(sal_uInt32 *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_HYPER:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ *(sal_Int64 *)pDest = *(sal_Int8 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ *(sal_Int64 *)pDest = *(sal_Int16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(sal_Int64 *)pDest = *(sal_uInt16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ *(sal_Int64 *)pDest = *(sal_Int32 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ *(sal_Int64 *)pDest = *(sal_uInt32 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ *(sal_Int64 *)pDest = *(sal_Int64 *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ *(sal_uInt64 *)pDest = *(sal_Int8 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ *(sal_uInt64 *)pDest = *(sal_Int16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(sal_uInt64 *)pDest = *(sal_uInt16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ *(sal_uInt64 *)pDest = *(sal_Int32 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ *(sal_uInt64 *)pDest = *(sal_uInt32 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ *(sal_uInt64 *)pDest = *(sal_uInt64 *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_FLOAT:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ *(float *)pDest = *(sal_Int8 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ *(float *)pDest = *(sal_Int16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(float *)pDest = *(sal_uInt16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_FLOAT:
+ *(float *)pDest = *(float *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_DOUBLE:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ *(double *)pDest = *(sal_Int8 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ *(double *)pDest = *(sal_Int16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(double *)pDest = *(sal_uInt16 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ *(double *)pDest = *(sal_Int32 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ *(double *)pDest = *(sal_uInt32 *)pSource;
+ return sal_True;
+ case typelib_TypeClass_FLOAT:
+ *(double *)pDest = *(float *)pSource;
+ return sal_True;
+ case typelib_TypeClass_DOUBLE:
+ *(double *)pDest = *(double *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_STRING:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_STRING:
+ ::rtl_uString_assign( (rtl_uString **)pDest, *(rtl_uString **)pSource );
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_TYPE:
+ switch (pSourceType->eTypeClass)
+ {
+ case typelib_TypeClass_TYPE:
+ ::typelib_typedescriptionreference_release( *(typelib_TypeDescriptionReference **)pDest );
+ TYPE_ACQUIRE(
+ *(typelib_TypeDescriptionReference **)pDest = *(typelib_TypeDescriptionReference **)pSource );
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_ANY:
+ __destructAny( (uno_Any *)pDest, release );
+ __copyConstructAny( (uno_Any *)pDest, pSource, pSourceType, pSourceTypeDescr, acquire, 0 );
+ return sal_True;
+ case typelib_TypeClass_ENUM:
+ if (__type_equals( pDestType, pSourceType ))
+ {
+ *(int *)pDest = *(int *)pSource;
+ return sal_True;
+ }
+ return sal_False;
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ return sal_False;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ if (typelib_TypeClass_STRUCT == pSourceType->eTypeClass ||
+ typelib_TypeClass_EXCEPTION == pSourceType->eTypeClass)
+ {
+ sal_Bool bRet = sal_False;
+ if (pSourceTypeDescr)
+ {
+ typelib_CompoundTypeDescription * pTypeDescr =
+ (typelib_CompoundTypeDescription *)pSourceTypeDescr;
+ while (pTypeDescr && !__type_equals( ((typelib_TypeDescription *)pTypeDescr)->pWeakRef, pDestType ))
+ pTypeDescr = pTypeDescr->pBaseTypeDescription;
+ if (pTypeDescr)
+ bRet = __assignStruct( pDest, pSource, pTypeDescr, queryInterface, acquire, release );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pSourceTypeDescr, pSourceType );
+ typelib_CompoundTypeDescription * pTypeDescr =
+ (typelib_CompoundTypeDescription *)pSourceTypeDescr;
+ while (pTypeDescr && !__type_equals( ((typelib_TypeDescription *)pTypeDescr)->pWeakRef, pDestType ))
+ pTypeDescr = pTypeDescr->pBaseTypeDescription;
+ if (pTypeDescr)
+ bRet = __assignStruct( pDest, pSource, pTypeDescr, queryInterface, acquire, release );
+ TYPELIB_DANGER_RELEASE( pSourceTypeDescr );
+ }
+ return bRet;
+ }
+ return sal_False;
+ case typelib_TypeClass_UNION:
+ if (__type_equals( pDestType, pSourceType ))
+ {
+ if (pDestTypeDescr)
+ {
+ __destructUnion( pDest, pDestTypeDescr, release );
+ __copyConstructUnion( pDest, pSource, pDestTypeDescr, acquire, 0 );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
+ __destructUnion( pDest, pDestTypeDescr, release );
+ __copyConstructUnion( pDest, pSource, pDestTypeDescr, acquire, 0 );
+ TYPELIB_DANGER_RELEASE( pDestTypeDescr );
+ }
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_SEQUENCE:
+ if (*(uno_Sequence **)pSource == *(uno_Sequence **)pDest) // self assignment
+ return sal_True;
+ if (__type_equals( pDestType, pSourceType ))
+ {
+ __destructSequence( *(uno_Sequence **)pDest, pDestType, pDestTypeDescr, release );
+ ::osl_incrementInterlockedCount( &(*(uno_Sequence **)pSource)->nRefCount );
+ *(uno_Sequence **)pDest = *(uno_Sequence **)pSource;
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_INTERFACE:
+ if (typelib_TypeClass_INTERFACE != pSourceType->eTypeClass)
+ return sal_False;
+ if (__type_equals( pDestType, pSourceType ))
+ {
+ __assignInterface( (void **)pDest, *(void **)pSource, acquire, release );
+ return sal_True;
+ }
+ else
+ {
+ sal_Bool bRet;
+ if (pSourceTypeDescr)
+ {
+ typelib_TypeDescription * pTD = pSourceTypeDescr;
+ while (pTD && !__type_equals( pTD->pWeakRef, pDestType ))
+ pTD = (typelib_TypeDescription *)((typelib_InterfaceTypeDescription *)pTD)->pBaseTypeDescription;
+ if (pTD) // is base of dest
+ {
+ __assignInterface( (void **)pDest, *(void **)pSource, acquire, release );
+ bRet = sal_True;
+ }
+ else
+ {
+ // query for interface
+ bRet = __queryAndAssignInterface(
+ (void **)pDest, *(void **)pSource, pDestType, queryInterface, release );
+ }
+ }
+ else
+ {
+ if (__type_equals( pSourceType, pDestType ))
+ {
+ __assignInterface( (void **)pDest, *(void **)pSource, acquire, release );
+ bRet = sal_True;
+ }
+ else
+ {
+ // query for interface
+ bRet = __queryAndAssignInterface(
+ (void **)pDest, *(void **)pSource, pDestType, queryInterface, release );
+ }
+ }
+ return bRet;
+ }
+ }
+ return sal_False;
+}
+
+}
+
+#endif
diff --git a/cppu/source/uno/constr.hxx b/cppu/source/uno/constr.hxx
new file mode 100644
index 000000000000..0391f167b135
--- /dev/null
+++ b/cppu/source/uno/constr.hxx
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * $RCSfile: constr.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef __CONSTR_HXX__
+#define __CONSTR_HXX__
+
+#include "prim.hxx"
+
+namespace cppu
+{
+
+//##################################################################################################
+//#### construction ################################################################################
+//##################################################################################################
+
+
+//--------------------------------------------------------------------------------------------------
+inline void __defaultConstructUnion(
+ void * pMem,
+ typelib_TypeDescription * pTypeDescr )
+{
+ ::uno_type_constructData(
+ (char *)pMem + ((typelib_UnionTypeDescription *)pTypeDescr)->nValueOffset,
+ ((typelib_UnionTypeDescription *)pTypeDescr)->pDefaultTypeRef );
+ *(sal_Int64 *)pMem = ((typelib_UnionTypeDescription *)pTypeDescr)->nDefaultDiscriminant;
+}
+//==================================================================================================
+void defaultConstructStruct(
+ void * pMem,
+ typelib_CompoundTypeDescription * pCompType );
+//--------------------------------------------------------------------------------------------------
+inline void __defaultConstructStruct(
+ void * pMem,
+ typelib_CompoundTypeDescription * pTypeDescr )
+{
+ if (pTypeDescr->pBaseTypeDescription)
+ {
+ defaultConstructStruct( pMem, pTypeDescr->pBaseTypeDescription );
+ }
+
+ typelib_TypeDescriptionReference ** ppTypeRefs = (pTypeDescr)->ppTypeRefs;
+ sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
+ sal_Int32 nDescr = pTypeDescr->nMembers;
+
+ while (nDescr--)
+ {
+ ::uno_type_constructData( (char *)pMem + pMemberOffsets[nDescr], ppTypeRefs[nDescr] );
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+inline void __defaultConstructData(
+ void * pMem,
+ typelib_TypeDescriptionReference * pType,
+ typelib_TypeDescription * pTypeDescr )
+{
+ switch (pType->eTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ *(sal_Unicode *)pMem = '\0';
+ break;
+ case typelib_TypeClass_BOOLEAN:
+ *(sal_Bool *)pMem = sal_False;
+ break;
+ case typelib_TypeClass_BYTE:
+ *(sal_Int8 *)pMem = 0;
+ break;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(sal_Int16 *)pMem = 0;
+ break;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ *(sal_Int32 *)pMem = 0;
+ break;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ *(sal_Int64 *)pMem = 0;
+ break;
+ case typelib_TypeClass_FLOAT:
+ *(float *)pMem = 0.0;
+ break;
+ case typelib_TypeClass_DOUBLE:
+ *(double *)pMem = 0.0;
+ break;
+ case typelib_TypeClass_STRING:
+ *(rtl_uString **)pMem = 0;
+ RTL_USTRING_NEW( (rtl_uString **)pMem );
+ break;
+ case typelib_TypeClass_TYPE:
+ *(typelib_TypeDescriptionReference **)pMem = __getVoidType();
+ break;
+ case typelib_TypeClass_ANY:
+ __CONSTRUCT_EMPTY_ANY( (uno_Any *)pMem );
+ break;
+ case typelib_TypeClass_ENUM:
+ if (pTypeDescr)
+ {
+ *(int *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue;
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ *(int *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue;
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ if (pTypeDescr)
+ {
+ __defaultConstructStruct( pMem, (typelib_CompoundTypeDescription *)pTypeDescr );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __defaultConstructStruct( pMem, (typelib_CompoundTypeDescription *)pTypeDescr );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_UNION:
+ if (pTypeDescr)
+ {
+ __defaultConstructUnion( pMem, pTypeDescr );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __defaultConstructUnion( pMem, pTypeDescr );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_SEQUENCE:
+ *(uno_Sequence **)pMem = __getEmptySequence();
+ break;
+ case typelib_TypeClass_INTERFACE:
+ *(void **)pMem = 0; // either cpp or c-uno interface
+ break;
+ }
+}
+
+}
+
+#endif
diff --git a/cppu/source/uno/copy.hxx b/cppu/source/uno/copy.hxx
new file mode 100644
index 000000000000..4147db4beb5c
--- /dev/null
+++ b/cppu/source/uno/copy.hxx
@@ -0,0 +1,715 @@
+/*************************************************************************
+ *
+ * $RCSfile: copy.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef __COPY_HXX__
+#define __COPY_HXX__
+
+#include "prim.hxx"
+#include "constr.hxx"
+
+namespace cppu
+{
+
+
+//##################################################################################################
+//#### copy construction ###########################################################################
+//##################################################################################################
+
+
+//--------------------------------------------------------------------------------------------------
+void copyConstructStruct(
+ void * pDest, void * pSource,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire, uno_Mapping * mapping );
+//--------------------------------------------------------------------------------------------------
+inline void __copyConstructStruct(
+ void * pDest, void * pSource,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire, uno_Mapping * mapping )
+{
+ if (pTypeDescr->pBaseTypeDescription)
+ {
+ // copy base value
+ copyConstructStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, acquire, mapping );
+ }
+
+ // then copy members
+ typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
+ sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
+ sal_Int32 nDescr = pTypeDescr->nMembers;
+
+ if (mapping)
+ {
+ while (nDescr--)
+ {
+ ::uno_type_copyAndConvertData( (char *)pDest + pMemberOffsets[nDescr],
+ (char *)pSource + pMemberOffsets[nDescr],
+ ppTypeRefs[nDescr], mapping );
+ }
+ }
+ else
+ {
+ while (nDescr--)
+ {
+ ::uno_type_copyData( (char *)pDest + pMemberOffsets[nDescr],
+ (char *)pSource + pMemberOffsets[nDescr],
+ ppTypeRefs[nDescr], acquire );
+ }
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void __copyConstructUnion(
+ void * pDest, void * pSource,
+ typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire, uno_Mapping * mapping )
+{
+ typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pSource, pTypeDescr );
+ if (mapping)
+ {
+ ::uno_type_copyAndConvertData(
+ (char *)pDest + ((typelib_UnionTypeDescription *)pTypeDescr)->nValueOffset,
+ (char *)pSource + ((typelib_UnionTypeDescription *)pTypeDescr)->nValueOffset,
+ pSetType, mapping );
+ }
+ else
+ {
+ ::uno_type_copyData(
+ (char *)pDest + ((typelib_UnionTypeDescription *)pTypeDescr)->nValueOffset,
+ (char *)pSource + ((typelib_UnionTypeDescription *)pTypeDescr)->nValueOffset,
+ pSetType, acquire );
+ }
+ *(sal_Int64 *)pDest = *(sal_Int64 *)pSource;
+ typelib_typedescriptionreference_release( pSetType );
+}
+//--------------------------------------------------------------------------------------------------
+void copyConstructSequence(
+ uno_Sequence ** ppDest, uno_Sequence * pSource,
+ typelib_TypeDescriptionReference * pElementType,
+ uno_AcquireFunc acquire, uno_Mapping * mapping );
+//--------------------------------------------------------------------------------------------------
+inline void __copyConstructAnyFromData(
+ uno_Any * pDestAny, void * pSource,
+ typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire, uno_Mapping * mapping )
+{
+ TYPE_ACQUIRE( pType );
+ pDestAny->pType = pType;
+
+ switch (pType->eTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Unicode) );
+ *(sal_Unicode *)pDestAny->pData = *(sal_Unicode *)pSource;
+ break;
+ case typelib_TypeClass_BOOLEAN:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Bool) );
+ *(sal_Bool *)pDestAny->pData = *(sal_Bool *)pSource;
+ break;
+ case typelib_TypeClass_BYTE:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int8) );
+ *(sal_Int8 *)pDestAny->pData = *(sal_Int8 *)pSource;
+ break;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int16) );
+ *(sal_Int16 *)pDestAny->pData = *(sal_Int16 *)pSource;
+ break;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int32) );
+ *(sal_Int32 *)pDestAny->pData = *(sal_Int32 *)pSource;
+ break;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) );
+ *(sal_Int64 *)pDestAny->pData = *(sal_Int64 *)pSource;
+ break;
+ case typelib_TypeClass_FLOAT:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(float) );
+ *(float *)pDestAny->pData = *(float *)pSource;
+ break;
+ case typelib_TypeClass_DOUBLE:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(double) );
+ *(double *)pDestAny->pData = *(double *)pSource;
+ break;
+ case typelib_TypeClass_STRING:
+ ::rtl_uString_acquire( *(rtl_uString **)pSource );
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(rtl_uString *) );
+ *(rtl_uString **)pDestAny->pData = *(rtl_uString **)pSource;
+ break;
+ case typelib_TypeClass_TYPE:
+ TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource );
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(typelib_TypeDescriptionReference *) );
+ *(typelib_TypeDescriptionReference **)pDestAny->pData = *(typelib_TypeDescriptionReference **)pSource;
+ break;
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_ANY:
+ OSL_ENSHURE( sal_False, "### unexpected nested any!" );
+ break;
+#endif
+ case typelib_TypeClass_ENUM:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(int) );
+ *(int *)pDestAny->pData = *(int *)pSource;
+ break;
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ if (pTypeDescr)
+ {
+ pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
+ __copyConstructStruct(
+ pDestAny->pData, pSource,
+ (typelib_CompoundTypeDescription *)pTypeDescr,
+ acquire, mapping );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
+ __copyConstructStruct(
+ pDestAny->pData, pSource,
+ (typelib_CompoundTypeDescription *)pTypeDescr,
+ acquire, mapping );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_UNION:
+ if (pTypeDescr)
+ {
+ pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
+ __copyConstructUnion( pDestAny->pData, pSource, pTypeDescr, acquire, mapping );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
+ __copyConstructUnion( pDestAny->pData, pSource, pTypeDescr, acquire, mapping );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_SEQUENCE:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(uno_Sequence *) );
+ if (pTypeDescr)
+ {
+ copyConstructSequence(
+ (uno_Sequence **)pDestAny->pData, *(uno_Sequence **)pSource,
+ ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ acquire, mapping );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ copyConstructSequence(
+ (uno_Sequence **)pDestAny->pData, *(uno_Sequence **)pSource,
+ ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ acquire, mapping );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_INTERFACE:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(void *) );
+ if (mapping)
+ {
+ *(void **)pDestAny->pData = __map( *(void **)pSource, pType, pTypeDescr, mapping );
+ }
+ else
+ {
+ __acquire( *(void **)pDestAny->pData = *(void **)pSource, acquire );
+ }
+ break;
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void __copyConstructAny(
+ uno_Any * pDestAny, void * pSource,
+ typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire, uno_Mapping * mapping )
+{
+ if (typelib_TypeClass_VOID == pType->eTypeClass)
+ {
+ __CONSTRUCT_EMPTY_ANY( pDestAny );
+ }
+ else
+ {
+ if (typelib_TypeClass_ANY == pType->eTypeClass)
+ {
+ if (pSource)
+ {
+ pType = ((uno_Any *)pSource)->pType;
+ if (typelib_TypeClass_VOID == pType->eTypeClass)
+ {
+ __CONSTRUCT_EMPTY_ANY( pDestAny );
+ return;
+ }
+ pTypeDescr = 0;
+ pSource = ((uno_Any *)pSource)->pData;
+ }
+ else
+ {
+ __CONSTRUCT_EMPTY_ANY( pDestAny );
+ return;
+ }
+ }
+ if (pSource)
+ {
+ __copyConstructAnyFromData( pDestAny, pSource, pType, pTypeDescr, acquire, mapping );
+ }
+ else // default construct
+ {
+ TYPE_ACQUIRE( pType );
+ pDestAny->pType = pType;
+ switch (pType->eTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Unicode) );
+ *(sal_Unicode *)pDestAny->pData = '\0';
+ break;
+ case typelib_TypeClass_BOOLEAN:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Bool) );
+ *(sal_Bool *)pDestAny->pData = sal_False;
+ break;
+ case typelib_TypeClass_BYTE:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int8) );
+ *(sal_Int8 *)pDestAny->pData = 0;
+ break;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int16) );
+ *(sal_Int16 *)pDestAny->pData = 0;
+ break;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int32) );
+ *(sal_Int32 *)pDestAny->pData = 0;
+ break;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) );
+ *(sal_Int64 *)pDestAny->pData = 0;
+ break;
+ case typelib_TypeClass_FLOAT:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(float) );
+ *(float *)pDestAny->pData = 0.0;
+ break;
+ case typelib_TypeClass_DOUBLE:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(double) );
+ *(double *)pDestAny->pData = 0.0;
+ break;
+ case typelib_TypeClass_STRING:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(rtl_uString *) );
+ *(rtl_uString **)pDestAny->pData = 0;
+ RTL_USTRING_NEW( (rtl_uString **)pDestAny->pData );
+ break;
+ case typelib_TypeClass_TYPE:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(typelib_TypeDescriptionReference *) );
+ *(typelib_TypeDescriptionReference **)pDestAny->pData = __getVoidType();
+ break;
+ case typelib_TypeClass_ENUM:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(int) );
+ if (pTypeDescr)
+ {
+ *(int *)pDestAny->pData = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue;
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ *(int *)pDestAny->pData = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue;
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ if (pTypeDescr)
+ {
+ pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
+ __defaultConstructStruct(
+ pDestAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
+ __defaultConstructStruct(
+ pDestAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_UNION:
+ if (pTypeDescr)
+ {
+ pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
+ __defaultConstructUnion( pDestAny->pData, pTypeDescr );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
+ __defaultConstructUnion( pDestAny->pData, pTypeDescr );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_SEQUENCE:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(uno_Sequence *) );
+ *(uno_Sequence **)pDestAny->pData = __getEmptySequence();
+ break;
+ case typelib_TypeClass_INTERFACE:
+ pDestAny->pData = ::rtl_allocateMemory( sizeof(void *) );
+ *(void **)pDestAny->pData = 0; // either cpp or c-uno interface
+ break;
+ }
+ }
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void __copyConstructSequence(
+ uno_Sequence ** ppDest, uno_Sequence * pSource,
+ typelib_TypeDescriptionReference * pElementType,
+ uno_AcquireFunc acquire, uno_Mapping * mapping )
+{
+ typelib_TypeClass eTypeClass = pElementType->eTypeClass;
+ if (!mapping ||
+ (eTypeClass <= typelib_TypeClass_ENUM && eTypeClass != typelib_TypeClass_ANY))
+ {
+ ::osl_incrementInterlockedCount( &pSource->nRefCount );
+ *ppDest = pSource;
+ }
+ else // create new sequence
+ {
+ uno_Sequence * pDest;
+ sal_Int32 nElements = pSource->nElements;
+ if (nElements)
+ {
+ switch (eTypeClass)
+ {
+ case typelib_TypeClass_ANY:
+ {
+ pDest = (uno_Sequence *)::rtl_allocateMemory(
+ SAL_SEQUENCE_HEADER_SIZE + (nElements * sizeof(uno_Any)) );
+ uno_Any * pDestElements = (uno_Any *)pDest->elements;
+ uno_Any * pSourceElements = (uno_Any *)pSource->elements;
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ typelib_TypeDescriptionReference * pType = pSourceElements[nPos].pType;
+ if (typelib_TypeClass_VOID == pType->eTypeClass)
+ {
+ __CONSTRUCT_EMPTY_ANY( &pDestElements[nPos] );
+ }
+ else
+ {
+ __copyConstructAnyFromData(
+ &pDestElements[nPos], pSourceElements[nPos].pData,
+ pType, 0,
+ acquire, mapping );
+ }
+ }
+ break;
+ }
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+ char * pSourceElements = pSource->elements;
+ pDest = (uno_Sequence *)::rtl_allocateMemory(
+ SAL_SEQUENCE_HEADER_SIZE + (nElements * nElementSize) );
+ char * pElements = pDest->elements;
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ __copyConstructStruct(
+ pElements + (nPos * nElementSize),
+ pSourceElements + (nPos * nElementSize),
+ (typelib_CompoundTypeDescription *)pElementTypeDescr,
+ acquire, mapping );
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_UNION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+ sal_Int32 nValueOffset = ((typelib_UnionTypeDescription *)pElementTypeDescr)->nValueOffset;
+ pDest = (uno_Sequence *)::rtl_allocateMemory(
+ SAL_SEQUENCE_HEADER_SIZE + (nElements * nElementSize) );
+ char * pElements = pDest->elements;
+ char * pSourceElements = pSource->elements;
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ char * pDest = pElements + (nPos * nElementSize);
+ char * pSource = pSourceElements + (nPos * nElementSize);
+
+ typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pSource, pElementTypeDescr );
+ ::uno_type_copyAndConvertData( pDest + nValueOffset, pSource + nValueOffset,
+ pSetType, mapping );
+ *(sal_Int64 *)pDest = *(sal_Int64 *)pSource;
+ ::typelib_typedescriptionreference_release( pSetType );
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_SEQUENCE: // sequence of sequence
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ typelib_TypeDescriptionReference * pSeqElementType =
+ ((typelib_IndirectTypeDescription *)pElementTypeDescr)->pType;
+ pDest = (uno_Sequence *)::rtl_allocateMemory(
+ SAL_SEQUENCE_HEADER_SIZE + (nElements * sizeof(uno_Sequence *)) );
+ char * pElements = pDest->elements;
+ uno_Sequence ** pSourceElements = (uno_Sequence **)pSource->elements;
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ copyConstructSequence(
+ (uno_Sequence **)pElements + nPos, pSourceElements[nPos],
+ pSeqElementType,
+ acquire, mapping );
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_INTERFACE:
+ {
+ pDest = (uno_Sequence *)::rtl_allocateMemory(
+ SAL_SEQUENCE_HEADER_SIZE + (nElements * sizeof(void *)) );
+ char * pElements = pDest->elements;
+ void ** pSourceElements = (void **)pSource->elements;
+ if (mapping)
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ ((void **)pElements)[nPos] = 0;
+ if (((void **)pSourceElements)[nPos])
+ {
+ (*mapping->mapInterface)(
+ mapping, (void **)pElements + nPos,
+ pSourceElements[nPos],
+ (typelib_InterfaceTypeDescription *)pElementTypeDescr );
+ }
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ }
+ else
+ {
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ __acquire( ((void **)pElements)[nPos] = pSourceElements[nPos], acquire );
+ }
+ }
+ break;
+ }
+ default:
+ pDest = (uno_Sequence *)::rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE );
+ break;
+ }
+ }
+ else
+ {
+ pDest = (uno_Sequence *)::rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE );
+ }
+ pDest->nElements = nElements;
+ pDest->nRefCount = 1;
+ *ppDest = pDest;
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+inline void __copyConstructData(
+ void * pDest, void * pSource,
+ typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire, uno_Mapping * mapping )
+{
+ switch (pType->eTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ *(sal_Unicode *)pDest = *(sal_Unicode *)pSource;
+ break;
+ case typelib_TypeClass_BOOLEAN:
+ *(sal_Bool *)pDest = *(sal_Bool *)pSource;
+ break;
+ case typelib_TypeClass_BYTE:
+ *(sal_Int8 *)pDest = *(sal_Int8 *)pSource;
+ break;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(sal_Int16 *)pDest = *(sal_Int16 *)pSource;
+ break;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ *(sal_Int32 *)pDest = *(sal_Int32 *)pSource;
+ break;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+#if defined(GCC) && defined(SPARC)
+ *(sal_Int32 *)pDest = *(sal_Int32 *)pSource;
+ *(((sal_Int32 *)pDest) +1) = *(((sal_Int32 *)pSource) +1);
+#else
+ *(sal_Int64 *)pDest = *(sal_Int64 *)pSource;
+#endif
+ break;
+ case typelib_TypeClass_FLOAT:
+ *(float *)pDest = *(float *)pSource;
+ break;
+ case typelib_TypeClass_DOUBLE:
+ *(double *)pDest = *(double *)pSource;
+ break;
+ case typelib_TypeClass_STRING:
+ ::rtl_uString_acquire( *(rtl_uString **)pSource );
+ *(rtl_uString **)pDest = *(rtl_uString **)pSource;
+ break;
+ case typelib_TypeClass_TYPE:
+ TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource );
+ *(typelib_TypeDescriptionReference **)pDest = *(typelib_TypeDescriptionReference **)pSource;
+ break;
+ case typelib_TypeClass_ANY:
+ __copyConstructAny(
+ (uno_Any *)pDest, ((uno_Any *)pSource)->pData,
+ ((uno_Any *)pSource)->pType, 0,
+ acquire, mapping );
+ break;
+ case typelib_TypeClass_ENUM:
+ *(int *)pDest = *(int *)pSource;
+ break;
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ if (pTypeDescr)
+ {
+ __copyConstructStruct(
+ pDest, pSource,
+ (typelib_CompoundTypeDescription *)pTypeDescr,
+ acquire, mapping );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __copyConstructStruct(
+ pDest, pSource,
+ (typelib_CompoundTypeDescription *)pTypeDescr,
+ acquire, mapping );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_UNION:
+ if (pTypeDescr)
+ {
+ __copyConstructUnion( pDest, pSource, pTypeDescr, acquire, mapping );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __copyConstructUnion( pDest, pSource, pTypeDescr, acquire, mapping );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_SEQUENCE:
+ if (mapping)
+ {
+ if (pTypeDescr)
+ {
+ __copyConstructSequence(
+ (uno_Sequence **)pDest, *(uno_Sequence **)pSource,
+ ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ acquire, mapping );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __copyConstructSequence(
+ (uno_Sequence **)pDest, *(uno_Sequence **)pSource,
+ ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ acquire, mapping );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ }
+ else
+ {
+ ::osl_incrementInterlockedCount( &(*(uno_Sequence **)pSource)->nRefCount );
+ *(uno_Sequence **)pDest = *(uno_Sequence **)pSource;
+ }
+ break;
+ case typelib_TypeClass_INTERFACE:
+ if (mapping)
+ *(void **)pDest = __map( *(void **)pSource, pType, pTypeDescr, mapping );
+ else
+ __acquire( *(void **)pDest = *(void **)pSource, acquire );
+ break;
+ }
+}
+
+}
+
+#endif
diff --git a/cppu/source/uno/data.cxx b/cppu/source/uno/data.cxx
new file mode 100644
index 000000000000..a188354ee45a
--- /dev/null
+++ b/cppu/source/uno/data.cxx
@@ -0,0 +1,357 @@
+/*************************************************************************
+ *
+ * $RCSfile: data.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "constr.hxx"
+#include "destr.hxx"
+#include "copy.hxx"
+#include "assign.hxx"
+#include "eq.hxx"
+
+using namespace cppu;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+
+namespace cppu
+{
+
+//==================================================================================================
+void defaultConstructStruct(
+ void * pMem,
+ typelib_CompoundTypeDescription * pCompType )
+{
+ __defaultConstructStruct( pMem, pCompType );
+}
+//==================================================================================================
+void copyConstructStruct(
+ void * pDest, void * pSource,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire, uno_Mapping * mapping )
+{
+ __copyConstructStruct( pDest, pSource, pTypeDescr, acquire, mapping );
+}
+//==================================================================================================
+void destructStruct(
+ void * pValue,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_ReleaseFunc release )
+{
+ __destructStruct( pValue, pTypeDescr, release );
+}
+//==================================================================================================
+sal_Bool equalStruct(
+ void * pDest, void *pSource,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+{
+ return __equalStruct( pDest, pSource, pTypeDescr, queryInterface, release );
+}
+//==================================================================================================
+sal_Bool assignStruct(
+ void * pDest, void * pSource,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ return __assignStruct( pDest, pSource, pTypeDescr, queryInterface, acquire, release );
+}
+//==================================================================================================
+void copyConstructSequence(
+ uno_Sequence ** ppDest, uno_Sequence * pSource,
+ typelib_TypeDescriptionReference * pElementType,
+ uno_AcquireFunc acquire, uno_Mapping * mapping )
+{
+ __copyConstructSequence( ppDest, pSource, pElementType, acquire, mapping );
+}
+//==================================================================================================
+void destructSequence(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescriptionReference * pElementType,
+ uno_ReleaseFunc release )
+{
+ uno_Sequence * pSequence = *ppSequence;
+ OSL_ASSERT( pSequence );
+ if (! ::osl_decrementInterlockedCount( &pSequence->nRefCount ))
+ {
+ if (pSequence->nElements)
+ {
+ __destructElements( pSequence->elements, pElementType, 0, pSequence->nElements, release );
+ }
+ ::rtl_freeMemory( pSequence );
+ }
+}
+//==================================================================================================
+sal_Bool equalSequence(
+ uno_Sequence * pDest, uno_Sequence * pSource,
+ typelib_TypeDescriptionReference * pElementType,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+{
+ return __equalSequence( pDest, pSource, pElementType, queryInterface, release );
+}
+
+extern "C"
+{
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_constructData(
+ void * pMem, typelib_TypeDescriptionReference * pType )
+{
+ __defaultConstructData( pMem, pType, 0 );
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_constructData(
+ void * pMem, typelib_TypeDescription * pTypeDescr )
+{
+ __defaultConstructData( pMem, pTypeDescr->pWeakRef, pTypeDescr );
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_destructData(
+ void * pValue, typelib_TypeDescriptionReference * pType,
+ uno_ReleaseFunc release )
+{
+ __destructData( pValue, pType, 0, release );
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_destructData(
+ void * pValue,
+ typelib_TypeDescription * pTypeDescr,
+ uno_ReleaseFunc release )
+{
+ __destructData( pValue, pTypeDescr->pWeakRef, pTypeDescr, release );
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_copyData(
+ void * pDest, void * pSource,
+ typelib_TypeDescriptionReference * pType,
+ uno_AcquireFunc acquire )
+{
+ __copyConstructData( pDest, pSource, pType, 0, acquire, 0 );
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_copyData(
+ void * pDest, void * pSource,
+ typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire )
+{
+ __copyConstructData( pDest, pSource, pTypeDescr->pWeakRef, pTypeDescr, acquire, 0 );
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_copyAndConvertData(
+ void * pDest, void * pSource,
+ typelib_TypeDescriptionReference * pType,
+ uno_Mapping * mapping )
+{
+ __copyConstructData( pDest, pSource, pType, 0, 0, mapping );
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_copyAndConvertData(
+ void * pDest, void * pSource,
+ typelib_TypeDescription * pTypeDescr,
+ uno_Mapping * mapping )
+{
+ __copyConstructData( pDest, pSource, pTypeDescr->pWeakRef, pTypeDescr, 0, mapping );
+}
+//##################################################################################################
+SAL_DLLEXPORT sal_Bool SAL_CALL uno_type_equalData(
+ void * pVal1, typelib_TypeDescriptionReference * pVal1Type,
+ void * pVal2, typelib_TypeDescriptionReference * pVal2Type,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+{
+ return __equalData( pVal1, pVal1Type, 0,
+ pVal2, pVal2Type, 0,
+ queryInterface, release );
+}
+//##################################################################################################
+SAL_DLLEXPORT sal_Bool SAL_CALL uno_equalData(
+ void * pVal1, typelib_TypeDescription * pVal1TD,
+ void * pVal2, typelib_TypeDescription * pVal2TD,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+{
+ return __equalData( pVal1, pVal1TD->pWeakRef, pVal1TD,
+ pVal2, pVal2TD->pWeakRef, pVal2TD,
+ queryInterface, release );
+}
+//##################################################################################################
+SAL_DLLEXPORT sal_Bool SAL_CALL uno_type_assignData(
+ void * pDest, typelib_TypeDescriptionReference * pDestType,
+ void * pSource, typelib_TypeDescriptionReference * pSourceType,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ return __assignData( pDest, pDestType, 0,
+ pSource, pSourceType, 0,
+ queryInterface, acquire, release );
+}
+//##################################################################################################
+SAL_DLLEXPORT sal_Bool SAL_CALL uno_assignData(
+ void * pDest, typelib_TypeDescription * pDestTD,
+ void * pSource, typelib_TypeDescription * pSourceTD,
+ uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ return __assignData( pDest, pDestTD->pWeakRef, pDestTD,
+ pSource, pSourceTD->pWeakRef, pSourceTD,
+ queryInterface, acquire, release );
+}
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+#ifdef _DEBUG
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#elif defined(SAL_OS2)
+# pragma pack(8)
+#endif
+
+struct M
+{
+ sal_Int32 n;
+ sal_Int16 o;
+};
+
+struct N : public M
+{
+ sal_Int16 p;
+};
+
+struct O : public M
+{
+ double p;
+};
+
+struct empty
+{
+};
+struct second : public empty
+{
+ int a;
+};
+
+class BinaryCompatible_Impl
+{
+public:
+ BinaryCompatible_Impl()
+ {
+ if ((SAL_SEQUENCE_HEADER_SIZE % 8) != 0)
+ abort();
+
+ /*
+ If the feature failed search FEATURE_ and correct it.
+ */
+ // the sizeof enum must be the size of an integer
+ // FEATURE_ENUM
+ if( sizeof( TypeClass ) != sizeof( int ) )
+ abort();
+
+ // the sizeof any must be sizeof( void * ) * 2,
+ // the first is a pointer to typelib_TypeDescription, the second is the pointer to the data
+ // FEATURE_ANY
+ if( sizeof( Any ) != sizeof( uno_Any ) )
+ abort();
+ if( sizeof( Any ) != sizeof( void * ) * 2 )
+ abort();
+ if( (sal_Int32)&((Any *) 16)->pType != 16 )
+ abort();
+ if( (sal_Int32)&((Any *) 16)->pData != 16 + sizeof( void * ) )
+ abort();
+
+ // All types can moved from one one memory location to another
+ // without calling the copy constructor and the destructor.
+ // FEATURE_MEMORYMOVE_INVARIANT
+
+ // All types can moved from one one memory location to another
+ // without calling the copy constructor and the destructor.
+ // FEATURE_ZEROCONSTRUCTOR
+
+ // The reference class must be a pointer to XInterface or a subclass of XInterface
+ // FEATURE_INTERFACE
+ if( sizeof( Reference< XInterface > ) != sizeof( XInterface * ) )
+ abort();
+
+ // The reference class must be a pointer to XInterface or a subclass of XInterface
+ // FEATURE_WSTRING
+ if( sizeof( OUString ) != sizeof( rtl_uString * ) )
+ abort();
+
+ // The reference class must be a pointer to XInterface or a subclass of XInterface
+ // FEATURE_ALIGN
+ if( sizeof( M ) != 8 || sizeof( N ) != 12 || sizeof( O ) != 16 )
+ abort();
+
+#ifndef __GNUC__
+ // An empty superclass have a size of 0 except for gcc
+ // FEATURE_EMPTYCLASS
+ if( sizeof( second ) != sizeof( int ) )
+ abort();
+#endif
+ }
+};
+#ifdef SAL_W32
+# pragma pack(pop)
+#elif defined(SAL_OS2)
+# pragma pack()
+#endif
+
+static BinaryCompatible_Impl aTest;
+#endif
+
+}
diff --git a/cppu/source/uno/destr.hxx b/cppu/source/uno/destr.hxx
new file mode 100644
index 000000000000..d2fef7e6eff8
--- /dev/null
+++ b/cppu/source/uno/destr.hxx
@@ -0,0 +1,411 @@
+/*************************************************************************
+ *
+ * $RCSfile: destr.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef __DESTR_HXX__
+#define __DESTR_HXX__
+
+#include "prim.hxx"
+
+namespace cppu
+{
+
+
+//##################################################################################################
+//#### destruction #################################################################################
+//##################################################################################################
+
+
+//--------------------------------------------------------------------------------------------------
+inline void __destructUnion(
+ void * pValue,
+ typelib_TypeDescription * pTypeDescr,
+ uno_ReleaseFunc release )
+{
+ typelib_TypeDescriptionReference * pType = __unionGetSetType( pValue, pTypeDescr );
+ ::uno_type_destructData(
+ (char *)pValue + ((typelib_UnionTypeDescription *)pTypeDescr)->nValueOffset,
+ pType, release );
+ ::typelib_typedescriptionreference_release( pType );
+}
+//==================================================================================================
+void destructStruct(
+ void * pValue,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_ReleaseFunc release );
+//--------------------------------------------------------------------------------------------------
+inline void __destructStruct(
+ void * pValue,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_ReleaseFunc release )
+{
+ if (pTypeDescr->pBaseTypeDescription)
+ {
+ destructStruct( pValue, pTypeDescr->pBaseTypeDescription, release );
+ }
+
+ typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
+ sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
+ sal_Int32 nDescr = pTypeDescr->nMembers;
+ while (nDescr--)
+ {
+ ::uno_type_destructData(
+ (char *)pValue + pMemberOffsets[nDescr], ppTypeRefs[nDescr], release );
+ }
+}
+//==================================================================================================
+void destructSequence(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescriptionReference * pElementType,
+ uno_ReleaseFunc release );
+//--------------------------------------------------------------------------------------------------
+inline void __destructAny(
+ uno_Any * pAny,
+ uno_ReleaseFunc release )
+{
+ typelib_TypeDescriptionReference * pType = pAny->pType;
+
+ if (typelib_TypeClass_VOID != pType->eTypeClass)
+ {
+ switch (pType->eTypeClass)
+ {
+ case typelib_TypeClass_STRING:
+ ::rtl_uString_release( *(rtl_uString **)pAny->pData );
+ break;
+ case typelib_TypeClass_TYPE:
+ ::typelib_typedescriptionreference_release( *(typelib_TypeDescriptionReference **)pAny->pData );
+ break;
+ case typelib_TypeClass_ANY:
+ OSL_ENSHURE( sal_False, "### unexpected nested any!" );
+ ::uno_any_destruct( (uno_Any *)pAny->pData, release );
+ break;
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __destructStruct( pAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr, release );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_UNION:
+ {
+ typelib_TypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __destructUnion( pAny->pData, pTypeDescr, release );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_SEQUENCE:
+ {
+ typelib_TypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ destructSequence(
+ (uno_Sequence **)pAny->pData,
+ ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ release );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_INTERFACE:
+ __releaseRef( (void **)pAny->pData, release );
+ break;
+ }
+ ::rtl_freeMemory( pAny->pData );
+#ifdef DEBUG
+ pAny->pData = (void *)0xdeadbeef;
+#endif
+ }
+ ::typelib_typedescriptionreference_release( pType );
+}
+//--------------------------------------------------------------------------------------------------
+inline sal_Int32 __destructElements(
+ void * pElements, typelib_TypeDescriptionReference * pElementType,
+ sal_Int32 nStartIndex, sal_Int32 nStopIndex,
+ uno_ReleaseFunc release )
+{
+ switch (pElementType->eTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ return sizeof(sal_Unicode);
+ case typelib_TypeClass_BOOLEAN:
+ return sizeof(sal_Bool);
+ case typelib_TypeClass_BYTE:
+ return sizeof(sal_Int8);
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return sizeof(sal_Int16);
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return sizeof(sal_Int32);
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ return sizeof(sal_Int64);
+ case typelib_TypeClass_FLOAT:
+ return sizeof(float);
+ case typelib_TypeClass_DOUBLE:
+ return sizeof(double);
+
+ case typelib_TypeClass_STRING:
+ {
+ rtl_uString ** pDest = (rtl_uString **)pElements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ ::rtl_uString_release( pDest[nPos] );
+ }
+ return sizeof(rtl_uString *);
+ }
+ case typelib_TypeClass_TYPE:
+ {
+ typelib_TypeDescriptionReference ** pDest = (typelib_TypeDescriptionReference **)pElements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ ::typelib_typedescriptionreference_release( pDest[nPos] );
+ }
+ return sizeof(typelib_TypeDescriptionReference *);
+ }
+ case typelib_TypeClass_ANY:
+ {
+ uno_Any * pDest = (uno_Any *)pElements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ __destructAny( &pDest[nPos], release );
+ }
+ return sizeof(uno_Any);
+ }
+ case typelib_TypeClass_ENUM:
+ return sizeof(int);
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ __destructStruct(
+ (char *)pElements + (nElementSize * nPos),
+ (typelib_CompoundTypeDescription *)pElementTypeDescr,
+ release );
+ }
+ sal_Int32 nSize = pElementTypeDescr->nSize;
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ return nSize;
+ }
+ case typelib_TypeClass_UNION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ __destructUnion(
+ (char *)pElements + (nElementSize * nPos),
+ pElementTypeDescr,
+ release );
+ }
+ sal_Int32 nSize = pElementTypeDescr->nSize;
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ return nSize;
+ }
+ case typelib_TypeClass_SEQUENCE:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ uno_Sequence ** pDest = (uno_Sequence **)pElements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ destructSequence(
+ &pDest[nPos],
+ ((typelib_IndirectTypeDescription *)pElementTypeDescr)->pType,
+ release );
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ return sizeof(uno_Sequence *);
+ }
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_ARRAY:
+ OSL_ENSHURE( sal_False, "### unexpected array!" );
+ break;
+#endif
+ case typelib_TypeClass_INTERFACE:
+ {
+ if (release)
+ {
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ void * p = ((void **)pElements)[nPos];
+ if (p)
+ (*release)( p );
+ }
+ }
+ else
+ {
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ uno_Interface * p = ((uno_Interface **)pElements)[nPos];
+ if (p)
+ (*p->release)( p );
+ }
+ }
+ return sizeof(void *);
+ }
+ }
+ return 0;
+}
+//--------------------------------------------------------------------------------------------------
+inline void __destructSequence(
+ uno_Sequence * pSequence,
+ typelib_TypeDescriptionReference * pType,
+ typelib_TypeDescription * pTypeDescr,
+ uno_ReleaseFunc release )
+{
+ if (! ::osl_decrementInterlockedCount( &pSequence->nRefCount ))
+ {
+ if (pSequence->nElements)
+ {
+ if (pTypeDescr)
+ {
+ __destructElements(
+ pSequence->elements, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ 0, pSequence->nElements, release );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __destructElements(
+ pSequence->elements, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ 0, pSequence->nElements, release );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ }
+ ::rtl_freeMemory( pSequence );
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void __destructData(
+ void * pValue,
+ typelib_TypeDescriptionReference * pType,
+ typelib_TypeDescription * pTypeDescr,
+ uno_ReleaseFunc release )
+{
+ switch (pType->eTypeClass)
+ {
+ case typelib_TypeClass_STRING:
+ ::rtl_uString_release( *(rtl_uString **)pValue );
+ break;
+ case typelib_TypeClass_TYPE:
+ ::typelib_typedescriptionreference_release( *(typelib_TypeDescriptionReference **)pValue );
+ break;
+ case typelib_TypeClass_ANY:
+ __destructAny( (uno_Any *)pValue, release );
+ break;
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ if (pTypeDescr)
+ {
+ __destructStruct( pValue, (typelib_CompoundTypeDescription *)pTypeDescr, release );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __destructStruct( pValue, (typelib_CompoundTypeDescription *)pTypeDescr, release );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_UNION:
+ if (pTypeDescr)
+ {
+ __destructUnion( pValue, pTypeDescr, release );
+ }
+ else
+ {
+ typelib_TypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __destructUnion( pValue, pTypeDescr, release );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ break;
+ case typelib_TypeClass_SEQUENCE:
+ __destructSequence( *(uno_Sequence **)pValue, pType, pTypeDescr, release );
+ break;
+ case typelib_TypeClass_INTERFACE:
+ __releaseRef( (void **)pValue, release );
+ break;
+ }
+}
+
+}
+
+#endif
diff --git a/cppu/source/uno/eq.hxx b/cppu/source/uno/eq.hxx
new file mode 100644
index 000000000000..6deac9cbbd8d
--- /dev/null
+++ b/cppu/source/uno/eq.hxx
@@ -0,0 +1,745 @@
+/*************************************************************************
+ *
+ * $RCSfile: eq.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef __EQ_HXX__
+#define __EQ_HXX__
+
+#include <math.h>
+
+#ifndef _RTL_MEMORY_H_
+#include <rtl/memory.h>
+#endif
+
+#include "prim.hxx"
+#include "destr.hxx"
+
+namespace cppu
+{
+
+
+//##################################################################################################
+//#### equality ####################################################################################
+//##################################################################################################
+
+
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool __unoEqualObject( void * pUnoI1, void * pUnoI2 )
+{
+ if (pUnoI1 == pUnoI2)
+ return sal_True;
+ if (!pUnoI2 || !pUnoI2)
+ return sal_False;
+
+ sal_Bool bRet = sal_False;
+
+ void * pArgs[1];
+
+ const com::sun::star::uno::Type & rXIType =
+ ::getCppuType( (const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > *)0 );
+ pArgs[0] = const_cast< com::sun::star::uno::Type * >( &rXIType );
+ uno_Any aRet1, aRet2, aExc;
+ uno_Any * pExc = &aExc;
+
+ typelib_TypeDescription * pMTqueryInterface = __getQueryInterfaceTypeDescr();
+ (*((uno_Interface *)pUnoI1)->pDispatcher)(
+ (uno_Interface *)pUnoI1, pMTqueryInterface, &aRet1, pArgs, &pExc );
+
+ OSL_ENSHURE( !pExc, "### Exception occured during queryInterface()!" );
+ if (pExc)
+ {
+ __destructAny( pExc, 0 );
+ }
+ else
+ {
+ if (typelib_TypeClass_INTERFACE == aRet1.pType->eTypeClass)
+ {
+ pExc = &aExc;
+ (*((uno_Interface *)pUnoI2)->pDispatcher)(
+ (uno_Interface *)pUnoI2, pMTqueryInterface, &aRet2, pArgs, &pExc );
+
+ OSL_ENSHURE( !pExc, "### Exception occured during queryInterface()!" );
+ if (pExc)
+ {
+ __destructAny( pExc, 0 );
+ }
+ else
+ {
+ if (typelib_TypeClass_INTERFACE == aRet2.pType->eTypeClass)
+ {
+ bRet = (*(void **)aRet1.pData == *(void **)aRet2.pData);
+ }
+ __destructAny( &aRet2, 0 );
+ }
+ }
+ __destructAny( &aRet1, 0 );
+ }
+
+ typelib_typedescription_release( pMTqueryInterface );
+
+ return bRet;
+}
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool __equalObject(
+ void * pI1, void * pI2,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+{
+ if (pI1 == pI2)
+ return sal_True;
+ if (queryInterface)
+ {
+ sal_Bool bRet = sal_False;
+ const com::sun::star::uno::Type & rType =
+ ::getCppuType( (const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > *)0 );
+ if (pI1 = (*queryInterface)( pI1, rType.getTypeLibType() ))
+ {
+ if (pI2 = (*queryInterface)( pI2, rType.getTypeLibType() ))
+ {
+ bRet = (pI1 == pI2);
+ (*release)( pI2 );
+ }
+ (*release)( pI1 );
+ }
+ return bRet;
+ }
+ return __unoEqualObject( pI1, pI2 );
+}
+
+//==================================================================================================
+sal_Bool equalStruct(
+ void * pDest, void *pSource,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release );
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool __equalStruct(
+ void * pDest, void *pSource,
+ typelib_CompoundTypeDescription * pTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+{
+ if (pTypeDescr->pBaseTypeDescription &&
+ !equalStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, queryInterface, release ))
+ {
+ return sal_False;
+ }
+
+ typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
+ sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
+ sal_Int32 nDescr = pTypeDescr->nMembers;
+
+ while (nDescr--)
+ {
+ sal_Int32 nOffset = pMemberOffsets[nDescr];
+ if (! uno_type_equalData( (char *)pDest + nOffset,
+ ppTypeRefs[nDescr],
+ (char *)pSource + nOffset,
+ ppTypeRefs[nDescr],
+ queryInterface, release ))
+ {
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+//==================================================================================================
+sal_Bool equalSequence(
+ uno_Sequence * pDest, uno_Sequence * pSource,
+ typelib_TypeDescriptionReference * pElementType,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release );
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool __equalSequence(
+ uno_Sequence * pDest, uno_Sequence * pSource,
+ typelib_TypeDescriptionReference * pElementType,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+{
+ if (pDest == pSource)
+ return sal_True;
+ sal_Int32 nElements = pDest->nElements;
+ if (nElements != pSource->nElements)
+ return sal_False;
+ if (! nElements)
+ return sal_True;
+
+ void * pDestElements = pDest->elements;
+ void * pSourceElements = pSource->elements;
+
+ switch (pElementType->eTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Unicode) * nElements ));
+ case typelib_TypeClass_BOOLEAN:
+ {
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ if ((((sal_Bool *)pDestElements)[nPos] != sal_False) !=
+ (((sal_Bool *)pSourceElements)[nPos] != sal_False))
+ {
+ return sal_False;
+ }
+ }
+ return sal_True;
+ }
+ case typelib_TypeClass_BYTE:
+ return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int8) * nElements ));
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int16) * nElements ));
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int64) * nElements ));
+ case typelib_TypeClass_FLOAT:
+ {
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ if (((float *)pDestElements)[nPos] != ((float *)pSourceElements)[nPos])
+ return sal_False;
+ }
+ return sal_True;
+ }
+ case typelib_TypeClass_DOUBLE:
+ {
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ if (((double *)pDestElements)[nPos] != ((double *)pSourceElements)[nPos])
+ return sal_False;
+ }
+ return sal_True;
+ }
+ case typelib_TypeClass_STRING:
+ {
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ if (! ((::rtl::OUString *)pDestElements +nPos)->equals( ((const ::rtl::OUString *)pSourceElements)[nPos] ))
+ return sal_False;
+ }
+ return sal_True;
+ }
+ case typelib_TypeClass_TYPE:
+ {
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ if (! __type_equals( ((typelib_TypeDescriptionReference **)pDestElements)[nPos],
+ ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] ))
+ {
+ return sal_False;
+ }
+ }
+ return sal_True;
+ }
+ case typelib_TypeClass_ANY:
+ {
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ uno_Any * pDest = (uno_Any *)pDestElements + nPos;
+ uno_Any * pSource = (uno_Any *)pSourceElements + nPos;
+ if (! ::uno_type_equalData( pDest->pData, pDest->pType,
+ pSource->pData, pSource->pType,
+ queryInterface, release ))
+ {
+ return sal_False;
+ }
+ }
+ return sal_True;
+ }
+ case typelib_TypeClass_ENUM:
+ return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(int) * nElements ));
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ if (! __equalStruct( (char *)pDestElements + (nPos * nElementSize),
+ (char *)pSourceElements + (nPos * nElementSize),
+ (typelib_CompoundTypeDescription *)pElementTypeDescr,
+ queryInterface, release ))
+ {
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ return sal_False;
+ }
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ return sal_True;
+ }
+ case typelib_TypeClass_UNION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+ sal_Int32 nValueOffset = ((typelib_UnionTypeDescription *)pElementTypeDescr)->nValueOffset;
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ char * pDest = (char *)pDestElements + (nPos * nElementSize);
+ char * pSource = (char *)pSourceElements + (nPos * nElementSize);
+ typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pDest, pElementTypeDescr );
+ sal_Bool bRet = uno_type_equalData( pDest + nValueOffset, pSetType,
+ pSource + nValueOffset, pSetType,
+ queryInterface, release );
+ ::typelib_typedescriptionreference_release( pSetType );
+ if (! bRet)
+ {
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ return sal_False;
+ }
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ return sal_True;
+ }
+ case typelib_TypeClass_SEQUENCE: // sequence of sequence
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ typelib_TypeDescriptionReference * pSeqElementType =
+ ((typelib_IndirectTypeDescription *)pElementTypeDescr)->pType;
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ if (! equalSequence( ((uno_Sequence **)pDestElements)[nPos],
+ ((uno_Sequence **)pSourceElements)[nPos],
+ pSeqElementType, queryInterface, release ))
+ {
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ return sal_False;
+ }
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ return sal_True;
+ }
+ case typelib_TypeClass_INTERFACE:
+ {
+ for ( sal_Int32 nPos = nElements; nPos--; )
+ {
+ if (! __equalObject( ((void **)pDestElements)[nPos], ((void **)pSourceElements)[nPos],
+ queryInterface, release ))
+ {
+ return sal_False;
+ }
+ }
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool __equalData(
+ void * pDest,
+ typelib_TypeDescriptionReference * pDestType, typelib_TypeDescription * pDestTypeDescr,
+ void * pSource,
+ typelib_TypeDescriptionReference * pSourceType, typelib_TypeDescription * pSourceTypeDescr,
+ uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
+{
+ typelib_TypeClass eSourceTypeClass, eDestTypeClass;
+ while (typelib_TypeClass_ANY == (eDestTypeClass = pDestType->eTypeClass))
+ {
+ pDestTypeDescr = 0;
+ pDestType = ((uno_Any *)pDest)->pType;
+ pDest = ((uno_Any *)pDest)->pData;
+ }
+ while (typelib_TypeClass_ANY == (eSourceTypeClass = pSourceType->eTypeClass))
+ {
+ pSourceTypeDescr = 0;
+ pSourceType = ((uno_Any *)pSource)->pType;
+ pSource = ((uno_Any *)pSource)->pData;
+ }
+
+ switch (eDestTypeClass)
+ {
+ case typelib_TypeClass_VOID:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_VOID:
+ return sal_True;
+ }
+ return sal_False;
+ case typelib_TypeClass_CHAR:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ return (*(sal_Unicode *)pDest == *(sal_Unicode *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_BOOLEAN:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BOOLEAN:
+ return (*(sal_Bool *)pDest == *(sal_Bool *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_BYTE:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ return (*(sal_Int8 *)pDest == *(sal_Int8 *)pSource);
+ case typelib_TypeClass_SHORT:
+ return (*(sal_Int8 *)pDest == *(sal_Int16 *)pSource);
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (*(sal_Int8 *)pDest == *(sal_uInt16 *)pSource);
+ case typelib_TypeClass_LONG:
+ return (*(sal_Int8 *)pDest == *(sal_Int32 *)pSource);
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (*(sal_Int8 *)pDest == *(sal_uInt32 *)pSource);
+ case typelib_TypeClass_HYPER:
+ return (*(sal_Int8 *)pDest == *(sal_Int64 *)pSource);
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ return (*(sal_Int8 *)pDest == *(sal_uInt64 *)pSource);
+ case typelib_TypeClass_FLOAT:
+ return (*(sal_Int8 *)pDest == *(float *)pSource);
+ case typelib_TypeClass_DOUBLE:
+ return (*(sal_Int8 *)pDest == *(double *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_SHORT:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ return (*(sal_Int16 *)pDest == *(sal_Int8 *)pSource);
+ case typelib_TypeClass_SHORT:
+ return (*(sal_Int16 *)pDest == *(sal_Int16 *)pSource);
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (*(sal_Int16 *)pDest == *(sal_uInt16 *)pSource);
+ case typelib_TypeClass_LONG:
+ return (*(sal_Int16 *)pDest == *(sal_Int32 *)pSource);
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (*(sal_Int16 *)pDest == *(sal_uInt32 *)pSource);
+ case typelib_TypeClass_HYPER:
+ return (*(sal_Int16 *)pDest == *(sal_Int64 *)pSource);
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ return (*(sal_Int16 *)pDest == *(sal_uInt64 *)pSource);
+ case typelib_TypeClass_FLOAT:
+ return (*(sal_Int16 *)pDest == *(float *)pSource);
+ case typelib_TypeClass_DOUBLE:
+ return (*(sal_Int16 *)pDest == *(double *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ return (*(sal_uInt16 *)pDest == *(sal_Int8 *)pSource);
+ case typelib_TypeClass_SHORT:
+ return (*(sal_uInt16 *)pDest == *(sal_Int16 *)pSource);
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (*(sal_uInt16 *)pDest == *(sal_uInt16 *)pSource);
+ case typelib_TypeClass_LONG:
+ return (*(sal_uInt16 *)pDest == *(sal_Int32 *)pSource);
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (*(sal_uInt16 *)pDest == *(sal_uInt32 *)pSource);
+ case typelib_TypeClass_HYPER:
+ return (*(sal_uInt16 *)pDest == *(sal_Int64 *)pSource);
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ return (*(sal_uInt16 *)pDest == *(sal_uInt64 *)pSource);
+ case typelib_TypeClass_FLOAT:
+ return (*(sal_uInt16 *)pDest == *(float *)pSource);
+ case typelib_TypeClass_DOUBLE:
+ return (*(sal_uInt16 *)pDest == *(double *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_LONG:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ return (*(sal_Int32 *)pDest == *(sal_Int8 *)pSource);
+ case typelib_TypeClass_SHORT:
+ return (*(sal_Int32 *)pDest == *(sal_Int16 *)pSource);
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (*(sal_Int32 *)pDest == *(sal_uInt16 *)pSource);
+ case typelib_TypeClass_LONG:
+ return (*(sal_Int32 *)pDest == *(sal_Int32 *)pSource);
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (*(sal_Int32 *)pDest == *(sal_uInt32 *)pSource);
+ case typelib_TypeClass_HYPER:
+ return (*(sal_Int32 *)pDest == *(sal_Int64 *)pSource);
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ return (*(sal_Int32 *)pDest == *(sal_uInt64 *)pSource);
+ case typelib_TypeClass_FLOAT:
+ return (*(sal_Int32 *)pDest == *(float *)pSource);
+ case typelib_TypeClass_DOUBLE:
+ return (*(sal_Int32 *)pDest == *(double *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ return (*(sal_uInt32 *)pDest == *(sal_Int8 *)pSource);
+ case typelib_TypeClass_SHORT:
+ return (*(sal_uInt32 *)pDest == *(sal_Int16 *)pSource);
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (*(sal_uInt32 *)pDest == *(sal_uInt16 *)pSource);
+ case typelib_TypeClass_LONG:
+ return (*(sal_uInt32 *)pDest == *(sal_Int32 *)pSource);
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (*(sal_uInt32 *)pDest == *(sal_uInt32 *)pSource);
+ case typelib_TypeClass_HYPER:
+ return (*(sal_uInt32 *)pDest == *(sal_Int64 *)pSource);
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ return (*(sal_uInt32 *)pDest == *(sal_uInt64 *)pSource);
+ case typelib_TypeClass_FLOAT:
+ return (*(sal_uInt32 *)pDest == *(float *)pSource);
+ case typelib_TypeClass_DOUBLE:
+ return (*(sal_uInt32 *)pDest == *(double *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_HYPER:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ return (*(sal_Int64 *)pDest == *(sal_Int8 *)pSource);
+ case typelib_TypeClass_SHORT:
+ return (*(sal_Int64 *)pDest == *(sal_Int16 *)pSource);
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (*(sal_Int64 *)pDest == *(sal_uInt16 *)pSource);
+ case typelib_TypeClass_LONG:
+ return (*(sal_Int64 *)pDest == *(sal_Int32 *)pSource);
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (*(sal_Int64 *)pDest == *(sal_uInt32 *)pSource);
+ case typelib_TypeClass_HYPER:
+ return (*(sal_Int64 *)pDest == *(sal_Int64 *)pSource);
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ return (*(sal_Int64 *)pDest == *(sal_uInt64 *)pSource);
+ case typelib_TypeClass_FLOAT:
+ return (*(sal_Int64 *)pDest == *(float *)pSource);
+ case typelib_TypeClass_DOUBLE:
+ return (*(sal_Int64 *)pDest == *(double *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ return (*(sal_uInt64 *)pDest == *(sal_Int8 *)pSource);
+ case typelib_TypeClass_SHORT:
+ return (*(sal_uInt64 *)pDest == *(sal_Int16 *)pSource);
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (*(sal_uInt64 *)pDest == *(sal_uInt16 *)pSource);
+ case typelib_TypeClass_LONG:
+ return (*(sal_uInt64 *)pDest == *(sal_Int32 *)pSource);
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (*(sal_uInt64 *)pDest == *(sal_uInt32 *)pSource);
+ case typelib_TypeClass_HYPER:
+ return (*(sal_uInt64 *)pDest == *(sal_Int64 *)pSource);
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ return (*(sal_uInt64 *)pDest == *(sal_uInt64 *)pSource);
+ case typelib_TypeClass_FLOAT:
+ if (::floor( *(float *)pSource ) != *(float *)pSource || *(float *)pSource < 0)
+ return sal_False;
+ return (*(sal_uInt64 *)pDest == (sal_uInt64)*(float *)pSource);
+ case typelib_TypeClass_DOUBLE:
+ if (::floor( *(double *)pSource ) != *(double *)pSource || *(double *)pSource < 0)
+ return sal_False;
+ return (*(sal_uInt64 *)pDest == (sal_uInt64)*(double *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_FLOAT:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ return (*(float *)pDest == *(sal_Int8 *)pSource);
+ case typelib_TypeClass_SHORT:
+ return (*(float *)pDest == *(sal_Int16 *)pSource);
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (*(float *)pDest == *(sal_uInt16 *)pSource);
+ case typelib_TypeClass_LONG:
+ return (*(float *)pDest == *(sal_Int32 *)pSource);
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (*(float *)pDest == *(sal_uInt32 *)pSource);
+ case typelib_TypeClass_HYPER:
+ return (*(float *)pDest == *(sal_Int64 *)pSource);
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ if (::floor( *(float *)pDest ) != *(float *)pDest || *(float *)pDest < 0)
+ return sal_False;
+ return ((sal_uInt64)*(float *)pDest == *(sal_uInt64 *)pSource);
+ case typelib_TypeClass_FLOAT:
+ return (*(float *)pDest == *(float *)pSource);
+ case typelib_TypeClass_DOUBLE:
+ return (*(float *)pDest == *(double *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_DOUBLE:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ return (*(double *)pDest == *(sal_Int8 *)pSource);
+ case typelib_TypeClass_SHORT:
+ return (*(double *)pDest == *(sal_Int16 *)pSource);
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ return (*(double *)pDest == *(sal_uInt16 *)pSource);
+ case typelib_TypeClass_LONG:
+ return (*(double *)pDest == *(sal_Int32 *)pSource);
+ case typelib_TypeClass_UNSIGNED_LONG:
+ return (*(double *)pDest == *(sal_uInt32 *)pSource);
+ case typelib_TypeClass_HYPER:
+ return (*(double *)pDest == *(sal_Int64 *)pSource);
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ if (::floor( *(double *)pDest ) != *(double *)pDest || *(double *)pDest < 0)
+ return sal_False;
+ return ((sal_uInt64)*(double *)pDest == *(sal_uInt64 *)pSource);
+ case typelib_TypeClass_FLOAT:
+ return (*(double *)pDest == *(float *)pSource);
+ case typelib_TypeClass_DOUBLE:
+ return (*(double *)pDest == *(double *)pSource);
+ }
+ return sal_False;
+ case typelib_TypeClass_STRING:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_STRING:
+ return ((::rtl::OUString *)pDest)->equals( *(::rtl::OUString *)pSource );
+ }
+ return sal_False;
+ case typelib_TypeClass_TYPE:
+ switch (eSourceTypeClass)
+ {
+ case typelib_TypeClass_TYPE:
+ return __type_equals( *(typelib_TypeDescriptionReference **)pDest,
+ *(typelib_TypeDescriptionReference **)pSource );
+ }
+ return sal_False;
+ case typelib_TypeClass_ENUM:
+ return (__type_equals( pDestType, pSourceType ) &&
+ *(int *)pDest == *(int *)pSource);
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ if (! __type_equals( pDestType, pSourceType ))
+ return sal_False;
+ if (pDestTypeDescr)
+ {
+ return __equalStruct(
+ pDest, pSource,
+ (typelib_CompoundTypeDescription *)pDestTypeDescr,
+ queryInterface, release );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
+ sal_Bool bRet = __equalStruct(
+ pDest, pSource,
+ (typelib_CompoundTypeDescription *)pDestTypeDescr,
+ queryInterface, release );
+ TYPELIB_DANGER_RELEASE( pDestTypeDescr );
+ return bRet;
+ }
+ case typelib_TypeClass_UNION:
+ if (__type_equals( pDestType, pSourceType ) &&
+ *(sal_Int64 *)pDest == *(sal_Int64 *)pSource) // same discriminant
+ {
+ sal_Bool bRet;
+ if (pDestTypeDescr)
+ {
+ typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pDest, pDestTypeDescr );
+ bRet = uno_type_equalData(
+ (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType,
+ (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType,
+ queryInterface, release );
+ typelib_typedescriptionreference_release( pSetType );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
+ typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pDest, pDestTypeDescr );
+ bRet = uno_type_equalData(
+ (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType,
+ (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType,
+ queryInterface, release );
+ typelib_typedescriptionreference_release( pSetType );
+ TYPELIB_DANGER_RELEASE( pDestTypeDescr );
+ }
+ return bRet;
+ }
+ return sal_False;
+ case typelib_TypeClass_SEQUENCE:
+ if (__type_equals( pDestType, pSourceType ))
+ {
+ if (pDestTypeDescr)
+ {
+ return __equalSequence(
+ *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
+ ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
+ queryInterface, release );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
+ sal_Bool bRet = __equalSequence(
+ *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
+ ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
+ queryInterface, release );
+ TYPELIB_DANGER_RELEASE( pDestTypeDescr );
+ return bRet;
+ }
+ }
+ return sal_False;
+ case typelib_TypeClass_INTERFACE:
+ if (typelib_TypeClass_INTERFACE == eSourceTypeClass)
+ return __equalObject( *(void **)pDest, *(void **)pSource, queryInterface, release );
+ }
+ return sal_False;
+}
+
+}
+
+#endif
diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx
new file mode 100644
index 000000000000..899909be1d85
--- /dev/null
+++ b/cppu/source/uno/lbenv.cxx
@@ -0,0 +1,981 @@
+/*************************************************************************
+ *
+ * $RCSfile: lbenv.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _OSL_MODULE_H_
+#include <osl/module.h>
+#endif
+#ifndef _OSL_PROCESS_H_
+#include <osl/process.h>
+#endif
+#ifndef _RTL_PROCESS_H_
+#include <rtl/process.h>
+#endif
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#include <stdio.h>
+#ifdef SOLARIS
+#include <alloca.h>
+#else
+#include <malloc.h>
+#endif
+#include <stl/hash_map>
+#include <stl/vector>
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+#ifndef _UNO_LBNAMES_H_
+#include <uno/lbnames.h>
+#endif
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+#ifndef _UNO_ENVIRONMENT_H_
+#include <uno/environment.h>
+#endif
+
+#include "prim.hxx"
+#include "destr.hxx"
+
+#include <com/sun/star/uno/XInterface.hpp>
+
+
+using namespace std;
+using namespace osl;
+using namespace rtl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+
+
+//--------------------------------------------------------------------------------------------------
+inline static sal_Bool td_equals( typelib_InterfaceTypeDescription * pTD1,
+ typelib_InterfaceTypeDescription * pTD2 )
+{
+ return (pTD1 == pTD2 ||
+ (((typelib_TypeDescription *)pTD1)->pTypeName->length ==
+ ((typelib_TypeDescription *)pTD2)->pTypeName->length &&
+ ::rtl_ustr_compare( ((typelib_TypeDescription *)pTD1)->pTypeName->buffer,
+ ((typelib_TypeDescription *)pTD2)->pTypeName->buffer ) == 0));
+}
+
+struct ObjectEntry;
+//--------------------------------------------------------------------------------------------------
+struct InterfaceEntry
+{
+ void * pInterface;
+ uno_freeProxyFunc fpFreeProxy;
+ typelib_InterfaceTypeDescription * pTypeDescr;
+ ObjectEntry * pOEntry;
+
+ inline sal_Bool supports( typelib_InterfaceTypeDescription * pTypeDescr_ ) const;
+};
+//--------------------------------------------------------------------------------------------------
+struct ObjectEntry
+{
+ uno_ExtEnvironment * pEnv;
+ OUString oid;
+ sal_Int32 nRef;
+ vector< InterfaceEntry > aInterfaces;
+
+ inline ObjectEntry( uno_ExtEnvironment * pEnv, const OUString & rOId_ );
+
+ inline void append( void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr,
+ uno_freeProxyFunc fpFreeProxy );
+ inline const InterfaceEntry * find( typelib_InterfaceTypeDescription * pTypeDescr ) const;
+};
+
+//--------------------------------------------------------------------------------------------------
+struct FctPtrHash : public unary_function< const void *, size_t >
+{
+ size_t operator()( const void * pKey ) const
+ { return (size_t)pKey; }
+};
+//--------------------------------------------------------------------------------------------------
+struct FctOUStringHash : public unary_function< const OUString &, size_t >
+{
+ size_t operator()( const OUString & rKey ) const
+ { return rKey.hashCode(); }
+};
+
+// mapping from environment name to environment
+typedef hash_map< OUString, uno_Environment *, FctOUStringHash, equal_to< OUString > > OUString2EnvironmentMap;
+
+// mapping from ptr to object entry
+typedef hash_map< void *, ObjectEntry *, FctPtrHash, equal_to< void * > > Ptr2ObjectMap;
+// mapping from oid to object entry
+typedef hash_map< OUString, ObjectEntry *, FctOUStringHash, equal_to< OUString > > OId2ObjectMap;
+
+//==================================================================================================
+struct EnvironmentsData
+{
+ Mutex aMutex;
+ OUString2EnvironmentMap aName2EnvMap;
+
+ ~EnvironmentsData();
+
+ inline uno_Environment * getEnvironment( const OUString & rTypeName, void * pContext );
+ inline sal_Bool registerEnvironment( uno_Environment * pEnv );
+ inline sal_Bool revokeEnvironment( uno_Environment * pEnv );
+ inline void getRegisteredEnvironments(
+ uno_Environment *** pppEnvs, sal_Int32 * pnLen, uno_memAlloc memAlloc,
+ const OUString & rEnvTypeName );
+};
+//--------------------------------------------------------------------------------------------------
+static EnvironmentsData & getEnvironmentsData()
+{
+ static EnvironmentsData * s_p = 0;
+ if (! s_p)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_p)
+ {
+ static EnvironmentsData s_obj;
+ s_p = &s_obj;
+ }
+ }
+ return *s_p;
+}
+
+//==================================================================================================
+struct uno_DefaultEnvironment : public uno_ExtEnvironment
+{
+ sal_Int32 nRef;
+ oslModule hModule;
+
+ Mutex aAccess;
+ Ptr2ObjectMap aPtr2ObjectMap;
+ OId2ObjectMap aOId2ObjectMap;
+
+ uno_DefaultEnvironment( const OUString & rTypeName_, oslModule hMod_, void * pContext_ );
+ ~uno_DefaultEnvironment();
+};
+
+//__________________________________________________________________________________________________
+inline ObjectEntry::ObjectEntry( uno_ExtEnvironment * pEnv_, const OUString & rOId_ )
+ : pEnv( pEnv_ )
+ , oid( rOId_ )
+ , nRef( 0 )
+{
+ aInterfaces.reserve( 8 );
+}
+//__________________________________________________________________________________________________
+inline void ObjectEntry::append( void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr,
+ uno_freeProxyFunc fpFreeProxy )
+{
+ InterfaceEntry aNewEntry;
+ if (! fpFreeProxy)
+ (*pEnv->acquireInterface)( pEnv, pInterface );
+ aNewEntry.pInterface = pInterface;
+ aNewEntry.fpFreeProxy = fpFreeProxy;
+ aNewEntry.pOEntry = this;
+ typelib_typedescription_acquire( (typelib_TypeDescription *)(aNewEntry.pTypeDescr = pTypeDescr) );
+
+ aInterfaces.push_back( aNewEntry );
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aPtr2ObjectMap[ pInterface ] = this;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool InterfaceEntry::supports( typelib_InterfaceTypeDescription * pTypeDescr_ ) const
+{
+ typelib_InterfaceTypeDescription * pITD = pTypeDescr;
+ while (pITD)
+ {
+ if (td_equals( pITD, pTypeDescr_ ))
+ return sal_True;
+ pITD = pITD->pBaseTypeDescription;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline const InterfaceEntry * ObjectEntry::find( typelib_InterfaceTypeDescription * pTypeDescr ) const
+{
+ // shortcut common case
+ if (((typelib_TypeDescription *)pTypeDescr)->pTypeName->length == sizeof("com.sun.star.uno.XInterface") &&
+ rtl_ustr_ascii_compare( ((typelib_TypeDescription *)pTypeDescr)->pTypeName->buffer,
+ "com.sun.star.uno.XInterface" ) == 0)
+ {
+ return &aInterfaces[0];
+ }
+
+ sal_Int32 nSize = aInterfaces.size();
+ for ( sal_Int32 nPos = 0; nPos < nSize; ++nPos )
+ {
+ OSL_ASSERT( aInterfaces[nPos].pOEntry == this );
+ if (aInterfaces[nPos].supports( pTypeDescr ))
+ return &aInterfaces[nPos];
+ }
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL defenv_registerInterface(
+ uno_ExtEnvironment * pEnv, void ** ppInterface,
+ rtl_uString * pOId, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ OSL_ENSHURE( pEnv && ppInterface && pOId && pTypeDescr, "### null ptr!" );
+ const OUString & rOId = * reinterpret_cast< OUString * >( &pOId );
+
+ ClearableMutexGuard aGuard( static_cast< uno_DefaultEnvironment * >( pEnv )->aAccess );
+
+ const OId2ObjectMap::const_iterator iFind(
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aOId2ObjectMap.find( rOId ) );
+ if (iFind == static_cast< uno_DefaultEnvironment * >( pEnv )->aOId2ObjectMap.end())
+ {
+ ObjectEntry * pOEntry = new ObjectEntry( pEnv, rOId );
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aOId2ObjectMap[ rOId ] = pOEntry;
+ ++pOEntry->nRef; // another register call on object
+ pOEntry->append( *ppInterface, pTypeDescr, 0 );
+ }
+ else // object entry exists
+ {
+ ObjectEntry * pOEntry = (*iFind).second;
+ ++pOEntry->nRef; // another register call on object
+ const InterfaceEntry * pIEntry = pOEntry->find( pTypeDescr );
+
+ if (pIEntry) // type entry exists
+ {
+ if (pIEntry->pInterface != *ppInterface)
+ {
+ void * pInterface = pIEntry->pInterface;
+ (*pEnv->acquireInterface)( pEnv, pInterface );
+ aGuard.clear();
+ (*pEnv->releaseInterface)( pEnv, *ppInterface );
+ *ppInterface = pInterface;
+ }
+ }
+ else
+ {
+ pOEntry->append( *ppInterface, pTypeDescr, 0 );
+ }
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL defenv_registerProxyInterface(
+ uno_ExtEnvironment * pEnv, void ** ppInterface, uno_freeProxyFunc freeProxy,
+ rtl_uString * pOId, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ OSL_ENSHURE( pEnv && ppInterface && pOId && pTypeDescr, "### null ptr!" );
+ const OUString & rOId = * reinterpret_cast< OUString * >( &pOId );
+
+ ClearableMutexGuard aGuard( static_cast< uno_DefaultEnvironment * >( pEnv )->aAccess );
+
+ const OId2ObjectMap::const_iterator iFind(
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aOId2ObjectMap.find( rOId ) );
+ if (iFind == static_cast< uno_DefaultEnvironment * >( pEnv )->aOId2ObjectMap.end())
+ {
+ ObjectEntry * pOEntry = new ObjectEntry( pEnv, rOId );
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aOId2ObjectMap[ rOId ] = pOEntry;
+ ++pOEntry->nRef; // another register call on object
+ pOEntry->append( *ppInterface, pTypeDescr, freeProxy );
+ }
+ else // object entry exists
+ {
+ ObjectEntry * pOEntry = (*iFind).second;
+ ++pOEntry->nRef; // another register call on object
+ const InterfaceEntry * pIEntry = pOEntry->find( pTypeDescr );
+
+ if (pIEntry) // type entry exists
+ {
+ if (pIEntry->pInterface != *ppInterface)
+ {
+ void * pInterface = pIEntry->pInterface;
+ (*pEnv->acquireInterface)( pEnv, pInterface );
+ --pOEntry->nRef; // manual revoke of proxy to be freed
+ aGuard.clear();
+ (*freeProxy)( pEnv, *ppInterface );
+ *ppInterface = pInterface;
+ }
+ }
+ else
+ {
+ pOEntry->append( *ppInterface, pTypeDescr, freeProxy );
+ }
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL defenv_revokeInterface(
+ uno_ExtEnvironment * pEnv, void * pInterface )
+{
+ OSL_ENSHURE( pEnv && pInterface, "### null ptr!" );
+ ClearableMutexGuard aGuard( static_cast< uno_DefaultEnvironment * >( pEnv )->aAccess );
+
+ const Ptr2ObjectMap::const_iterator iFind(
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aPtr2ObjectMap.find( pInterface ) );
+ OSL_ASSERT( iFind != static_cast< uno_DefaultEnvironment * >( pEnv )->aPtr2ObjectMap.end() );
+ if (! --(*iFind).second->nRef)
+ {
+ ObjectEntry * pOEntry = (*iFind).second;
+ OSL_ASSERT( pEnv == pOEntry->pEnv );
+ // cleanup maps
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aOId2ObjectMap.erase( pOEntry->oid );
+ sal_Int32 nPos;
+ for ( nPos = pOEntry->aInterfaces.size(); nPos--; )
+ {
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aPtr2ObjectMap.erase(
+ pOEntry->aInterfaces[nPos].pInterface );
+ }
+
+ // the last proxy interface of the environment might kill this environment,
+ // because of releasing its language binding!!!
+ aGuard.clear();
+
+ // release interfaces
+ for ( nPos = pOEntry->aInterfaces.size(); nPos--; )
+ {
+ const InterfaceEntry & rEntry = pOEntry->aInterfaces[nPos];
+ typelib_typedescription_release( (typelib_TypeDescription *)rEntry.pTypeDescr );
+ if (rEntry.fpFreeProxy) // is proxy or used interface?
+ (*rEntry.fpFreeProxy)( pEnv, rEntry.pInterface );
+ else
+ (*pEnv->releaseInterface)( pEnv, rEntry.pInterface );
+ }
+
+ delete pOEntry;
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL defenv_getObjectIdentifier(
+ uno_ExtEnvironment * pEnv, rtl_uString ** ppOId, void * pInterface )
+{
+ OSL_ENSHURE( pEnv && ppOId && pInterface, "### null ptr!" );
+ if (*ppOId)
+ {
+ rtl_uString_release( *ppOId );
+ *ppOId = 0;
+ }
+
+ ClearableMutexGuard aGuard( static_cast< uno_DefaultEnvironment * >( pEnv )->aAccess );
+
+ const Ptr2ObjectMap::const_iterator iFind(
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aPtr2ObjectMap.find( pInterface ) );
+ if (iFind != static_cast< uno_DefaultEnvironment * >( pEnv )->aPtr2ObjectMap.end())
+ {
+ rtl_uString_acquire( *ppOId = (*iFind).second->oid.pData );
+ }
+ else
+ {
+ aGuard.clear();
+ (*pEnv->computeObjectIdentifier)( pEnv, ppOId, pInterface );
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL defenv_getRegisteredInterface(
+ uno_ExtEnvironment * pEnv, void ** ppInterface,
+ rtl_uString * pOId, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ OSL_ENSHURE( pEnv && ppInterface && pOId && pTypeDescr, "### null ptr!" );
+ if (*ppInterface)
+ {
+ (*pEnv->releaseInterface)( pEnv, *ppInterface );
+ *ppInterface = 0;
+ }
+
+ const OUString & rOId = * reinterpret_cast< OUString * >( &pOId );
+
+ MutexGuard aGuard( static_cast< uno_DefaultEnvironment * >( pEnv )->aAccess );
+
+ const OId2ObjectMap::const_iterator iFind(
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aOId2ObjectMap.find( rOId ) );
+ if (iFind != static_cast< uno_DefaultEnvironment * >( pEnv )->aOId2ObjectMap.end())
+ {
+ const InterfaceEntry * pIEntry = (*iFind).second->find( pTypeDescr );
+ if (pIEntry)
+ (*pEnv->acquireInterface)( pEnv, *ppInterface = pIEntry->pInterface );
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL defenv_getRegisteredInterfaces(
+ uno_ExtEnvironment * pEnv, void *** pppInterfaces, sal_Int32 * pnLen, uno_memAlloc memAlloc )
+{
+ OSL_ENSHURE( pEnv && pppInterfaces && pnLen && memAlloc, "### null ptr!" );
+ MutexGuard aGuard( static_cast< uno_DefaultEnvironment * >( pEnv )->aAccess );
+
+ sal_Int32 nLen = static_cast< uno_DefaultEnvironment * >( pEnv )->aPtr2ObjectMap.size();
+ sal_Int32 nPos = 0;
+ void ** ppInterfaces = (void **)(*memAlloc)( nLen * sizeof(void *) );
+
+ Ptr2ObjectMap::const_iterator iPos(
+ static_cast< uno_DefaultEnvironment * >( pEnv )->aPtr2ObjectMap.begin() );
+ while (iPos != static_cast< uno_DefaultEnvironment * >( pEnv )->aPtr2ObjectMap.end())
+ {
+ (*pEnv->acquireInterface)( pEnv, ppInterfaces[nPos++] = (*iPos).first );
+ ++iPos;
+ }
+
+ *pppInterfaces = ppInterfaces;
+ *pnLen = nLen;
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL defenv_acquire( uno_Environment * pEnv )
+{
+ osl_incrementInterlockedCount( &((uno_DefaultEnvironment *)pEnv)->nRef );
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL defenv_release( uno_Environment * pEnv )
+{
+ MutexGuard aGuard( getEnvironmentsData().aMutex );
+ if (! osl_decrementInterlockedCount( &((uno_DefaultEnvironment *)pEnv)->nRef ))
+ {
+ getEnvironmentsData().revokeEnvironment( pEnv );
+ delete (uno_DefaultEnvironment *)pEnv;
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL defenv_dispose( uno_Environment * pEnv )
+{
+}
+
+//__________________________________________________________________________________________________
+uno_DefaultEnvironment::uno_DefaultEnvironment(
+ const OUString & rTypeName_, void * pContext_, oslModule hMod_ )
+ : nRef( 0 )
+ , hModule( hMod_ )
+{
+ ((uno_Environment *)this)->pReserved = 0;
+ // functions
+ ((uno_Environment *)this)->acquire = defenv_acquire;
+ ((uno_Environment *)this)->release = defenv_release;
+ ((uno_Environment *)this)->dispose = defenv_dispose;
+ ((uno_Environment *)this)->pExtEnv = this;
+ // identifier
+ rtl_uString_acquire( rTypeName_.pData );
+ ((uno_Environment *)this)->pTypeName = rTypeName_.pData;
+ ((uno_Environment *)this)->pContext = pContext_;
+
+ // will be late initialized
+ ((uno_Environment *)this)->environmentDisposing = 0;
+
+ uno_ExtEnvironment::registerInterface = defenv_registerInterface;
+ uno_ExtEnvironment::registerProxyInterface = defenv_registerProxyInterface;
+ uno_ExtEnvironment::revokeInterface = defenv_revokeInterface;
+ uno_ExtEnvironment::getObjectIdentifier = defenv_getObjectIdentifier;
+ uno_ExtEnvironment::getRegisteredInterface = defenv_getRegisteredInterface;
+ uno_ExtEnvironment::getRegisteredInterfaces = defenv_getRegisteredInterfaces;
+
+}
+//__________________________________________________________________________________________________
+uno_DefaultEnvironment::~uno_DefaultEnvironment()
+{
+ OSL_ENSHURE( aOId2ObjectMap.empty(), "### object entries left!" );
+
+ if (((uno_Environment *)this)->environmentDisposing)
+ (*((uno_Environment *)this)->environmentDisposing)( (uno_Environment *)this );
+ if (hModule)
+ osl_unloadModule( hModule );
+
+ rtl_uString_release( ((uno_Environment *)this)->pTypeName );
+}
+
+//==================================================================================================
+static void writeLine( void * stream, const sal_Char * pLine, const sal_Char * pFilter )
+{
+ if (pFilter && *pFilter)
+ {
+ // lookup pFilter in pLine
+ while (*pLine)
+ {
+ if (*pLine == *pFilter)
+ {
+ sal_Int32 nPos = 1;
+ while (pLine[nPos] && pFilter[nPos] == pLine[nPos])
+ ++nPos;
+ if (! pFilter[nPos])
+ {
+ if (stream)
+ {
+ fprintf( (FILE *)stream, "%s\n", pLine );
+ }
+ else
+ {
+ OSL_TRACE( pLine );
+ OSL_TRACE( "\n" );
+ }
+ }
+ }
+ ++pLine;
+ }
+ }
+ else
+ {
+ if (stream)
+ {
+ fprintf( (FILE *)stream, "%s\n", pLine );
+ }
+ else
+ {
+ OSL_TRACE( pLine );
+ OSL_TRACE( "\n" );
+ }
+ }
+}
+//==================================================================================================
+static void writeLine( void * stream, const OUString & rLine, const sal_Char * pFilter )
+{
+ OString aLine( OUStringToOString( rLine, RTL_TEXTENCODING_ASCII_US ) );
+ writeLine( stream, aLine.getStr(), pFilter );
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_dumpEnvironment(
+ void * stream, uno_Environment * pEnv, const sal_Char * pFilter )
+{
+ OSL_ENSHURE( pEnv, "### null ptr!" );
+ OUStringBuffer buf;
+
+ if (! pEnv->pExtEnv)
+ {
+ writeLine( stream, "##############################################################################", pFilter );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("environment: ") );
+ buf.append( pEnv->pTypeName );
+ writeLine( stream, buf.makeStringAndClear(), pFilter );
+ writeLine( stream, "NO INTERFACE INFORMATION AVAILABLE!", pFilter );
+ return;
+ }
+
+ writeLine( stream, "##############################################################################", pFilter );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("environment dump: ") );
+ buf.append( pEnv->pTypeName );
+ writeLine( stream, buf.makeStringAndClear(), pFilter );
+
+ MutexGuard aGuard( ((uno_DefaultEnvironment *)pEnv)->aAccess );
+
+ OId2ObjectMap::const_iterator iPos( ((uno_DefaultEnvironment *)pEnv)->aOId2ObjectMap.begin() );
+ while (iPos != ((uno_DefaultEnvironment *)pEnv)->aOId2ObjectMap.end())
+ {
+ ObjectEntry * pOEntry = (*iPos).second;
+ OSL_ASSERT( (uno_DefaultEnvironment *)pEnv == pOEntry->pEnv );
+
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("+ object entry: nRef=") );
+ buf.append( pOEntry->nRef, 10 );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("; oid=\"") );
+ buf.append( pOEntry->oid );
+ buf.append( (sal_Unicode)'\"' );
+ writeLine( stream, buf.makeStringAndClear(), pFilter );
+
+ for ( sal_Int32 nPos = pOEntry->aInterfaces.size(); nPos--; )
+ {
+ const InterfaceEntry & rIEntry = pOEntry->aInterfaces[nPos];
+ OSL_ASSERT( rIEntry.pOEntry == pOEntry );
+
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" - ") );
+ buf.append( ((typelib_TypeDescription *)rIEntry.pTypeDescr)->pTypeName );
+ if (rIEntry.fpFreeProxy)
+ {
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("; proxy free=0x") );
+ buf.append( (sal_Int64)rIEntry.fpFreeProxy, 16 );
+ }
+ else
+ {
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("; original") );
+ }
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("; ptr=0x") );
+ buf.append( (sal_Int64)rIEntry.pInterface, 16 );
+ writeLine( stream, buf.makeStringAndClear(), pFilter );
+ }
+ ++iPos;
+ }
+ writeLine( stream, "##############################################################################", pFilter );
+}
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_dumpEnvironmentByName(
+ void * stream, rtl_uString * pEnvTypeName, const sal_Char * pFilter )
+{
+ uno_Environment * pEnv = 0;
+ uno_getEnvironment( &pEnv, pEnvTypeName, 0 );
+ if (pEnv)
+ {
+ uno_dumpEnvironment( stream, pEnv, pFilter );
+ (*pEnv->release)( pEnv );
+ }
+ else
+ {
+ OUStringBuffer buf( 32 );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("environment \"") );
+ buf.append( pEnvTypeName );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\" does not exist!") );
+ writeLine( stream, buf.makeStringAndClear(), pFilter );
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+inline static const OUString & unoenv_getStaticOIdPart()
+{
+ static OUString * s_pStaticOidPart = 0;
+ if (! s_pStaticOidPart)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pStaticOidPart)
+ {
+ OUStringBuffer aRet( 64 );
+ aRet.appendAscii( RTL_CONSTASCII_STRINGPARAM("];") );
+ // pid
+ oslProcessInfo info;
+ info.Size = sizeof(oslProcessInfo);
+ if (osl_getProcessInfo( 0, osl_Process_IDENTIFIER, &info ) == osl_Process_E_None)
+ aRet.append( (sal_Int64)info.Ident, 16 );
+ else
+ aRet.appendAscii( RTL_CONSTASCII_STRINGPARAM("unknown process id") );
+ // good guid
+ sal_uInt8 ar[16];
+ rtl_getGlobalProcessId( ar );
+ aRet.append( (sal_Unicode)';' );
+ for ( sal_Int32 i = 0; i < 16; ++i )
+ aRet.append( (sal_Int32)ar[i], 16 );
+
+ static OUString s_aStaticOidPart( aRet.makeStringAndClear() );
+ s_pStaticOidPart = &s_aStaticOidPart;
+ }
+ }
+ return *s_pStaticOidPart;
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL unoenv_computeObjectIdentifier(
+ uno_ExtEnvironment * pEnv, rtl_uString ** ppOId, void * pInterface )
+{
+ OSL_ENSHURE( pEnv && ppOId && pInterface, "### null ptr!" );
+ if (*ppOId)
+ {
+ rtl_uString_release( *ppOId );
+ *ppOId = 0;
+ }
+
+ typelib_InterfaceTypeDescription * pTXInterfaceDescr = 0;
+ const Type & rXIType = ::getCppuType( (const Reference< XInterface > *)0 );
+ typelib_TypeDescription * pMTqueryInterface = __getQueryInterfaceTypeDescr();
+
+ void * pArgs[1];
+ pArgs[0] = const_cast< Type * >( &rXIType );
+ uno_Any aRet, aExc;
+ uno_Any * pExc = &aExc;
+
+ (*((uno_Interface *)pInterface)->pDispatcher)(
+ (uno_Interface *)pInterface, pMTqueryInterface, &aRet, pArgs, &pExc );
+
+ OSL_ENSHURE( !pExc, "### Exception occured during queryInterface()!" );
+ if (pExc) // cleanup exception object
+ {
+ __destructAny( pExc, 0 );
+ }
+ else
+ {
+ OSL_ENSHURE( aRet.pType->eTypeClass == typelib_TypeClass_INTERFACE,
+ "### cannot query for XInterface!" );
+ if (aRet.pType->eTypeClass == typelib_TypeClass_INTERFACE)
+ {
+ // interface
+ OUStringBuffer oid( 64 );
+ oid.append( (sal_Int64)*(void **)aRet.pData, 16 );
+ oid.append( (sal_Unicode)';' );
+ // environment[context]
+ oid.append( ((uno_Environment *)pEnv)->pTypeName );
+ oid.append( (sal_Unicode)'[' );
+ oid.append( (sal_Int64)((uno_Environment *)pEnv)->pContext, 16 );
+ // process;good guid
+ oid.append( unoenv_getStaticOIdPart() );
+ OUString aStr( oid.makeStringAndClear() );
+ rtl_uString_acquire( *ppOId = aStr.pData );
+ }
+ __destructAny( &aRet, 0 );
+ }
+
+ typelib_typedescription_release( pMTqueryInterface );
+}
+//==================================================================================================
+static void SAL_CALL unoenv_acquireInterface( uno_ExtEnvironment *, void * pUnoI )
+{
+ (*((uno_Interface *)pUnoI)->acquire)( (uno_Interface *)pUnoI );
+}
+//==================================================================================================
+static void SAL_CALL unoenv_releaseInterface( uno_ExtEnvironment *, void * pUnoI )
+{
+ (*((uno_Interface *)pUnoI)->release)( (uno_Interface *)pUnoI );
+}
+
+//__________________________________________________________________________________________________
+EnvironmentsData::~EnvironmentsData()
+{
+ MutexGuard aGuard( aMutex );
+
+ OUString2EnvironmentMap::const_iterator iPos( aName2EnvMap.begin() );
+#ifdef CPPU_ALLOW_ASSERTIONS
+ OSL_ENSHURE( aName2EnvMap.empty(), "### unrevoked environments! living proxies?" );
+ while (iPos != aName2EnvMap.end())
+ {
+ ::uno_dumpEnvironment( 0, (*iPos).second, 0 );
+ ++iPos;
+ }
+ iPos = aName2EnvMap.begin();
+#endif
+ while (iPos != aName2EnvMap.end())
+ {
+ (*(*iPos).second->dispose)( (*iPos).second );
+ ++iPos;
+ }
+}
+//__________________________________________________________________________________________________
+inline uno_Environment * EnvironmentsData::getEnvironment(
+ const OUString & rEnvTypeName, void * pContext )
+{
+ uno_Environment * pEnv = 0;
+
+ OUString aKey( OUString::valueOf( (sal_Int32)pContext ) );
+ aKey += rEnvTypeName;
+
+ // try to find registered mapping
+ MutexGuard aGuard( aMutex );
+ const OUString2EnvironmentMap::const_iterator iFind( aName2EnvMap.find( aKey ) );
+ if (iFind != aName2EnvMap.end())
+ {
+ pEnv = (*iFind).second;
+ (*pEnv->acquire)( pEnv );
+ }
+
+ return pEnv;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool EnvironmentsData::registerEnvironment( uno_Environment * pEnv )
+{
+ OSL_ENSHURE( pEnv, "### null ptr!" );
+ OUString aKey( OUString::valueOf( (sal_Int64)pEnv->pContext ) );
+ aKey += pEnv->pTypeName;
+
+ // try to find environment
+ MutexGuard aGuard( aMutex );
+ const OUString2EnvironmentMap::const_iterator iFind( aName2EnvMap.find( aKey ) );
+ OSL_ENSHURE( iFind == aName2EnvMap.end(), "### environment already registered!" );
+ if (iFind == aName2EnvMap.end())
+ {
+ aName2EnvMap[ aKey ] = pEnv;
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool EnvironmentsData::revokeEnvironment( uno_Environment * pEnv )
+{
+ OSL_ENSHURE( pEnv, "### null ptr!" );
+ OUString aKey( OUString::valueOf( (sal_Int64)pEnv->pContext ) );
+ aKey += pEnv->pTypeName;
+
+ MutexGuard aGuard( aMutex );
+ OSL_ENSHURE( aName2EnvMap.find( aKey ) != aName2EnvMap.end(), "### env reg error!" );
+ aName2EnvMap.erase( aKey );
+ return sal_True;
+}
+//__________________________________________________________________________________________________
+inline void EnvironmentsData::getRegisteredEnvironments(
+ uno_Environment *** pppEnvs, sal_Int32 * pnLen, uno_memAlloc memAlloc,
+ const OUString & rEnvTypeName )
+{
+ OSL_ENSHURE( pppEnvs && pnLen && memAlloc, "### null ptr!" );
+
+ uno_Environment ** ppFound;
+ sal_Int32 nSize = 0;
+
+ {
+ MutexGuard aGuard( aMutex );
+ // max size
+ ppFound = (uno_Environment **)alloca( sizeof(uno_Environment *) * aName2EnvMap.size() );
+ // find matching environment
+ for ( OUString2EnvironmentMap::const_iterator iPos( aName2EnvMap.begin() );
+ iPos != aName2EnvMap.end(); ++iPos )
+ {
+ uno_Environment * pEnv = (*iPos).second;
+ if (!rEnvTypeName.getLength() || rEnvTypeName.equals( pEnv->pTypeName ))
+ {
+ (*pEnv->acquire)( pEnv );
+ ppFound[nSize++] = pEnv;
+ }
+ }
+ }
+
+ *pnLen = nSize;
+ if (nSize)
+ {
+ *pppEnvs = (uno_Environment **)(*memAlloc)( sizeof(uno_Environment *) * nSize );
+ OSL_ASSERT( *pppEnvs );
+ while (nSize--)
+ {
+ (*pppEnvs)[nSize] = ppFound[nSize];
+ }
+ }
+ else
+ {
+ *pppEnvs = 0;
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+static uno_Environment * initDefaultEnvironment( const OUString & rEnvTypeName, void * pContext )
+{
+ uno_Environment * pEnv = 0;
+
+ // create default environment
+ if (rEnvTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_UNO) ))
+ {
+ uno_DefaultEnvironment * pDefEnv = new uno_DefaultEnvironment( rEnvTypeName, pContext, 0 );
+ pEnv = (uno_Environment *)pDefEnv;
+ (*pEnv->acquire)( pEnv );
+ pDefEnv->computeObjectIdentifier = unoenv_computeObjectIdentifier;
+ pDefEnv->acquireInterface = unoenv_acquireInterface;
+ pDefEnv->releaseInterface = unoenv_releaseInterface;
+ }
+ else
+ {
+ // late init with some code from matching uno language binding
+ OUStringBuffer aLibName( 16 );
+#ifdef SAL_UNX
+ aLibName.appendAscii( RTL_CONSTASCII_STRINGPARAM("lib") );
+ aLibName.append( rEnvTypeName );
+ aLibName.appendAscii( RTL_CONSTASCII_STRINGPARAM("_uno.so") );
+#else
+ aLibName.append( rEnvTypeName );
+ aLibName.appendAscii( RTL_CONSTASCII_STRINGPARAM("_uno.dll") );
+#endif
+ OUString aStr( aLibName.makeStringAndClear() );
+ // will be unloaded by environment
+ oslModule hMod = osl_loadModule( aStr.pData, SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY );
+ if (hMod)
+ {
+ OUString aSymbolName( RTL_CONSTASCII_USTRINGPARAM(UNO_INIT_ENVIRONMENT) );
+ uno_initEnvironmentFunc fpInit =
+ (uno_initEnvironmentFunc)osl_getSymbol( hMod, aSymbolName.pData );
+ if (fpInit)
+ {
+ pEnv = (uno_Environment *)new uno_DefaultEnvironment( rEnvTypeName, pContext, hMod );
+ (*pEnv->acquire)( pEnv );
+ (*fpInit)( pEnv ); // init of environment
+ }
+ else
+ {
+ osl_unloadModule( hMod );
+ }
+ }
+ }
+
+ return pEnv;
+}
+
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL anonymous_defenv_release( uno_Environment * pEnv )
+{
+ if (! osl_decrementInterlockedCount( &((uno_DefaultEnvironment *)pEnv)->nRef ))
+ delete (uno_DefaultEnvironment *)pEnv;
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_createEnvironment(
+ uno_Environment ** ppEnv, rtl_uString * pEnvTypeName, void * pContext )
+{
+ OSL_ENSHURE( ppEnv, "### null ptr!" );
+ if (*ppEnv)
+ (*(*ppEnv)->release)( *ppEnv );
+
+ *ppEnv = initDefaultEnvironment(
+ * reinterpret_cast< OUString * >( &pEnvTypeName ), pContext );
+ (*ppEnv)->release = anonymous_defenv_release; // patch release func
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_getEnvironment(
+ uno_Environment ** ppEnv, rtl_uString * pEnvTypeName, void * pContext )
+{
+ OSL_ENSHURE( ppEnv, "### null ptr!" );
+ if (*ppEnv)
+ (*(*ppEnv)->release)( *ppEnv );
+
+ const OUString & rEnvTypeName = * reinterpret_cast< OUString * >( &pEnvTypeName );
+
+ MutexGuard aGuard( getEnvironmentsData().aMutex );
+ *ppEnv = getEnvironmentsData().getEnvironment( rEnvTypeName, pContext );
+
+ if (! *ppEnv)
+ {
+ if (*ppEnv = initDefaultEnvironment( rEnvTypeName, pContext )) // register new environment
+ getEnvironmentsData().registerEnvironment( *ppEnv );
+ }
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_getRegisteredEnvironments(
+ uno_Environment *** pppEnvs, sal_Int32 * pnLen, uno_memAlloc memAlloc,
+ rtl_uString * pEnvTypeName )
+{
+ getEnvironmentsData().getRegisteredEnvironments(
+ pppEnvs, pnLen, memAlloc,
+ (pEnvTypeName ? OUString( pEnvTypeName ) : OUString()) );
+}
diff --git a/cppu/source/uno/lbmap.cxx b/cppu/source/uno/lbmap.cxx
new file mode 100644
index 000000000000..d79a9a9e7755
--- /dev/null
+++ b/cppu/source/uno/lbmap.cxx
@@ -0,0 +1,657 @@
+/*************************************************************************
+ *
+ * $RCSfile: lbmap.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef CPPU_ASSERTIONS
+#define CPPU_TRACE(x) OSL_TRACE(x)
+#else
+#define CPPU_TRACE(x)
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _OSL_MODULE_H_
+#include <osl/module.h>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+#ifndef _UNO_ENVIRONMENT_HXX_
+#include <uno/environment.hxx>
+#endif
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <stl/hash_map>
+#include <stl/set>
+#include <stl/algorithm>
+
+
+using namespace std;
+using namespace osl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+
+//==================================================================================================
+struct MappingEntry
+{
+ sal_Int32 nRef;
+ uno_Mapping * pMapping;
+ uno_freeMappingFunc freeMapping;
+ OUString aMappingName;
+
+ MappingEntry( uno_Mapping * pMapping_, uno_freeMappingFunc freeMapping_,
+ const OUString & rMappingName_ )
+ : nRef( 1 )
+ , pMapping( pMapping_ )
+ , freeMapping( freeMapping_ )
+ , aMappingName( rMappingName_ )
+ {}
+};
+//--------------------------------------------------------------------------------------------------
+struct FctOUStringHash : public unary_function< const OUString &, size_t >
+{
+ size_t operator()( const OUString & rKey ) const
+ { return (size_t)rKey.hashCode(); }
+};
+//--------------------------------------------------------------------------------------------------
+struct FctPtrHash : public unary_function< uno_Mapping *, size_t >
+{
+ size_t operator()( uno_Mapping * pKey ) const
+ { return (size_t)pKey; }
+};
+
+typedef hash_map< OUString, MappingEntry *, FctOUStringHash, equal_to< OUString > > t_OUString2Entry;
+typedef hash_map< uno_Mapping *, MappingEntry *, FctPtrHash, equal_to< uno_Mapping * > > t_Mapping2Entry;
+
+typedef set< uno_getMappingFunc > t_CallbackSet;
+typedef set< OUString > t_OUStringSet;
+
+//==================================================================================================
+struct MappingsData
+{
+ Mutex aMappingsMutex;
+ t_OUString2Entry aName2Entry;
+ t_Mapping2Entry aMapping2Entry;
+
+ Mutex aCallbacksMutex;
+ t_CallbackSet aCallbacks;
+
+ Mutex aNegativeLibsMutex;
+ t_OUStringSet aNegativeLibs;
+ ~MappingsData();
+};
+//__________________________________________________________________________________________________
+MappingsData::~MappingsData()
+{
+#ifdef CPPU_ASSERTIONS
+ OSL_ENSHURE( aName2Entry.empty() && aMapping2Entry.empty(), "### unrevoked mappings!" );
+ t_OUString2Entry::const_iterator iPos( aName2Entry.begin() );
+ while (iPos != aName2Entry.end())
+ {
+ CPPU_TRACE( "\n### unrevoked mapping: " );
+ MappingEntry * pEntry = (*iPos).second;
+ OString aName( OUStringToOString( pEntry->aMappingName, RTL_TEXTENCODING_ASCII_US ) );
+ CPPU_TRACE( aName.getStr() );
+ ++iPos;
+ }
+ OSL_ENSHURE( aCallbacks.empty(), "### callbacks left!" );
+ if (aCallbacks.size())
+ {
+ CPPU_TRACE( "\n### " );
+ OString aSize( OString::valueOf( (sal_Int32)aCallbacks.size() ) );
+ CPPU_TRACE( aSize.getStr() );
+ CPPU_TRACE( " unrevoked callbacks" );
+ }
+#endif
+}
+//--------------------------------------------------------------------------------------------------
+static MappingsData & getMappingsData()
+{
+ static MappingsData * s_p = 0;
+ if (! s_p)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_p)
+ {
+ static MappingsData s_obj;
+ s_p = &s_obj;
+ }
+ }
+ return *s_p;
+}
+
+/**
+ * This class mediates two different mapping via uno, e.g. form any language to uno,
+ * then from uno to any other language.
+ */
+struct uno_Mediate_Mapping : public uno_Mapping
+{
+ sal_Int32 nRef;
+
+ Environment aFrom;
+ Environment aTo;
+
+ Mapping aFrom2Uno;
+ Mapping aUno2To;
+
+ OUString aAddPurpose;
+
+ uno_Mediate_Mapping( const Environment & rFrom_, const Environment & rTo_,
+ const Mapping & rFrom2Uno_, const Mapping & rUno2To_,
+ const OUString & rAddPurpose );
+};
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL mediate_free( uno_Mapping * pMapping )
+{
+ delete static_cast< uno_Mediate_Mapping * >( pMapping );
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL mediate_acquire( uno_Mapping * pMapping )
+{
+ if (1 == osl_incrementInterlockedCount( & static_cast< uno_Mediate_Mapping * >( pMapping )->nRef ))
+ {
+ uno_registerMapping( &pMapping, mediate_free,
+ static_cast< uno_Mediate_Mapping * >( pMapping )->aFrom.get(),
+ static_cast< uno_Mediate_Mapping * >( pMapping )->aTo.get(),
+ static_cast< uno_Mediate_Mapping * >( pMapping )->aAddPurpose.pData );
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL mediate_release( uno_Mapping * pMapping )
+{
+ if (! osl_decrementInterlockedCount( & static_cast< uno_Mediate_Mapping * >( pMapping )->nRef ))
+ {
+ uno_revokeMapping( pMapping );
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL mediate_mapInterface( uno_Mapping * pMapping,
+ void ** ppOut, void * pInterface,
+ typelib_InterfaceTypeDescription * pInterfaceTypeDescr )
+{
+ OSL_ENSHURE( pMapping && ppOut, "### null ptr!" );
+ if (pMapping && ppOut)
+ {
+ uno_Interface * pUnoI = 0;
+
+ uno_Mapping * pFrom2Uno = static_cast< uno_Mediate_Mapping * >( pMapping )->aFrom2Uno.get();
+ uno_Mapping * pUno2To = static_cast< uno_Mediate_Mapping * >( pMapping )->aUno2To.get();
+
+ (*pFrom2Uno->mapInterface)( pFrom2Uno, (void **)&pUnoI, pInterface, pInterfaceTypeDescr );
+ if (pUnoI)
+ {
+ (*pUno2To->mapInterface)( pUno2To, ppOut, pUnoI, pInterfaceTypeDescr );
+ (*pUnoI->release)( pUnoI );
+ }
+ }
+}
+//__________________________________________________________________________________________________
+uno_Mediate_Mapping::uno_Mediate_Mapping( const Environment & rFrom_, const Environment & rTo_,
+ const Mapping & rFrom2Uno_, const Mapping & rUno2To_,
+ const OUString & rAddPurpose_ )
+ : nRef( 1 )
+ , aFrom( rFrom_ )
+ , aTo( rTo_ )
+ , aFrom2Uno( rFrom2Uno_ )
+ , aUno2To( rUno2To_ )
+ , aAddPurpose( rAddPurpose_ )
+{
+ uno_Mapping::acquire = mediate_acquire;
+ uno_Mapping::release = mediate_release;
+ uno_Mapping::mapInterface = mediate_mapInterface;
+}
+
+//==================================================================================================
+static inline OUString getMappingName(
+ const Environment & rFrom, const Environment & rTo, const OUString & rAddPurpose )
+{
+ OUStringBuffer aKey( 64 );
+ aKey.append( rAddPurpose );
+ aKey.append( (sal_Unicode)';' );
+ aKey.append( rFrom.getTypeName() );
+ aKey.append( (sal_Unicode)'[' );
+ aKey.append( (sal_Int64)rFrom.get(), 16 );
+ aKey.appendAscii( RTL_CONSTASCII_STRINGPARAM("];") );
+ aKey.append( rTo.getTypeName() );
+ aKey.append( (sal_Unicode)'[' );
+ aKey.append( (sal_Int64)rTo.get(), 16 );
+ aKey.append( (sal_Unicode)']' );
+ return aKey.makeStringAndClear();
+}
+//==================================================================================================
+static inline OUString getLibName(
+ const Environment & rFrom, const Environment & rTo, const OUString & rAddPurpose )
+{
+ OUStringBuffer aLibName( 16 );
+#ifdef SAL_UNX
+ aLibName.appendAscii( RTL_CONSTASCII_STRINGPARAM("lib") );
+ if (rAddPurpose.getLength())
+ {
+ aLibName.append( rAddPurpose );
+ aLibName.append( (sal_Unicode)'_' );
+ }
+ aLibName.append( rFrom.getTypeName() );
+ aLibName.append( (sal_Unicode)'_' );
+ aLibName.append( rTo.getTypeName() );
+ aLibName.appendAscii( RTL_CONSTASCII_STRINGPARAM(".so") );
+#else
+ if (rAddPurpose.getLength())
+ {
+ aLibName.append( rAddPurpose );
+ aLibName.append( (sal_Unicode)'_' );
+ }
+ aLibName.append( rFrom.getTypeName() );
+ aLibName.append( (sal_Unicode)'_' );
+ aLibName.append( rTo.getTypeName() );
+#ifndef OS2
+ aLibName.appendAscii( RTL_CONSTASCII_STRINGPARAM(".dll") );
+#endif
+#endif
+ return aLibName.makeStringAndClear();
+}
+
+//--------------------------------------------------------------------------------------------------
+static inline void setNegativeModule( const OUString & rName )
+{
+ MappingsData & rData = getMappingsData();
+ MutexGuard aGuard( rData.aNegativeLibsMutex );
+ rData.aNegativeLibs.insert( rName );
+}
+//--------------------------------------------------------------------------------------------------
+static inline oslModule loadModule( const OUString & rName )
+{
+ sal_Bool bNeg;
+ {
+ MappingsData & rData = getMappingsData();
+ MutexGuard aGuard( rData.aNegativeLibsMutex );
+ const t_OUStringSet::const_iterator iFind( rData.aNegativeLibs.find( rName ) );
+ bNeg = (iFind != rData.aNegativeLibs.end());
+ }
+
+ if (! bNeg)
+ {
+ oslModule hModule = osl_loadModule( rName.pData, SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY );
+ if (hModule)
+ return hModule;
+ setNegativeModule( rName ); // no load again
+ }
+ return 0;
+}
+//==================================================================================================
+static Mapping loadExternalMapping(
+ const Environment & rFrom, const Environment & rTo, const OUString & rAddPurpose )
+{
+ OSL_ASSERT( rFrom.is() && rTo.is() );
+ if (rFrom.is() && rTo.is())
+ {
+ // find proper lib
+ oslModule hModule = 0;
+ OUString aName;
+
+ if (rFrom.getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_UNO) ))
+ hModule = loadModule( aName = getLibName( rTo, rFrom, rAddPurpose ) );
+ if (! hModule)
+ hModule = loadModule( aName = getLibName( rFrom, rTo, rAddPurpose ) );
+ if (! hModule)
+ hModule = loadModule( aName = getLibName( rTo, rFrom, rAddPurpose ) );
+
+ if (hModule)
+ {
+ OUString aSymbolName( RTL_CONSTASCII_USTRINGPARAM(UNO_EXT_GETMAPPING) );
+ uno_ext_getMappingFunc fpGetMapFunc =
+ (uno_ext_getMappingFunc)osl_getSymbol( hModule, aSymbolName.pData );
+ if (fpGetMapFunc)
+ {
+ Mapping aExt;
+ (*fpGetMapFunc)( (uno_Mapping **)&aExt, rFrom.get(), rTo.get() );
+ if (aExt.is())
+ return aExt;
+ }
+ osl_unloadModule( hModule );
+ setNegativeModule( aName );
+ }
+ }
+ return Mapping();
+}
+
+//==================================================================================================
+static Mapping getDirectMapping(
+ const Environment & rFrom, const Environment & rTo, const OUString & rAddPurpose = OUString() )
+{
+ OSL_ASSERT( rFrom.is() && rTo.is() );
+ if (rFrom.is() && rTo.is())
+ {
+ MappingsData & rData = getMappingsData();
+ ClearableMutexGuard aGuard( rData.aMappingsMutex );
+
+ // try to find registered mapping
+ const t_OUString2Entry::const_iterator iFind( rData.aName2Entry.find(
+ getMappingName( rFrom, rTo, rAddPurpose ) ) );
+
+ if (iFind == rData.aName2Entry.end())
+ {
+ aGuard.clear();
+ return loadExternalMapping( rFrom, rTo, rAddPurpose );
+ }
+ else
+ {
+ return Mapping( (*iFind).second->pMapping );
+ }
+ }
+ return Mapping();
+}
+
+//--------------------------------------------------------------------------------------------------
+static inline Mapping createMediateMapping(
+ const Environment & rFrom, const Environment & rTo,
+ const Mapping & rFrom2Uno, const Mapping & rUno2To,
+ const OUString & rAddPurpose )
+{
+ uno_Mapping * pRet = new uno_Mediate_Mapping(
+ rFrom, rTo, rFrom2Uno, rUno2To, rAddPurpose ); // ref count initially 1
+ uno_registerMapping(
+ &pRet, mediate_free, rFrom.get(), rTo.get(), rAddPurpose.pData );
+ Mapping aRet( pRet );
+ (*pRet->release)( pRet );
+ return aRet;
+}
+//==================================================================================================
+static Mapping getMediateMapping(
+ const Environment & rFrom, const Environment & rTo, const OUString & rAddPurpose )
+{
+ Environment aUno;
+ Mapping aUno2To;
+
+ // connect to uno
+ if (rTo.getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_UNO ) )) // to is uno
+ {
+ aUno = rTo;
+ // no Uno2To mapping necessary
+ }
+ else
+ {
+ // get registered uno env
+ OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) );
+ uno_getEnvironment( (uno_Environment **)&aUno, aEnvTypeName.pData, 0 );
+
+ aUno2To = getDirectMapping( aUno, rTo );
+ // : uno <-> to
+ }
+
+ // connect to uno
+ if (rAddPurpose.getLength()) // insert purpose mapping between new ano_uno <-> uno
+ {
+ // create anonymous uno env
+ Environment aAnUno;
+ OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) );
+ uno_createEnvironment( (uno_Environment **)&aAnUno, aEnvTypeName.pData, 0 );
+
+ Mapping aAnUno2Uno( getDirectMapping( aAnUno, aUno, rAddPurpose ) );
+ if (! aAnUno2Uno.is())
+ return Mapping();
+ if (aUno2To.is()) // to is not uno
+ {
+ // create another mediate mapping
+ aUno2To = createMediateMapping( aAnUno, rTo, aAnUno2Uno, aUno2To, rAddPurpose );
+ // : ano_uno <-> uno <-> to
+ }
+ else
+ {
+ aUno2To = aAnUno2Uno;
+ // : ano_uno <-> to (i.e. uno)
+ }
+ aUno = aAnUno;
+ }
+
+ Mapping aFrom2Uno( getDirectMapping( rFrom, aUno ) );
+ if (aFrom2Uno.is())
+ {
+ return createMediateMapping( rFrom, rTo, aFrom2Uno, aUno2To, rAddPurpose );
+ // : from <-> some uno ...
+ }
+
+ return Mapping();
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_getMapping(
+ uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo, rtl_uString * pAddPurpose )
+{
+ OSL_ENSHURE( ppMapping && pFrom && pTo, "### null ptr!" );
+ if (*ppMapping)
+ {
+ (*(*ppMapping)->release)( *ppMapping );
+ *ppMapping = 0;
+ }
+
+ Mapping aRet;
+ Environment aFrom( pFrom ), aTo( pTo );
+
+ OUString aAddPurpose;
+ if (pAddPurpose)
+ aAddPurpose = pAddPurpose;
+
+ MappingsData & rData = getMappingsData();
+
+ // try registered mapping
+ {
+ MutexGuard aGuard( rData.aMappingsMutex );
+ const t_OUString2Entry::const_iterator iFind( rData.aName2Entry.find(
+ getMappingName( aFrom, aTo, aAddPurpose ) ) );
+ if (iFind != rData.aName2Entry.end())
+ aRet = (*iFind).second->pMapping;
+ }
+
+ if (! aRet.is()) // try callback chain
+ {
+ MutexGuard aGuard( rData.aCallbacksMutex );
+ for ( t_CallbackSet::const_iterator iPos( rData.aCallbacks.begin() );
+ iPos != rData.aCallbacks.end(); ++iPos )
+ {
+ (**iPos)( ppMapping, pFrom, pTo, aAddPurpose.pData );
+ if (*ppMapping)
+ return;
+ }
+ }
+
+ if (! aRet.is())
+ {
+ aRet = loadExternalMapping( aFrom, aTo, aAddPurpose ); // direct try
+ if (! aRet.is())
+ aRet = getMediateMapping( aFrom, aTo, aAddPurpose ); // try via uno
+ }
+
+ if (aRet.is())
+ {
+ (*aRet.get()->acquire)( aRet.get() );
+ *ppMapping = aRet.get();
+ }
+}
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_getMappingByName(
+ uno_Mapping ** ppMapping, rtl_uString * pFrom, rtl_uString * pTo, rtl_uString * pAddPurpose )
+{
+ OSL_ENSHURE( ppMapping && pFrom && pTo, "### null ptr!" );
+ if (*ppMapping)
+ {
+ (*(*ppMapping)->release)( *ppMapping );
+ *ppMapping = 0;
+ }
+
+ uno_Environment * pEFrom = 0;
+ uno_getEnvironment( &pEFrom, pFrom, 0 );
+ OSL_ENSHURE( pEFrom, "### cannot get source environment!" );
+ if (pEFrom)
+ {
+ uno_Environment * pETo = 0;
+ uno_getEnvironment( &pETo, pTo, 0 );
+ OSL_ENSHURE( pETo, "### cannot get target environment!" );
+ if (pETo)
+ {
+ uno_getMapping( ppMapping, pEFrom, pETo, pAddPurpose );
+ (*pETo->release)( pETo );
+ }
+ (*pEFrom->release)( pEFrom );
+ }
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_registerMapping(
+ uno_Mapping ** ppMapping, uno_freeMappingFunc freeMapping,
+ uno_Environment * pFrom, uno_Environment * pTo, rtl_uString * pAddPurpose )
+{
+ MappingsData & rData = getMappingsData();
+ ClearableMutexGuard aGuard( rData.aMappingsMutex );
+
+ const t_Mapping2Entry::const_iterator iFind( rData.aMapping2Entry.find( *ppMapping ) );
+ if (iFind == rData.aMapping2Entry.end())
+ {
+ OUString aMappingName(
+ getMappingName( pFrom, pTo, pAddPurpose ? OUString(pAddPurpose) : OUString() ) );
+#ifdef CPPU_ASSERTIONS
+ CPPU_TRACE( "> inserting new mapping " );
+ OString aMappingName8( OUStringToOString( aMappingName, RTL_TEXTENCODING_ASCII_US ) );
+ CPPU_TRACE( aMappingName8.getStr() );
+ CPPU_TRACE( " <\n" );
+#endif
+ // count initially 1
+ MappingEntry * pEntry = new MappingEntry( *ppMapping, freeMapping, aMappingName );
+ rData.aName2Entry[ aMappingName ] = pEntry;
+ rData.aMapping2Entry[ *ppMapping ] = pEntry;
+ }
+ else
+ {
+ MappingEntry * pEntry = (*iFind).second;
+ ++pEntry->nRef;
+
+ if (pEntry->pMapping != *ppMapping) // exchange mapping to be registered
+ {
+ (*pEntry->pMapping->acquire)( pEntry->pMapping );
+ --pEntry->nRef; // correct count; kill mapping to be registered
+ aGuard.clear();
+ (*freeMapping)( *ppMapping );
+ *ppMapping = pEntry->pMapping;
+ }
+ }
+}
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_revokeMapping( uno_Mapping * pMapping )
+{
+ MappingsData & rData = getMappingsData();
+ ClearableMutexGuard aGuard( rData.aMappingsMutex );
+
+ const t_Mapping2Entry::const_iterator iFind( rData.aMapping2Entry.find( pMapping ) );
+ OSL_ASSERT( iFind != rData.aMapping2Entry.end() );
+ MappingEntry * pEntry = (*iFind).second;
+ if (! --pEntry->nRef)
+ {
+ rData.aMapping2Entry.erase( pEntry->pMapping );
+ rData.aName2Entry.erase( pEntry->aMappingName );
+ aGuard.clear();
+#ifdef CPPU_ASSERTIONS
+ CPPU_TRACE( "> revoking mapping " );
+ OString aMappingName( OUStringToOString( pEntry->aMappingName, RTL_TEXTENCODING_ASCII_US ) );
+ CPPU_TRACE( aMappingName.getStr() );
+ CPPU_TRACE( " <\n" );
+#endif
+ (*pEntry->freeMapping)( pEntry->pMapping );
+ delete pEntry;
+ }
+}
+
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_registerMappingCallback( uno_getMappingFunc pCallback )
+{
+ OSL_ENSHURE( pCallback, "### null ptr!" );
+ MappingsData & rData = getMappingsData();
+ MutexGuard aGuard( rData.aCallbacksMutex );
+ rData.aCallbacks.insert( pCallback );
+}
+//##################################################################################################
+extern "C" SAL_DLLEXPORT void SAL_CALL uno_revokeMappingCallback( uno_getMappingFunc pCallback )
+{
+ OSL_ENSHURE( pCallback, "### null ptr!" );
+ MappingsData & rData = getMappingsData();
+ MutexGuard aGuard( rData.aCallbacksMutex );
+ rData.aCallbacks.erase( pCallback );
+}
diff --git a/cppu/source/uno/makefile.mk b/cppu/source/uno/makefile.mk
new file mode 100644
index 000000000000..a11b841fd746
--- /dev/null
+++ b/cppu/source/uno/makefile.mk
@@ -0,0 +1,93 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=cppu
+TARGET=cppu_uno
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : ..$/..$/util$/makefile.pmk
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/data.obj \
+ $(SLO)$/sequence.obj \
+ $(SLO)$/any.obj \
+ $(SLO)$/lbmap.obj \
+ $(SLO)$/lbenv.obj
+
+# NETBSD: somewhere we have to instantiate the static data members.
+# NETBSD-1.2.1 doesn't know about weak symbols so the default mechanism for GCC won't work.
+# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols
+.IF "$(OS)"=="NETBSD" || "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX"
+SLOFILES+=$(SLO)$/staticmb.obj
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : ..$/..$/util$/target.pmk
+.INCLUDE : target.mk
diff --git a/cppu/source/uno/prim.hxx b/cppu/source/uno/prim.hxx
new file mode 100644
index 000000000000..4f589b4caf2d
--- /dev/null
+++ b/cppu/source/uno/prim.hxx
@@ -0,0 +1,262 @@
+/*************************************************************************
+ *
+ * $RCSfile: prim.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef __PRIM_HXX__
+#define __PRIM_HXX__
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+#ifndef _typelib_TypeClass_H_
+#include <typelib/typeclass.h>
+#endif
+#ifndef _UNO_SEQUENCE2_H_
+#include <uno/sequence2.h>
+#endif
+#ifndef _UNO_ANY2_H_
+#include <uno/any2.h>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _UNO_MAPPING_H_
+#include <uno/mapping.h>
+#endif
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+
+#ifndef _OSL_INTERLCK_H
+#include <osl/interlck.h>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _RTL_USTRING_HXX
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#include <com/sun/star/uno/Type.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+
+namespace cppu
+{
+
+//--------------------------------------------------------------------------------------------------
+inline void * __map(
+ void * p,
+ typelib_TypeDescriptionReference * pType,
+ typelib_TypeDescription * pTypeDescr,
+ uno_Mapping * mapping )
+{
+ void * pRet = 0;
+ if (p)
+ {
+ if (pTypeDescr)
+ {
+ (*mapping->mapInterface)( mapping, &pRet, p, (typelib_InterfaceTypeDescription *)pTypeDescr );
+ }
+ else
+ {
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ (*mapping->mapInterface)( mapping, &pRet, p, (typelib_InterfaceTypeDescription *)pTypeDescr );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ }
+ return pRet;
+}
+//--------------------------------------------------------------------------------------------------
+inline void __acquire( void * p, uno_AcquireFunc acquire )
+{
+ if (p)
+ {
+ if (acquire)
+ (*acquire)( p );
+ else
+ (*((uno_Interface *)p)->acquire)( (uno_Interface *)p );
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void __releaseRef( void ** pRef, uno_ReleaseFunc release )
+{
+ if (*pRef)
+ {
+ if (release)
+ (*release)( *pRef );
+ else
+ (*((uno_Interface *)*pRef)->release)( (uno_Interface *)*pRef );
+ }
+#ifdef DEBUG
+ *pRef = (void *)0xdeadbeef;
+#endif
+}
+
+//--------------------------------------------------------------------------------------------------
+static uno_Sequence * s_pSeq = 0;
+static uno_Sequence s_seq;
+inline uno_Sequence * __getEmptySequence()
+{
+ if (! s_pSeq)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! s_pSeq)
+ {
+ s_seq.nRefCount = 1;
+ s_seq.nElements = 0;
+ s_pSeq = &s_seq;
+ }
+ }
+ ::osl_incrementInterlockedCount( &s_pSeq->nRefCount );
+ return s_pSeq;
+}
+//--------------------------------------------------------------------------------------------------
+static typelib_TypeDescriptionReference * s_pVoidType = 0;
+inline typelib_TypeDescriptionReference * __getVoidType()
+{
+ if (! s_pVoidType)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! s_pVoidType)
+ {
+ s_pVoidType = * ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID );
+ }
+ }
+ ::typelib_typedescriptionreference_acquire( s_pVoidType );
+ return s_pVoidType;
+}
+
+//--------------------------------------------------------------------------------------------------
+#ifdef DEBUG
+#define __CONSTRUCT_EMPTY_ANY( pAny ) \
+(pAny)->pType = __getVoidType(); \
+(pAny)->pData = (void *)0xdeadbeef;
+#else
+#define __CONSTRUCT_EMPTY_ANY( pAny ) \
+(pAny)->pType = __getVoidType();
+#endif
+
+//--------------------------------------------------------------------------------------------------
+#define TYPE_ACQUIRE( pType ) \
+ ::osl_incrementInterlockedCount( &(pType)->nRefCount );
+
+//--------------------------------------------------------------------------------------------------
+static typelib_TypeDescription * s_pQITD = 0;
+inline typelib_TypeDescription * __getQueryInterfaceTypeDescr()
+{
+ if (! s_pQITD)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! s_pQITD)
+ {
+ typelib_InterfaceTypeDescription * pTXInterfaceDescr = 0;
+ const com::sun::star::uno::Type & rXIType =
+ ::getCppuType( (const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > *)0 );
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pTXInterfaceDescr, rXIType.getTypeLibType() );
+ OSL_ASSERT( pTXInterfaceDescr->ppAllMembers );
+ ::typelib_typedescriptionreference_getDescription(
+ &s_pQITD, pTXInterfaceDescr->ppAllMembers[0] );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pTXInterfaceDescr );
+ }
+ }
+ ::typelib_typedescription_acquire( s_pQITD );
+ return s_pQITD;
+}
+
+//--------------------------------------------------------------------------------------------------
+inline typelib_TypeDescriptionReference * __unionGetSetType(
+ void * pUnion, typelib_TypeDescription * pTD )
+{
+ typelib_TypeDescriptionReference * pRet;
+
+ sal_Int64 * pDiscr = ((typelib_UnionTypeDescription *)pTD)->pDiscriminants;
+ sal_Int64 nDiscr = *(sal_Int64 *)pUnion;
+ for ( sal_Int32 nPos = ((typelib_UnionTypeDescription *)pTD)->nMembers; nPos--; )
+ {
+ if (pDiscr[nPos] == nDiscr)
+ {
+ pRet = ((typelib_UnionTypeDescription *)pTD)->ppTypeRefs[nPos];
+ break;
+ }
+ }
+ if (nPos >= 0)
+ {
+ // default
+ pRet = ((typelib_UnionTypeDescription *)pTD)->pDefaultTypeRef;
+ }
+ typelib_typedescriptionreference_acquire( pRet );
+ return pRet;
+}
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool __type_equals(
+ typelib_TypeDescriptionReference * pType1,
+ typelib_TypeDescriptionReference * pType2 )
+{
+ return (pType1 == pType2 ||
+ (pType1->eTypeClass == pType2->eTypeClass &&
+ pType1->pTypeName->length == pType2->pTypeName->length &&
+ ::rtl_ustr_compare( pType1->pTypeName->buffer, pType2->pTypeName->buffer ) == 0));
+}
+
+}
+
+#endif
diff --git a/cppu/source/uno/sequence.cxx b/cppu/source/uno/sequence.cxx
new file mode 100644
index 000000000000..8d4576aea3f4
--- /dev/null
+++ b/cppu/source/uno/sequence.cxx
@@ -0,0 +1,804 @@
+/*************************************************************************
+ *
+ * $RCSfile: sequence.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RTL_MEMORY_H_
+#include <rtl/memory.h>
+#endif
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_INTERLCK_H_
+#include <osl/interlck.h>
+#endif
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+#ifndef _UNO_SEQUENCE2_H_
+#include <uno/sequence2.h>
+#endif
+
+#include "constr.hxx"
+#include "copy.hxx"
+#include "destr.hxx"
+
+using namespace cppu;
+
+namespace cppu
+{
+//--------------------------------------------------------------------------------------------------
+static inline void allocSeq(
+ uno_Sequence ** ppSeq, sal_Int32 nElementSize, sal_Int32 nElements )
+{
+ if (nElements)
+ {
+ uno_Sequence * pSeq = (uno_Sequence *)
+ (*ppSeq
+ ? ::rtl_reallocateMemory( *ppSeq, SAL_SEQUENCE_HEADER_SIZE + (nElementSize * nElements) )
+ : ::rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + (nElementSize * nElements) ));
+ pSeq->nRefCount = 1;
+ pSeq->nElements = nElements;
+ *ppSeq = pSeq;
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void __defaultConstructElements(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescriptionReference * pElementType,
+ sal_Int32 nStartIndex, sal_Int32 nStopIndex,
+ sal_Int32 nAlloc = 0 ) // >= 0 means (re)alloc memory for nAlloc elements
+{
+ switch (pElementType->eTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ allocSeq( ppSequence, sizeof(sal_Unicode), nAlloc );
+ ::rtl_zeroMemory(
+ (*ppSequence)->elements + (sizeof(sal_Unicode) * nStartIndex),
+ sizeof(sal_Unicode) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_BOOLEAN:
+ allocSeq( ppSequence, sizeof(sal_Bool), nAlloc );
+ ::rtl_zeroMemory(
+ (*ppSequence)->elements + (sizeof(sal_Bool) * nStartIndex),
+ sizeof(sal_Bool) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_BYTE:
+ allocSeq( ppSequence, sizeof(sal_Int8), nAlloc );
+ ::rtl_zeroMemory(
+ (*ppSequence)->elements + (sizeof(sal_Int8) * nStartIndex),
+ sizeof(sal_Int8) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ allocSeq( ppSequence, sizeof(sal_Int16), nAlloc );
+ ::rtl_zeroMemory(
+ (*ppSequence)->elements + (sizeof(sal_Int16) * nStartIndex),
+ sizeof(sal_Int16) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ allocSeq( ppSequence, sizeof(sal_Int32), nAlloc );
+ ::rtl_zeroMemory(
+ (*ppSequence)->elements + (sizeof(sal_Int32) * nStartIndex),
+ sizeof(sal_Int32) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ allocSeq( ppSequence, sizeof(sal_Int64), nAlloc );
+ ::rtl_zeroMemory(
+ (*ppSequence)->elements + (sizeof(sal_Int64) * nStartIndex),
+ sizeof(sal_Int64) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_FLOAT:
+ {
+ allocSeq( ppSequence, sizeof(float), nAlloc );
+
+ float * pElements = (float *)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ pElements[nPos] = 0.0;
+ }
+ break;
+ }
+ case typelib_TypeClass_DOUBLE:
+ {
+ allocSeq( ppSequence, sizeof(double), nAlloc );
+
+ double * pElements = (double *)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ pElements[nPos] = 0.0;
+ }
+ break;
+ }
+ case typelib_TypeClass_STRING:
+ {
+ allocSeq( ppSequence, sizeof(rtl_uString *), nAlloc );
+
+ rtl_uString ** pElements = (rtl_uString **)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ pElements[nPos] = 0;
+ RTL_USTRING_NEW( &pElements[nPos] );
+ }
+ break;
+ }
+ case typelib_TypeClass_TYPE:
+ {
+ allocSeq( ppSequence, sizeof(typelib_TypeDescriptionReference *), nAlloc );
+
+ typelib_TypeDescriptionReference ** pElements =
+ (typelib_TypeDescriptionReference **)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ pElements[nPos] = __getVoidType();
+ }
+ break;
+ }
+ case typelib_TypeClass_ANY:
+ {
+ allocSeq( ppSequence, sizeof(uno_Any), nAlloc );
+
+ uno_Any * pElements = (uno_Any *)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ __CONSTRUCT_EMPTY_ANY( &pElements[nPos] );
+ }
+ break;
+ }
+ case typelib_TypeClass_ENUM:
+ {
+ allocSeq( ppSequence, sizeof(int), nAlloc );
+
+// ::rtl_zeroMemory(
+// (*ppSequence)->elements + (sizeof(int) * nStartIndex),
+// sizeof(int) * (nStopIndex - nStartIndex) );
+
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ int eEnum = ((typelib_EnumTypeDescription *)pElementTypeDescr)->nDefaultEnumValue;
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+
+ int * pElements = (int *)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ pElements[nPos] = eEnum;
+ }
+ break;
+ }
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+
+ allocSeq( ppSequence, nElementSize, nAlloc );
+
+ char * pElements = (*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ __defaultConstructStruct(
+ pElements + (nElementSize * nPos),
+ (typelib_CompoundTypeDescription *)pElementTypeDescr );
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_UNION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+
+ allocSeq( ppSequence, nElementSize, nAlloc );
+
+ sal_Int32 nValueOffset = ((typelib_UnionTypeDescription *)pElementTypeDescr)->nValueOffset;
+ sal_Int32 nDefaultDiscr = ((typelib_UnionTypeDescription *)pElementTypeDescr)->nDefaultDiscriminant;
+
+ typelib_TypeDescription * pDefaultTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pDefaultTypeDescr, ((typelib_UnionTypeDescription *)pElementTypeDescr)->pDefaultTypeRef );
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+
+ char * pElements = (*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ char * pMem = pElements + (nElementSize * nPos);
+ ::uno_constructData( (char *)pMem + nValueOffset, pDefaultTypeDescr );
+ *(sal_Int64 *)pMem = nDefaultDiscr;
+ }
+ TYPELIB_DANGER_RELEASE( pDefaultTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_SEQUENCE:
+ {
+ allocSeq( ppSequence, sizeof(uno_Sequence *), nAlloc );
+
+ uno_Sequence ** pElements = (uno_Sequence **)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ pElements[nPos] = __getEmptySequence();
+ }
+ break;
+ }
+ case typelib_TypeClass_INTERFACE: // either cpp or c-uno interface
+ allocSeq( ppSequence, sizeof(void *), nAlloc );
+
+ ::rtl_zeroMemory(
+ (*ppSequence)->elements + (sizeof(void *) * nStartIndex),
+ sizeof(void *) * (nStopIndex - nStartIndex) );
+ break;
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void __copyConstructElements(
+ uno_Sequence ** ppSequence, void * pSourceElements,
+ typelib_TypeDescriptionReference * pElementType,
+ sal_Int32 nStartIndex, sal_Int32 nStopIndex,
+ uno_AcquireFunc acquire,
+ sal_Int32 nAlloc = 0 )
+{
+ switch (pElementType->eTypeClass)
+ {
+ case typelib_TypeClass_CHAR:
+ allocSeq( ppSequence, sizeof(sal_Unicode), nAlloc );
+ ::rtl_copyMemory(
+ (*ppSequence)->elements + (sizeof(sal_Unicode) * nStartIndex),
+ (char *)pSourceElements + (sizeof(sal_Unicode) * nStartIndex),
+ sizeof(sal_Unicode) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_BOOLEAN:
+ allocSeq( ppSequence, sizeof(sal_Bool), nAlloc );
+ ::rtl_copyMemory(
+ (*ppSequence)->elements + (sizeof(sal_Bool) * nStartIndex),
+ (char *)pSourceElements + (sizeof(sal_Bool) * nStartIndex),
+ sizeof(sal_Bool) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_BYTE:
+ allocSeq( ppSequence, sizeof(sal_Int8), nAlloc );
+ ::rtl_copyMemory(
+ (*ppSequence)->elements + (sizeof(sal_Int8) * nStartIndex),
+ (char *)pSourceElements + (sizeof(sal_Int8) * nStartIndex),
+ sizeof(sal_Int8) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ allocSeq( ppSequence, sizeof(sal_Int16), nAlloc );
+ ::rtl_copyMemory(
+ (*ppSequence)->elements + (sizeof(sal_Int16) * nStartIndex),
+ (char *)pSourceElements + (sizeof(sal_Int16) * nStartIndex),
+ sizeof(sal_Int16) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ allocSeq( ppSequence, sizeof(sal_Int32), nAlloc );
+ ::rtl_copyMemory(
+ (*ppSequence)->elements + (sizeof(sal_Int32) * nStartIndex),
+ (char *)pSourceElements + (sizeof(sal_Int32) * nStartIndex),
+ sizeof(sal_Int32) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ allocSeq( ppSequence, sizeof(sal_Int64), nAlloc );
+ ::rtl_copyMemory(
+ (*ppSequence)->elements + (sizeof(sal_Int64) * nStartIndex),
+ (char *)pSourceElements + (sizeof(sal_Int64) * nStartIndex),
+ sizeof(sal_Int64) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_FLOAT:
+ allocSeq( ppSequence, sizeof(float), nAlloc );
+ ::rtl_copyMemory(
+ (*ppSequence)->elements + (sizeof(float) * nStartIndex),
+ (char *)pSourceElements + (sizeof(float) * nStartIndex),
+ sizeof(float) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_DOUBLE:
+ allocSeq( ppSequence, sizeof(double), nAlloc );
+ ::rtl_copyMemory(
+ (*ppSequence)->elements + (sizeof(double) * nStartIndex),
+ (char *)pSourceElements + (sizeof(double) * nStartIndex),
+ sizeof(double) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_ENUM:
+ allocSeq( ppSequence, sizeof(int), nAlloc );
+ ::rtl_copyMemory(
+ (*ppSequence)->elements + (sizeof(int) * nStartIndex),
+ (char *)pSourceElements + (sizeof(int) * nStartIndex),
+ sizeof(int) * (nStopIndex - nStartIndex) );
+ break;
+ case typelib_TypeClass_STRING:
+ {
+ allocSeq( ppSequence, sizeof(rtl_uString *), nAlloc );
+
+ rtl_uString ** pDestElements = (rtl_uString **)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ ::rtl_uString_acquire( ((rtl_uString **)pSourceElements)[nPos] );
+ pDestElements[nPos] = ((rtl_uString **)pSourceElements)[nPos];
+ }
+ break;
+ }
+ case typelib_TypeClass_TYPE:
+ {
+ allocSeq( ppSequence, sizeof(typelib_TypeDescriptionReference *), nAlloc );
+
+ typelib_TypeDescriptionReference ** pDestElements =
+ (typelib_TypeDescriptionReference **)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ TYPE_ACQUIRE( ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] );
+ pDestElements[nPos] = ((typelib_TypeDescriptionReference **)pSourceElements)[nPos];
+ }
+ break;
+ }
+ case typelib_TypeClass_ANY:
+ {
+ allocSeq( ppSequence, sizeof(uno_Any), nAlloc );
+
+ uno_Any * pDestElements = (uno_Any *)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ uno_Any * pSource = (uno_Any *)pSourceElements + nPos;
+ __copyConstructAny(
+ &pDestElements[nPos],
+ pSource->pData,
+ pSource->pType, 0,
+ acquire, 0 );
+ }
+ break;
+ }
+#ifdef CPPU_ASSERTIONS
+ case typelib_TypeClass_TYPEDEF:
+ OSL_ENSHURE( sal_False, "### unexpected typedef!" );
+ break;
+#endif
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+
+ allocSeq( ppSequence, nElementSize, nAlloc );
+
+ char * pDestElements = (*ppSequence)->elements;
+
+ typelib_CompoundTypeDescription * pTypeDescr = (typelib_CompoundTypeDescription *)pElementTypeDescr;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ char * pDest = pDestElements + (nElementSize * nPos);
+ char * pSource = (char *)pSourceElements + (nElementSize * nPos);
+
+ if (pTypeDescr->pBaseTypeDescription)
+ {
+ // copy base value
+ __copyConstructStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, acquire, 0 );
+ }
+
+ // then copy members
+ typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
+ sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
+ sal_Int32 nDescr = pTypeDescr->nMembers;
+
+ while (nDescr--)
+ {
+ ::uno_type_copyData(
+ pDest + pMemberOffsets[nDescr],
+ pSource + pMemberOffsets[nDescr],
+ ppTypeRefs[nDescr], acquire );
+ }
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_UNION:
+ {
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ sal_Int32 nElementSize = pElementTypeDescr->nSize;
+
+ allocSeq( ppSequence, nElementSize, nAlloc );
+
+ char * pDestElements = (*ppSequence)->elements;
+
+ sal_Int32 nValueOffset = ((typelib_UnionTypeDescription *)pElementTypeDescr)->nValueOffset;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ char * pDest = pDestElements + (nElementSize * nPos);
+ char * pSource = (char *)pSourceElements + (nElementSize * nPos);
+
+ typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pSource, pElementTypeDescr );
+ uno_type_copyData( pDest + nValueOffset,
+ pSource + nValueOffset,
+ pSetType, acquire );
+ *(sal_Int64 *)pDest = *(sal_Int64 *)pSource;
+ typelib_typedescriptionreference_release( pSetType );
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_SEQUENCE:
+ {
+ allocSeq( ppSequence, sizeof(uno_Sequence *), nAlloc );
+
+ typelib_TypeDescription * pElementTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
+ uno_Sequence ** pDestElements = (uno_Sequence **)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ __copyConstructSequence(
+ &pDestElements[nPos],
+ ((uno_Sequence **)pSourceElements)[nPos],
+ ((typelib_IndirectTypeDescription *)pElementTypeDescr)->pType,
+ acquire, 0 );
+ }
+ TYPELIB_DANGER_RELEASE( pElementTypeDescr );
+ break;
+ }
+ case typelib_TypeClass_INTERFACE:
+ {
+ allocSeq( ppSequence, sizeof(void *), nAlloc );
+
+ void ** pDestElements = (void **)(*ppSequence)->elements;
+ for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
+ {
+ __acquire( pDestElements[nPos] = ((void **)pSourceElements)[nPos], acquire );
+ }
+ break;
+ }
+ }
+}
+//--------------------------------------------------------------------------------------------------
+inline void __reallocSequence(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescriptionReference * pElementType,
+ sal_Int32 nSize,
+ uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ uno_Sequence * pSource = *ppSequence;
+ sal_Int32 nSourceElements = pSource->nElements;
+
+ if (pSource->nRefCount > 1) // split
+ {
+ uno_Sequence * pNew = 0;
+
+ sal_Int32 nRest = nSize - nSourceElements;
+ sal_Int32 nCopy = (nRest > 0 ? nSourceElements : nSize);
+
+ if (nCopy > 0)
+ {
+ __copyConstructElements(
+ &pNew, pSource->elements, pElementType,
+ 0, nCopy, acquire,
+ nSize ); // alloc to nSize
+ }
+ if (nRest > 0)
+ {
+ __defaultConstructElements(
+ &pNew, pElementType,
+ nCopy, nSize,
+ nCopy > 0 ? 0 : nSize ); // alloc to nSize if nCopy <= 0
+ }
+
+ // destruct sequence
+ if (! ::osl_decrementInterlockedCount( &(*ppSequence)->nRefCount ))
+ {
+ if ((*ppSequence)->nElements)
+ {
+ __destructElements(
+ (*ppSequence)->elements, pElementType, 0, (*ppSequence)->nElements, release );
+ }
+ ::rtl_freeMemory( *ppSequence );
+ }
+
+ *ppSequence = pNew;
+ }
+ else
+ {
+ if (nSize > nSourceElements) // default construct the rest
+ {
+ __defaultConstructElements(
+ ppSequence, pElementType,
+ nSourceElements, nSize,
+ nSize ); // realloc to nSize
+ }
+ else // or destruct the rest and realloc mem
+ {
+ sal_Int32 nElementSize = __destructElements(
+ (*ppSequence)->elements, pElementType,
+ nSize, nSourceElements, release );
+ *ppSequence = (uno_Sequence *)::rtl_reallocateMemory(
+ *ppSequence, SAL_SEQUENCE_HEADER_SIZE + (nSize * nElementSize) );
+ (*ppSequence)->nElements = nSize;
+ }
+ }
+}
+
+}
+
+extern "C"
+{
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_sequence_construct(
+ uno_Sequence ** ppSequence, typelib_TypeDescriptionReference * pType,
+ void * pElements, sal_Int32 len,
+ uno_AcquireFunc acquire )
+{
+ if (len)
+ {
+ typelib_TypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+
+ typelib_TypeDescriptionReference * pElementType =
+ ((typelib_IndirectTypeDescription *)pTypeDescr)->pType;
+
+ uno_Sequence * pSequence = 0;
+
+ if (pElements)
+ {
+ __copyConstructElements(
+ &pSequence, pElements, pElementType,
+ 0, len, acquire,
+ len ); // alloc to len
+ }
+ else
+ {
+ __defaultConstructElements(
+ &pSequence,
+ pElementType,
+ 0, len,
+ len ); // alloc to len
+ }
+
+ *ppSequence = pSequence;
+
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ else
+ {
+ *ppSequence = __getEmptySequence();
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_sequence_construct(
+ uno_Sequence ** ppSequence, typelib_TypeDescription * pTypeDescr,
+ void * pElements, sal_Int32 len,
+ uno_AcquireFunc acquire )
+{
+ if (len)
+ {
+ typelib_TypeDescriptionReference * pElementType =
+ ((typelib_IndirectTypeDescription *)pTypeDescr)->pType;
+
+ uno_Sequence * pSequence = 0;
+
+ if (pElements)
+ {
+ __copyConstructElements(
+ &pSequence, pElements, pElementType,
+ 0, len, acquire,
+ len ); // alloc to len
+ }
+ else
+ {
+ __defaultConstructElements(
+ &pSequence,
+ pElementType,
+ 0, len,
+ len ); // alloc to len
+ }
+
+ *ppSequence = pSequence;
+ }
+ else
+ {
+ *ppSequence = __getEmptySequence();
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_sequence_realloc(
+ uno_Sequence ** ppSequence, typelib_TypeDescriptionReference * pType, sal_Int32 nSize,
+ uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ OSL_ENSHURE( ppSequence, "### null ptr!" );
+ OSL_ENSHURE( nSize >= 0, "### new size must be at least 0!" );
+
+ if (nSize != (*ppSequence)->nElements)
+ {
+ typelib_TypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+ __reallocSequence(
+ ppSequence, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ nSize, acquire, release );
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_sequence_realloc(
+ uno_Sequence ** ppSequence, typelib_TypeDescription * pTypeDescr, sal_Int32 nSize,
+ uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ OSL_ENSHURE( ppSequence, "### null ptr!" );
+ OSL_ENSHURE( nSize >= 0, "### new size must be at least 0!" );
+
+ if (nSize != (*ppSequence)->nElements)
+ {
+ __reallocSequence(
+ ppSequence, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ nSize, acquire, release );
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_sequence_reference2One(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescriptionReference * pType,
+ uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ OSL_ENSHURE( ppSequence, "### null ptr!" );
+ uno_Sequence * pSequence = *ppSequence;
+ if (pSequence->nRefCount > 1)
+ {
+ if (pSequence->nElements)
+ {
+ typelib_TypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pTypeDescr, pType );
+
+ uno_Sequence * pNew = 0;
+ __copyConstructElements(
+ &pNew, pSequence->elements,
+ ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ 0, pSequence->nElements, acquire,
+ pSequence->nElements ); // alloc nElements
+
+ __destructSequence( *ppSequence, pType, pTypeDescr, release );
+ *ppSequence = pNew;
+
+ TYPELIB_DANGER_RELEASE( pTypeDescr );
+ }
+ else
+ {
+ __destructSequence( *ppSequence, pType, 0, release );
+
+ uno_Sequence * pNew = (uno_Sequence *)::rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE );
+ pNew->nRefCount = 1;
+ pNew->nElements = 0;
+ *ppSequence = pNew;
+ }
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_sequence_reference2One(
+ uno_Sequence ** ppSequence,
+ typelib_TypeDescription * pTypeDescr,
+ uno_AcquireFunc acquire, uno_ReleaseFunc release )
+{
+ OSL_ENSHURE( ppSequence, "### null ptr!" );
+ uno_Sequence * pSequence = *ppSequence;
+ if (pSequence->nRefCount > 1)
+ {
+ if (pSequence->nElements)
+ {
+ uno_Sequence * pNew = 0;
+ __copyConstructElements(
+ &pNew, pSequence->elements,
+ ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
+ 0, pSequence->nElements, acquire,
+ pSequence->nElements ); // alloc nElements
+
+ __destructSequence( *ppSequence, pTypeDescr->pWeakRef, pTypeDescr, release );
+ *ppSequence = pNew;
+ }
+ else
+ {
+ __destructSequence( *ppSequence, pTypeDescr->pWeakRef, pTypeDescr, release );
+
+ uno_Sequence * pNew = (uno_Sequence *)::rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE );
+ pNew->nRefCount = 1;
+ pNew->nElements = 0;
+ *ppSequence = pNew;
+ }
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_sequence_assign(
+ uno_Sequence ** ppDest,
+ uno_Sequence * pSource,
+ typelib_TypeDescription * pTypeDescr,
+ uno_ReleaseFunc release )
+{
+ if (*ppDest != pSource)
+ {
+ ::osl_incrementInterlockedCount( &pSource->nRefCount );
+ __destructSequence( *ppDest, pTypeDescr->pWeakRef, pTypeDescr, release );
+ *ppDest = pSource;
+ }
+}
+//##################################################################################################
+SAL_DLLEXPORT void SAL_CALL uno_type_sequence_assign(
+ uno_Sequence ** ppDest,
+ uno_Sequence * pSource,
+ typelib_TypeDescriptionReference * pType,
+ uno_ReleaseFunc release )
+{
+ if (*ppDest != pSource)
+ {
+ ::osl_incrementInterlockedCount( &pSource->nRefCount );
+ __destructSequence( *ppDest, pType, 0, release );
+ *ppDest = pSource;
+ }
+}
+
+}
diff --git a/cppu/test/cpputest.idl b/cppu/test/cpputest.idl
new file mode 100644
index 000000000000..fab2b36ae7a8
--- /dev/null
+++ b/cppu/test/cpputest.idl
@@ -0,0 +1,129 @@
+/*************************************************************************
+ *
+ * $RCSfile: cpputest.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _TEST_CPPUTEST_IDL_
+#define _TEST_CPPUTEST_IDL_
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/uno/TypeClass.idl>
+
+module test
+{
+
+struct Test1
+{
+ short nInt16;
+ double dDouble;
+ boolean bBool;
+};
+
+struct Test2
+{
+ short nInt16;
+ Test1 aTest1;
+};
+
+typedef Test1 TdTest1;
+
+struct Test3
+{
+ byte nInt8;
+ float nFloat;
+ double nDouble;
+ short nInt16;
+ string aString;
+ unsigned short nuInt16;
+ hyper nInt64;
+ long nInt32;
+ unsigned hyper nuInt64;
+ unsigned long nuInt32;
+ com::sun::star::uno::TypeClass eType;
+ char wChar;
+ TdTest1 td;
+ boolean bBool;
+ any aAny;
+};
+
+
+struct Base
+{
+ long n;
+ short o;
+};
+
+struct Base1 : Base
+{
+ short p;
+};
+
+struct Base2 : Base1
+{
+ double p2;
+};
+
+[ uik(46121273-3462-11d3-87A400A0-24494732), ident("SimpleInterface", 1.0) ]
+interface XSimpleInterface : com::sun::star::uno::XInterface
+{
+ void method();
+};
+
+}; //module test
+
+#endif
diff --git a/cppu/test/language_binding.idl b/cppu/test/language_binding.idl
new file mode 100644
index 000000000000..ad23f590bf12
--- /dev/null
+++ b/cppu/test/language_binding.idl
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * $RCSfile: language_binding.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:54 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _TEST_LANGUAGE_BINDING_IDL_
+#define _TEST_LANGUAGE_BINDING_IDL_
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/lang/IllegalArgumentException.idl>
+
+module test
+{
+
+enum TestEnum
+{
+ TEST,
+ ONE,
+ TWO,
+ CHECK,
+ LOLA,
+ PALOO,
+ ZA
+};
+
+/**
+ * simple c++ types
+ */
+struct TestSimple
+{
+ boolean Bool;
+ char Char;
+ byte Byte;
+ short Short;
+ unsigned short UShort;
+ long Long;
+ unsigned long ULong;
+ hyper Hyper;
+ unsigned hyper UHyper;
+ float Float;
+ double Double;
+ test::TestEnum Enum;
+};
+/**
+ * complex c++ types
+ */
+struct TestElement : test::TestSimple
+{
+ string String;
+ com::sun::star::uno::XInterface Interface;
+ any Any;
+};
+struct TestDataElements : test::TestElement
+{
+ sequence<test::TestElement > Sequence;
+};
+
+typedef TestDataElements TestData;
+
+/**
+ * Monster test interface to test language binding calls.
+ *
+ * @author Daniel Boelzle
+ */
+[ uik(46833373-3462-11d3-87A400A0-24494732), ident("XLBTest", 1.0) ]
+interface XLBTestBase : com::sun::star::uno::XInterface
+{
+ /**
+ * in parameter test, tests by calls reference also (complex types)
+ */
+ [oneway] void setValues( [in] boolean bBool, [in] char cChar, [in] byte nByte,
+ [in] short nShort, [in] unsigned short nUShort,
+ [in] long nLong, [in] unsigned long nULong,
+ [in] hyper nHyper, [in] unsigned hyper nUHyper,
+ [in] float fFloat, [in] double fDouble,
+ [in] test::TestEnum eEnum, [in] string aString,
+ [in] com::sun::star::uno::XInterface xInterface, [in] any aAny,
+ [in] sequence<test::TestElement > aSequence,
+ [in] test::TestData aStruct );
+ /**
+ * inout parameter test
+ */
+ test::TestData setValues2( [inout] boolean bBool, [inout] char cChar, [inout] byte nByte,
+ [inout] short nShort, [inout] unsigned short nUShort,
+ [inout] long nLong, [inout] unsigned long nULong,
+ [inout] hyper nHyper, [inout] unsigned hyper nUHyper,
+ [inout] float fFloat, [inout] double fDouble,
+ [inout] test::TestEnum eEnum, [inout] string aString,
+ [inout] com::sun::star::uno::XInterface xInterface, [inout] any aAny,
+ [inout] sequence<test::TestElement > aSequence,
+ [inout] test::TestData aStruct );
+
+ /**
+ * out parameter test
+ */
+ test::TestData getValues( [out] boolean bBool, [out] char cChar, [out] byte nByte,
+ [out] short nShort, [out] unsigned short nUShort,
+ [out] long nLong, [out] unsigned long nULong,
+ [out] hyper nHyper, [out] unsigned hyper nUHyper,
+ [out] float fFloat, [out] double fDouble,
+ [out] test::TestEnum eEnum, [out] string aString,
+ [out] com::sun::star::uno::XInterface xInterface, [out] any aAny,
+ [out] sequence<test::TestElement > aSequence,
+ [out] test::TestData aStruct );
+
+ [attribute] boolean Bool;
+ [attribute] byte Byte;
+ [attribute] char Char;
+ [attribute] short Short;
+ [attribute] unsigned short UShort;
+ [attribute] long Long;
+ [attribute] unsigned long ULong;
+ [attribute] hyper Hyper;
+ [attribute] unsigned hyper UHyper;
+ [attribute] float Float;
+ [attribute] double Double;
+ [attribute] test::TestEnum Enum;
+ [attribute] string String;
+ [attribute] com::sun::star::uno::XInterface Interface;
+ [attribute] any Any;
+ [attribute] sequence<test::TestElement > Sequence;
+ [attribute] test::TestData Struct;
+};
+
+
+/**
+ * Inherting from monster; adds raiseException().
+ *
+ * @author Daniel Boelzle
+ */
+[ uik(44C34C20-3478-11d3-87A400A0-24494732), ident("XLanguageBindingTest", 1.0) ]
+interface XLanguageBindingTest : test::XLBTestBase
+{
+ /**
+ * params are there only for dummy, to test if all temp out params will be released.
+ */
+ test::TestData raiseException( [out] boolean bBool, [out] char cChar, [out] byte nByte,
+ [out] short nShort, [out] unsigned short nUShort,
+ [out] long nLong, [out] unsigned long nULong,
+ [out] hyper nHyper, [out] unsigned hyper nUHyper,
+ [out] float fFloat, [out] double fDouble,
+ [out] test::TestEnum eEnum, [out] string aString,
+ [out] com::sun::star::uno::XInterface xInterface, [out] any aAny,
+ [out] sequence<test::TestElement > aSequence,
+ [out] test::TestData aStruct )
+ raises( com::sun::star::lang::IllegalArgumentException );
+
+ /**
+ * raises runtime exception
+ */
+ [attribute] long RuntimeException;
+};
+
+}; // test
+
+
+#endif
diff --git a/cppu/test/makefile.mk b/cppu/test/makefile.mk
new file mode 100644
index 000000000000..ee745c922cba
--- /dev/null
+++ b/cppu/test/makefile.mk
@@ -0,0 +1,153 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME= testcppu
+TARGET= testcppu
+LIBTARGET= NO
+TARGETTYPE= CUI
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC= TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb
+UNOUCROUT= $(OUT)$/inc$/test
+INCPRE+= $(OUT)$/inc$/test
+
+OBJFILES= \
+ $(OBJ)$/testcppu.obj \
+ $(OBJ)$/test_di.obj
+
+
+APP1TARGET= testcppu
+APP1OBJS= $(OBJ)$/test_di.obj \
+ $(OBJ)$/testcppu.obj
+
+APP1STDLIBS+= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+APP1DEF= $(MISC)$/$(APP1TARGET).def
+
+ALLIDLFILES:= cpputest.idl \
+ language_binding.idl
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : $(BIN)$/testcppu.rdb unoheader ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+CPPUMAKERFLAGS = -C
+.IF "$(COM)" == "MSC"
+CPPUMAKERFLAGS = -L
+.ENDIF
+
+TYPES:= -Ttest.XLanguageBindingTest \
+ -Ttest.XSimpleInterface \
+ -Ttest.Test1 \
+ -Ttest.Test2 \
+ -Ttest.TdTest1 \
+ -Ttest.Test3 \
+ -Ttest.Base \
+ -Ttest.Base1 \
+ -Ttest.Base2 \
+ -Tcom.sun.star.lang.XMultiServiceFactory \
+ -Tcom.sun.star.lang.XSingleServiceFactory \
+ -Tcom.sun.star.lang.XInitialization \
+ -Tcom.sun.star.lang.XServiceInfo \
+ -Tcom.sun.star.lang.XEventListener \
+ -Tcom.sun.star.lang.XTypeProvider \
+ -Tcom.sun.star.registry.XSimpleRegistry \
+ -Tcom.sun.star.registry.XRegistryKey \
+ -Tcom.sun.star.loader.XImplementationLoader \
+ -Tcom.sun.star.registry.XImplementationRegistration \
+ -Tcom.sun.star.lang.XComponent \
+ -Tcom.sun.star.container.XSet \
+ -Tcom.sun.star.uno.XReference \
+ -Tcom.sun.star.uno.XAdapter \
+ -Tcom.sun.star.uno.XAggregation \
+ -Tcom.sun.star.uno.XWeak \
+ -Tcom.sun.star.reflection.XIdlClassProvider
+
+$(BIN)$/testcppu.rdb: $(ALLIDLFILES)
+ +unoidl -I$(PRJ) -I$(SOLARIDLDIR) -Burd -OH$(BIN) $?
+ +regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)}
+ +regmerge $@ / $(UNOUCRRDB)
+ touch $@
+
+unoheader: $(BIN)$/testcppu.rdb
+ +cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) $(TYPES) $(BIN)$/testcppu.rdb
+
diff --git a/cppu/test/surrogate.hxx b/cppu/test/surrogate.hxx
new file mode 100644
index 000000000000..bb60f491055e
--- /dev/null
+++ b/cppu/test/surrogate.hxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * $RCSfile: surrogate.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:54 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <uno/dispatcher.h>
+#include <uno/mapping.hxx>
+#include <uno/environment.h>
+#include <uno/data.h>
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+/*
+//==================================================================================================
+struct UnoMediator : public uno_Interface
+{
+ oslInterlockedCount nRef;
+ uno_Interface * pDest;
+
+ UnoMediator( uno_Interface * pDest );
+ ~UnoMediator();
+};
+
+//--------------------------------------------------------------------------------------------------
+inline static void SAL_CALL UnoMediator_acquire( uno_Interface * pUnoI )
+{
+ osl_incrementInterlockedCount( &((UnoMediator *)pUnoI)->nRef );
+}
+//--------------------------------------------------------------------------------------------------
+inline static void SAL_CALL UnoMediator_release( uno_Interface * pUnoI )
+{
+ if (! osl_decrementInterlockedCount( &((UnoMediator *)pUnoI)->nRef ))
+ delete (UnoMediator *)pUnoI;
+}
+//--------------------------------------------------------------------------------------------------
+inline static void SAL_CALL UnoMediator_dispatch(
+ uno_Interface * pUnoI, const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ (*((UnoMediator *)pUnoI)->pDest->pDispatcher)(
+ ((UnoMediator *)pUnoI)->pDest, pMemberType, pReturn, pArgs, ppException );
+}
+
+//__________________________________________________________________________________________________
+UnoMediator::UnoMediator( uno_Interface * pDest_ )
+ : nRef( 0 )
+ , pDest( pDest_ )
+{
+ (*pDest->acquire)( pDest );
+ uno_Interface::acquire = UnoMediator_acquire;
+ uno_Interface::release = UnoMediator_release;
+ uno_Interface::pDispatcher = UnoMediator_dispatch;
+}
+//__________________________________________________________________________________________________
+UnoMediator::~UnoMediator()
+{
+ (*pDest->release)( pDest );
+}
+*/
+
+//##################################################################################################
+
+template< class T >
+inline sal_Bool makeSurrogate( com::sun::star::uno::Reference< T > & rOut,
+ const com::sun::star::uno::Reference< T > & rOriginal )
+{
+ rOut.clear();
+
+ typelib_TypeDescription * pTD = 0;
+ const com::sun::star::uno::Type & rType = ::getCppuType( &rOriginal );
+ TYPELIB_DANGER_GET( &pTD, rType.getTypeLibType() );
+ OSL_ENSHURE( pTD, "### cannot get typedescription!" );
+ if (pTD)
+ {
+ uno_Environment * pCppEnv1 = 0;
+ uno_Environment * pCppEnv2 = 0;
+
+ ::rtl::OUString aCppEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ uno_getEnvironment( &pCppEnv1, aCppEnvTypeName.pData, 0 );
+ uno_createEnvironment( &pCppEnv2, aCppEnvTypeName.pData, 0 ); // anonymous
+
+ ::com::sun::star::uno::Mapping aMapping( pCppEnv1, pCppEnv2, ::rtl::OUString::createFromAscii("prot") );
+ T * p = (T *)aMapping.mapInterface( rOriginal.get(), (typelib_InterfaceTypeDescription *)pTD );
+ if (p)
+ {
+ rOut = p;
+ p->release();
+ }
+
+ (*pCppEnv2->release)( pCppEnv2 );
+ (*pCppEnv1->release)( pCppEnv1 );
+
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+/*
+ ::com::sun::star::uno::Mapping aCpp2Uno( CPPU_CURRENT_LANGUAGE_BINDING_NAME, UNO_LB_UNO );
+ ::com::sun::star::uno::Mapping aUno2Cpp( UNO_LB_UNO, CPPU_CURRENT_LANGUAGE_BINDING_NAME );
+ OSL_ENSHURE( aCpp2Uno.is() && aUno2Cpp.is(), "### cannot get mappings!" );
+ if (aCpp2Uno.is() && aUno2Cpp.is())
+ {
+ typelib_TypeDescription * pTD = 0;
+ const com::sun::star::uno::Type & rType = ::getCppuType( &rOriginal );
+ TYPELIB_DANGER_GET( &pTD, rType.getTypeLibType() );
+ OSL_ENSHURE( pTD, "### cannot get typedescription!" );
+ if (pTD)
+ {
+ uno_Interface * pUno = (uno_Interface *)aCpp2Uno.mapInterface(
+ rOriginal.get(), (typelib_InterfaceTypeDescription *)pTD );
+ if (pUno)
+ {
+ UnoMediator * pPseudo = new UnoMediator( pUno );
+ (*pPseudo->acquire)( pPseudo );
+ OSL_ENSHURE( uno_equals( &pUno, &pPseudo, pTD, 0 ), "### interfaces don't belong to same object, but they do!?" );
+ (*pUno->release)( pUno );
+
+ T * pCpp = (T *)aUno2Cpp.mapInterface(
+ pPseudo, (typelib_InterfaceTypeDescription *)pTD );
+ (*pPseudo->release)( pPseudo );
+
+ if (pCpp)
+ {
+ rOut = pCpp;
+ pCpp->release();
+ }
+ }
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ }
+*/
+ return rOut.is();
+}
diff --git a/cppu/test/test_di.cxx b/cppu/test/test_di.cxx
new file mode 100644
index 000000000000..5f8e750fb179
--- /dev/null
+++ b/cppu/test/test_di.cxx
@@ -0,0 +1,608 @@
+/*************************************************************************
+ *
+ * $RCSfile: test_di.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:54 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <rtl/ustring.hxx>
+#include <osl/diagnose.h>
+#include <osl/time.h>
+//
+#include <uno/dispatcher.h>
+#include <uno/environment.h>
+#include <uno/mapping.hxx>
+#include <uno/data.h>
+
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppu/macros.hxx>
+#include <test/XLanguageBindingTest.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+
+
+using namespace test;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace osl;
+using namespace rtl;
+
+
+//==================================================================================================
+sal_Bool equals( const test::TestElement & rData1, const test::TestElement & rData2 )
+{
+ OSL_ENSHURE( rData1.Bool == rData2.Bool, "### bool does not match!" );
+ OSL_ENSHURE( rData1.Char == rData2.Char, "### char does not match!" );
+ OSL_ENSHURE( rData1.Byte == rData2.Byte, "### byte does not match!" );
+ OSL_ENSHURE( rData1.Short == rData2.Short, "### short does not match!" );
+ OSL_ENSHURE( rData1.UShort == rData2.UShort, "### unsigned short does not match!" );
+ OSL_ENSHURE( rData1.Long == rData2.Long, "### long does not match!" );
+ OSL_ENSHURE( rData1.ULong == rData2.ULong, "### unsigned long does not match!" );
+ OSL_ENSHURE( rData1.Hyper == rData2.Hyper, "### hyper does not match!" );
+ OSL_ENSHURE( rData1.UHyper == rData2.UHyper, "### unsigned hyper does not match!" );
+ OSL_ENSHURE( rData1.Float == rData2.Float, "### float does not match!" );
+ OSL_ENSHURE( rData1.Double == rData2.Double, "### double does not match!" );
+ OSL_ENSHURE( rData1.Enum == rData2.Enum, "### enum does not match!" );
+ OSL_ENSHURE( rData1.String == rData2.String, "### string does not match!" );
+ OSL_ENSHURE( rData1.Interface == rData2.Interface, "### interface does not match!" );
+ OSL_ENSHURE( rData1.Any == rData2.Any, "### any does not match!" );
+
+ return (rData1.Bool == rData2.Bool &&
+ rData1.Char == rData2.Char &&
+ rData1.Byte == rData2.Byte &&
+ rData1.Short == rData2.Short &&
+ rData1.UShort == rData2.UShort &&
+ rData1.Long == rData2.Long &&
+ rData1.ULong == rData2.ULong &&
+ rData1.Hyper == rData2.Hyper &&
+ rData1.UHyper == rData2.UHyper &&
+ rData1.Float == rData2.Float &&
+ rData1.Double == rData2.Double &&
+ rData1.Enum == rData2.Enum &&
+ rData1.String == rData2.String &&
+ rData1.Interface == rData2.Interface &&
+ rData1.Any == rData2.Any);
+}
+//==================================================================================================
+sal_Bool equals( const test::TestData & rData1, const test::TestData & rData2 )
+{
+ sal_Int32 nLen;
+
+ if ((rData1.Sequence == rData2.Sequence) &&
+ equals( (const test::TestElement &)rData1, (const test::TestElement &)rData2 ) &&
+ (nLen = rData1.Sequence.getLength()) == rData2.Sequence.getLength())
+ {
+ // once again by hand sequence ==
+ const test::TestElement * pElements1 = rData1.Sequence.getConstArray();
+ const test::TestElement * pElements2 = rData2.Sequence.getConstArray();
+ for ( ; nLen--; )
+ {
+ if (! equals( pElements1[nLen], pElements2[nLen] ))
+ {
+ OSL_ENSHURE( sal_False, "### sequence element did not match!" );
+ return sal_False;
+ }
+ }
+ return sal_True;
+ }
+ return sal_False;
+}
+//==================================================================================================
+void assign( test::TestElement & rData,
+ sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny )
+{
+ rData.Bool = bBool;
+ rData.Char = cChar;
+ rData.Byte = nByte;
+ rData.Short = nShort;
+ rData.UShort = nUShort;
+ rData.Long = nLong;
+ rData.ULong = nULong;
+ rData.Hyper = nHyper;
+ rData.UHyper = nUHyper;
+ rData.Float = fFloat;
+ rData.Double = fDouble;
+ rData.Enum = eEnum;
+ rData.String = rStr;
+ rData.Interface = xTest;
+ rData.Any = rAny;
+}
+//==================================================================================================
+void assign( test::TestData & rData,
+ sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny,
+ const com::sun::star::uno::Sequence< test::TestElement >& rSequence )
+{
+ assign( (test::TestElement &)rData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, xTest, rAny );
+ rData.Sequence = rSequence;
+}
+
+//==================================================================================================
+class Test_Impl : public cppu::WeakImplHelper1< XLanguageBindingTest >
+{
+ test::TestData _aData, _aStructData;
+
+public:
+ virtual ~Test_Impl()
+ { OSL_TRACE( "> scalar Test_Impl dtor <\n" ); }
+
+ // XLBTestBase
+ virtual void SAL_CALL setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny,
+ const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ const test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException);
+
+ virtual test::TestData SAL_CALL setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException);
+
+ virtual test::TestData SAL_CALL getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence< test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL getBool() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Bool; }
+ virtual sal_Int8 SAL_CALL getByte() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Byte; }
+ virtual sal_Unicode SAL_CALL getChar() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Char; }
+ virtual sal_Int16 SAL_CALL getShort() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Short; }
+ virtual sal_uInt16 SAL_CALL getUShort() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.UShort; }
+ virtual sal_Int32 SAL_CALL getLong() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Long; }
+ virtual sal_uInt32 SAL_CALL getULong() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.ULong; }
+ virtual sal_Int64 SAL_CALL getHyper() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Hyper; }
+ virtual sal_uInt64 SAL_CALL getUHyper() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.UHyper; }
+ virtual float SAL_CALL getFloat() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Float; }
+ virtual double SAL_CALL getDouble() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Double; }
+ virtual test::TestEnum SAL_CALL getEnum() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Enum; }
+ virtual rtl::OUString SAL_CALL getString() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.String; }
+ virtual com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getInterface( ) throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Interface; }
+ virtual com::sun::star::uno::Any SAL_CALL getAny() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Any; }
+ virtual com::sun::star::uno::Sequence< test::TestElement > SAL_CALL getSequence() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Sequence; }
+ virtual test::TestData SAL_CALL getStruct() throw(com::sun::star::uno::RuntimeException)
+ { return _aStructData; }
+
+ virtual void SAL_CALL setBool( sal_Bool _bool ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Bool = _bool; }
+ virtual void SAL_CALL setByte( sal_Int8 _byte ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Byte = _byte; }
+ virtual void SAL_CALL setChar( sal_Unicode _char ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Char = _char; }
+ virtual void SAL_CALL setShort( sal_Int16 _short ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Short = _short; }
+ virtual void SAL_CALL setUShort( sal_uInt16 _ushort ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.UShort = _ushort; }
+ virtual void SAL_CALL setLong( sal_Int32 _long ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Long = _long; }
+ virtual void SAL_CALL setULong( sal_uInt32 _ulong ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.ULong = _ulong; }
+ virtual void SAL_CALL setHyper( sal_Int64 _hyper ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Hyper = _hyper; }
+ virtual void SAL_CALL setUHyper( sal_uInt64 _uhyper ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.UHyper = _uhyper; }
+ virtual void SAL_CALL setFloat( float _float ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Float = _float; }
+ virtual void SAL_CALL setDouble( double _double ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Double = _double; }
+ virtual void SAL_CALL setEnum( test::TestEnum _enum ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Enum = _enum; }
+ virtual void SAL_CALL setString( const ::rtl::OUString& _string ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.String = _string; }
+ virtual void SAL_CALL setInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _interface ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Interface = _interface; }
+ virtual void SAL_CALL setAny( const ::com::sun::star::uno::Any& _any ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Any = _any; }
+ virtual void SAL_CALL setSequence( const ::com::sun::star::uno::Sequence<test::TestElement >& _sequence ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Sequence = _sequence; }
+ virtual void SAL_CALL setStruct( const test::TestData& _struct ) throw(::com::sun::star::uno::RuntimeException)
+ { _aStructData = _struct; }
+
+ // XLanguageBindingTest
+ virtual test::TestData SAL_CALL raiseException( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, sal_Int16& nShort, sal_uInt16& nUShort, sal_Int32& nLong, sal_uInt32& nULong, sal_Int64& nHyper, sal_uInt64& nUHyper, float& fFloat, double& fDouble, test::TestEnum& eEnum, ::rtl::OUString& aString, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInterface, ::com::sun::star::uno::Any& aAny, ::com::sun::star::uno::Sequence<test::TestElement >& aSequence,test::TestData& aStruct )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getRuntimeException() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRuntimeException( sal_Int32 _runtimeexception ) throw(::com::sun::star::uno::RuntimeException);
+};
+//__________________________________________________________________________________________________
+void Test_Impl::setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny,
+ const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ const test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ assign( _aData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, xTest, rAny, rSequence );
+ _aStructData = rStruct;
+}
+//__________________________________________________________________________________________________
+test::TestData Test_Impl::setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ assign( _aData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, xTest, rAny, rSequence );
+ _aStructData = rStruct;
+ return _aStructData;
+}
+//__________________________________________________________________________________________________
+test::TestData Test_Impl::getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ bBool = _aData.Bool;
+ cChar = _aData.Char;
+ nByte = _aData.Byte;
+ nShort = _aData.Short;
+ nUShort = _aData.UShort;
+ nLong = _aData.Long;
+ nULong = _aData.ULong;
+ nHyper = _aData.Hyper;
+ nUHyper = _aData.UHyper;
+ fFloat = _aData.Float;
+ fDouble = _aData.Double;
+ eEnum = _aData.Enum;
+ rStr = _aData.String;
+ xTest = _aData.Interface;
+ rAny = _aData.Any;
+ rSequence = _aData.Sequence;
+ rStruct = _aStructData;
+ return _aStructData;
+}
+
+//==================================================================================================
+sal_Bool performTest( const Reference<XLanguageBindingTest > & xLBT )
+{
+ OSL_ENSHURE( xLBT.is(), "### no test interface!" );
+ if (xLBT.is())
+ {
+ // this data is never ever granted access to by calls other than equals(), assign()!
+ test::TestData aData; // test against this data
+
+ Reference<XInterface > xI( *new OWeakObject() );
+
+ assign( (test::TestElement &)aData,
+ sal_True, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210,
+ (float)17.0815, 3.1415926359, TestEnum_LOLA,
+ OUString::createFromAscii("dumdidum"), xI,
+ Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
+
+ OSL_ENSHURE( aData.Any == xI, "### unexpected any!" );
+ OSL_ENSHURE( !(aData.Any != xI), "### unexpected any!" );
+
+ aData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aData, 1 );
+ // aData complete
+ //================================================================================
+
+ // this is a manually copy of aData for first setting...
+ test::TestData aSetData;
+
+ assign( (test::TestElement &)aSetData,
+ aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort,
+ aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, aData.Double,
+ aData.Enum, aData.String, xI,
+ Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
+
+ aSetData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aSetData, 1 );
+
+ xLBT->setValues(
+ aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, aSetData.UShort,
+ aSetData.Long, aSetData.ULong, aSetData.Hyper, aSetData.UHyper, aSetData.Float, aSetData.Double,
+ aSetData.Enum, aSetData.String, aSetData.Interface, aSetData.Any, aSetData.Sequence, aSetData );
+
+ {
+ test::TestData aRet, aRet2;
+ xLBT->getValues(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+
+ OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) );
+
+ // set last retrieved values
+ test::TestData aSV2ret = xLBT->setValues2(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+
+ OSL_ASSERT( equals( aData, aSV2ret ) && equals( aData, aRet2 ) );
+ }
+ {
+ test::TestData aRet, aRet2;
+ test::TestData aGVret = xLBT->getValues(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+
+ OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) && equals( aData, aGVret ) );
+
+ // set last retrieved values
+ xLBT->setBool( aRet.Bool );
+ xLBT->setChar( aRet.Char );
+ xLBT->setByte( aRet.Byte );
+ xLBT->setShort( aRet.Short );
+ xLBT->setUShort( aRet.UShort );
+ xLBT->setLong( aRet.Long );
+ xLBT->setULong( aRet.ULong );
+ xLBT->setHyper( aRet.Hyper );
+ xLBT->setUHyper( aRet.UHyper );
+ xLBT->setFloat( aRet.Float );
+ xLBT->setDouble( aRet.Double );
+ xLBT->setEnum( aRet.Enum );
+ xLBT->setString( aRet.String );
+ xLBT->setInterface( aRet.Interface );
+ xLBT->setAny( aRet.Any );
+ xLBT->setSequence( aRet.Sequence );
+ xLBT->setStruct( aRet2 );
+ }
+ {
+ test::TestData aRet, aRet2;
+ aRet.Hyper = xLBT->getHyper();
+ aRet.UHyper = xLBT->getUHyper();
+ aRet.Float = xLBT->getFloat();
+ aRet.Double = xLBT->getDouble();
+ aRet.Byte = xLBT->getByte();
+ aRet.Char = xLBT->getChar();
+ aRet.Bool = xLBT->getBool();
+ aRet.Short = xLBT->getShort();
+ aRet.UShort = xLBT->getUShort();
+ aRet.Long = xLBT->getLong();
+ aRet.ULong = xLBT->getULong();
+ aRet.Enum = xLBT->getEnum();
+ aRet.String = xLBT->getString();
+ aRet.Interface = xLBT->getInterface();
+ aRet.Any = xLBT->getAny();
+ aRet.Sequence = xLBT->getSequence();
+ aRet2 = xLBT->getStruct();
+
+ return (equals( aData, aRet ) && equals( aData, aRet2 ));
+ }
+ }
+ return sal_False;
+}
+
+//__________________________________________________________________________________________________
+test::TestData Test_Impl::raiseException( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, sal_Int16& nShort, sal_uInt16& nUShort, sal_Int32& nLong, sal_uInt32& nULong, sal_Int64& nHyper, sal_uInt64& nUHyper, float& fFloat, double& fDouble, test::TestEnum& eEnum, ::rtl::OUString& aString, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInterface, ::com::sun::star::uno::Any& aAny, ::com::sun::star::uno::Sequence< test::TestElement >& aSequence, test::TestData& aStruct )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ IllegalArgumentException aExc;
+ aExc.ArgumentPosition = 5;
+ aExc.Message = OUString::createFromAscii( "dum dum dum ich tanz im kreis herum..." );
+ aExc.Context = getInterface();
+ throw aExc;
+ return test::TestData();
+}
+//__________________________________________________________________________________________________
+sal_Int32 Test_Impl::getRuntimeException() throw(::com::sun::star::uno::RuntimeException)
+{
+ RuntimeException aExc;
+ aExc.Message = OUString::createFromAscii( "dum dum dum ich tanz im kreis herum..." );
+ aExc.Context = getInterface();
+ throw aExc;
+ return 0;
+}
+//__________________________________________________________________________________________________
+void Test_Impl::setRuntimeException( sal_Int32 _runtimeexception ) throw(::com::sun::star::uno::RuntimeException)
+{
+ RuntimeException aExc;
+ aExc.Message = OUString::createFromAscii( "dum dum dum ich tanz im kreis herum..." );
+ aExc.Context = getInterface();
+ throw aExc;
+}
+//==================================================================================================
+sal_Bool raiseException( const Reference< XLanguageBindingTest > & xLBT )
+{
+ sal_Int32 nCount = 0;
+ try
+ {
+ try
+ {
+ try
+ {
+ test::TestData aRet, aRet2;
+ xLBT->raiseException(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+ }
+ catch (IllegalArgumentException aExc)
+ {
+ ++nCount;
+ OSL_ENSHURE( aExc.ArgumentPosition == 5 &&
+ aExc.Context == xLBT->getInterface() &&
+ aExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...") ),
+ "### unexpected exception content!" );
+
+ /** it is certain, that the RuntimeException testing will fail, if no */
+ xLBT->getRuntimeException();
+ }
+ }
+ catch (const RuntimeException & rExc)
+ {
+ ++nCount;
+ OSL_ENSHURE( rExc.Context == xLBT->getInterface() &&
+ rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...") ),
+ "### unexpected exception content!" );
+
+ /** it is certain, that the RuntimeException testing will fail, if no */
+ xLBT->setRuntimeException( 0xcafebabe );
+ }
+ }
+ catch (Exception & rExc)
+ {
+ ++nCount;
+ OSL_ENSHURE( rExc.Context == xLBT->getInterface() &&
+ rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...") ),
+ "### unexpected exception content!" );
+ return (nCount == 3 &&
+ rExc.Context == xLBT->getInterface() &&
+ rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...") ));
+ }
+ return sal_False;
+}
+
+//==================================================================================================
+void test_di(void)
+{
+ Reference<XLanguageBindingTest > xOriginal( (XLanguageBindingTest *)new Test_Impl() );
+ Reference<XLanguageBindingTest > xLBT;
+
+ uno_Environment * pCppEnv1 = 0;
+ uno_Environment * pCppEnv2 = 0;
+
+ OUString aCppEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ uno_getEnvironment( &pCppEnv1, aCppEnvTypeName.pData, 0 );
+ uno_createEnvironment( &pCppEnv2, aCppEnvTypeName.pData, 0 ); // anonymous
+
+ Mapping aMapping( pCppEnv1, pCppEnv2, OUString::createFromAscii("prot") );
+ aMapping.mapInterface( (void **)&xLBT, xOriginal.get(), ::getCppuType( &xOriginal ) );
+ OSL_ENSHURE( aMapping.is(), "### cannot get mapping!" );
+
+ (*pCppEnv2->release)( pCppEnv2 );
+ (*pCppEnv1->release)( pCppEnv1 );
+
+ OSL_ASSERT( xLBT.is() );
+
+ if (xLBT.is() && performTest( xLBT ))
+ {
+ if (raiseException( xLBT ))
+ {
+ printf( "> dynamic invocation test succeeded!\n" );
+ return;
+ }
+ }
+ printf( "> dynamic invocation test failed!\n" );
+}
diff --git a/cppu/test/testcppu.cxx b/cppu/test/testcppu.cxx
new file mode 100644
index 000000000000..d08b29214b5a
--- /dev/null
+++ b/cppu/test/testcppu.cxx
@@ -0,0 +1,886 @@
+/*************************************************************************
+ *
+ * $RCSfile: testcppu.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:54 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <uno/environment.h>
+#include <uno/mapping.hxx>
+
+#include <uno/dispatcher.h>
+#include <rtl/alloc.h>
+
+#include <cppuhelper/queryinterface.hxx>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Uik.hpp>
+#include <rtl/ustring.hxx>
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+
+
+#include <test/Test1.hpp>
+#include <test/Test2.hpp>
+#include <test/TdTest1.hpp>
+#include <test/Test3.hpp>
+#include <test/Base.hpp>
+#include <test/Base1.hpp>
+#include <test/Base2.hpp>
+
+#include <cppuhelper/servicefactory.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <test/XSimpleInterface.hpp>
+#include <test/XLanguageBindingTest.hpp>
+
+using namespace test;
+using namespace rtl;
+using namespace osl;
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace test;
+
+
+sal_Int32 getSize( const Type & rT )
+{
+ sal_Int32 nSize;
+ typelib_TypeDescription * pTD = 0;
+ typelib_typedescriptionreference_getDescription( &pTD, rT.getTypeLibType() );
+ nSize = pTD->nSize;
+ typelib_typedescription_release( pTD );
+ return nSize;
+}
+/*
+ * main.
+ */
+void testCppu()
+{
+ {
+ // test the size of types
+ OSL_ENSHURE( sizeof( Uik ) == getSize( getCppuType( (Uik *)0) ),
+ "bad sizeof uik" );
+ OSL_ENSHURE( sizeof( Test1 ) == getSize( getCppuType( (Test1*)0).getTypeLibType() ),
+ "bad sizeof test1" );
+// OSL_ENSHURE( sizeof( TdTest1 ) == getSize( get_test_TdTest1_Type().getTypeLibType() ),
+// "bad sizeof TypedefTest1" );
+ OSL_ENSHURE( sizeof( Test2 ) == getSize( getCppuType( (Test2*)0).getTypeLibType() ),
+ "bad sizeof test2" );
+
+/* find the error
+sal_Int32 nPos;
+nPos = (sal_Int32)&((Test3 *)0)->nInt8;
+nPos = (sal_Int32)&((Test3 *)0)->nFloat;
+nPos = (sal_Int32)&((Test3 *)0)->nuInt8;
+nPos = (sal_Int32)&((Test3 *)0)->nDouble;
+nPos = (sal_Int32)&((Test3 *)0)->nInt16;
+nPos = (sal_Int32)&((Test3 *)0)->aString;
+nPos = (sal_Int32)&((Test3 *)0)->nuInt16;
+nPos = (sal_Int32)&((Test3 *)0)->nInt64;
+nPos = (sal_Int32)&((Test3 *)0)->nInt32;
+nPos = (sal_Int32)&((Test3 *)0)->nuInt64;
+nPos = (sal_Int32)&((Test3 *)0)->nuInt32;
+nPos = (sal_Int32)&((Test3 *)0)->eType;
+nPos = (sal_Int32)&((Test3 *)0)->wChar;
+nPos = (sal_Int32)&((Test3 *)0)->td;
+nPos = (sal_Int32)&((Test3 *)0)->bBool;
+nPos = (sal_Int32)&((Test3 *)0)->aAny;
+*/
+ OSL_ENSHURE( sizeof( Test3 ) == getSize( getCppuType( (Test3*)0).getTypeLibType() ),
+ "bad sizeof test3" );
+ }
+
+ {
+ // test the default constructor
+ Test1 a1;
+ a1.nInt16 = 4;
+ a1.dDouble = 3.6;
+ a1.bBool = sal_True;
+ uno_type_constructData( &a1, getCppuType( (Test1*)0).getTypeLibType() );
+ OSL_ASSERT( a1.nInt16 == 0 && a1.dDouble == 0.0 && a1.bBool == sal_False);
+
+ Test2 a2;
+ a2.nInt16 = 2;
+ a2.aTest1.nInt16 = 4;
+ a2.aTest1.dDouble = 3.6;
+ a2.aTest1.dDouble = sal_True;
+ uno_type_constructData( &a2, getCppuType( (Test2*)0).getTypeLibType() );
+ OSL_ASSERT( a2.nInt16 == 0 && a2.aTest1.nInt16 == 0 && a2.aTest1.dDouble == 0.0 && a2.aTest1.bBool == sal_False);
+
+ Test3 * pa3 = (Test3 *)new char[ sizeof( Test3 ) ];
+ Test3 & a3 = *pa3;
+ a3.nInt8 = 2;
+ a3.nFloat = (float)2;
+ a3.nDouble = 2;
+ a3.nInt16 = 2;
+ a3.nuInt16 = 2;
+ a3.nInt64 = 2;
+ a3.nInt32 = 2;
+ a3.nuInt64 = 2;
+ a3.nuInt32 = 2;
+ a3.eType = TypeClass_STRUCT;
+ a3.wChar = L'g';
+ a3.td.nInt16 = 2;
+ a3.td.dDouble = 2;
+ a3.bBool = sal_True;
+ uno_type_constructData( &a3, getCppuType( (Test3*)0).getTypeLibType() );
+ OSL_ASSERT( a3.nInt8 == 0 && a3.nFloat == (float)0
+ && a3.nDouble == 0 && a3.nInt16 == 0 && a3.aString == OUString()
+ && a3.nuInt16 == 0 && a3.nInt64 == 0 && a3.nInt32 == 0
+ && a3.nuInt64 == 0 && a3.nuInt32 == 0 && a3.eType == TypeClass_VOID
+ && a3.wChar == L'\0' && a3.td.nInt16 == 0 && a3.td.dDouble == 0
+ && a3.bBool == sal_False );
+ OSL_ASSERT( a3.aAny.getValueType() == getCppuVoidType() );
+ delete pa3;
+ }
+
+ {
+ // test the destructor
+ long a1[ sizeof( Test1 ) / sizeof(long) +1 ];
+ uno_type_constructData( &a1, getCppuType( (Test1*)0).getTypeLibType() );
+ uno_type_destructData( &a1, getCppuType( (Test1*)0).getTypeLibType(), cpp_release );
+
+ long a2[ sizeof( Test2 ) / sizeof(long) +1 ];
+ uno_type_constructData( &a2, getCppuType( (Test2*)0).getTypeLibType() );
+ uno_type_destructData( &a2, getCppuType( (Test2*)0).getTypeLibType(), cpp_release );
+
+ long a3[ sizeof( Test3 ) / sizeof(long) +1 ];
+ uno_type_constructData( &a3, getCppuType( (Test3*)0).getTypeLibType() );
+ OUString aTestString( RTL_CONSTASCII_USTRINGPARAM("test") );
+ ((Test3*)a3)->aString = aTestString;
+ uno_type_destructData( &a3, getCppuType( (Test3*)0).getTypeLibType(), cpp_release );
+ OSL_ASSERT( aTestString.pData->refCount == 1 );
+ }
+
+ {
+ // test the copy constructor
+ Test1 a1;
+ a1.nInt16 = 4;
+ a1.dDouble = 3.6;
+ a1.bBool = sal_True;
+ char sz1[sizeof( Test1 )];
+ uno_type_copyData( sz1, &a1, getCppuType( (Test1*)0).getTypeLibType(), cpp_acquire );
+ OSL_ASSERT( ((Test1*)sz1)->nInt16 == 4 && ((Test1*)sz1)->dDouble == 3.6 && ((Test1*)sz1)->bBool == sal_True);
+
+ Test2 a2;
+ a2.nInt16 = 2;
+ a2.aTest1.nInt16 = 4;
+ a2.aTest1.dDouble = 3.6;
+ a2.aTest1.bBool = sal_True;
+ char sz2[sizeof( Test2 )];
+ uno_type_copyData( sz2, &a2, getCppuType( (Test2*)0).getTypeLibType(), cpp_acquire );
+ OSL_ASSERT( ((Test2*)sz2)->nInt16 == 2 );
+ OSL_ASSERT(((Test2*)sz2)->aTest1.nInt16 == 4 );
+ OSL_ASSERT( ((Test2*)sz2)->aTest1.dDouble == 3.6 );
+ OSL_ASSERT(((Test2*)sz2)->aTest1.bBool == sal_True);
+
+ Test3 a3;
+ a3.nInt8 = 2;
+ a3.nFloat = (float)2;
+ a3.nDouble = 2;
+ a3.nInt16 = 2;
+ a3.aString = OUString::createFromAscii("2");
+ a3.nuInt16 = 2;
+ a3.nInt64 = 2;
+ a3.nInt32 = 2;
+ a3.nuInt64 = 2;
+ a3.nuInt32 = 2;
+ a3.eType = TypeClass_STRUCT;
+ a3.wChar = L'2';
+ a3.td.nInt16 = 2;
+ a3.td.dDouble = 2;
+ a3.bBool = sal_True;
+ a3.aAny = makeAny( (sal_Int32)2 );
+ char sz3[sizeof( Test3 )];
+ uno_type_copyData( sz3, &a3, getCppuType( (Test3*)0).getTypeLibType(), cpp_acquire );
+ OSL_ASSERT( ((Test3*)sz3)->nInt8 == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->nFloat == (float)2 );
+ OSL_ASSERT( ((Test3*)sz3)->nDouble == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->nInt16 == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->aString == OUString::createFromAscii("2") );
+ OSL_ASSERT( ((Test3*)sz3)->nuInt16 == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->nInt64 == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->nInt32 == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->nuInt64 == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->nuInt32 == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->eType == TypeClass_STRUCT );
+ OSL_ASSERT( ((Test3*)sz3)->wChar == L'2' );
+ OSL_ASSERT( ((Test3*)sz3)->td.nInt16 == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->td.dDouble == 2 );
+ OSL_ASSERT( ((Test3*)sz3)->bBool == sal_True );
+ OSL_ASSERT( ((Test3*)sz3)->aAny.getValueType() == getCppuType( (sal_Int32 *)0 ) );
+ OSL_ASSERT( *(sal_Int32*)((Test3*)sz3)->aAny.getValue() == 2 );
+ ((Test3 *)sz3)->~Test3();
+ }
+
+ {
+ sal_Bool bAssignable;
+ // test assignment
+ Test1 a1;
+ a1.nInt16 = 4;
+ a1.dDouble = 3.6;
+ a1.bBool = sal_True;
+ Test1 sz1;
+ bAssignable = uno_type_assignData(
+ &sz1, getCppuType( (Test1*)0).getTypeLibType(),
+ &a1, getCppuType( (Test1*)0).getTypeLibType(),
+ cpp_queryInterface, cpp_acquire, cpp_release );
+ OSL_ASSERT( bAssignable );
+ OSL_ASSERT( sz1.nInt16 == 4 && sz1.dDouble == 3.6 && sz1.bBool == sal_True);
+
+ Test2 a2;
+ a2.nInt16 = 2;
+ a2.aTest1.nInt16 = 4;
+ a2.aTest1.dDouble = 3.6;
+ a2.aTest1.bBool = sal_True;
+ Test2 sz2;
+ bAssignable = uno_type_assignData(
+ &sz2, getCppuType( (Test2*)0).getTypeLibType(),
+ &a2, getCppuType( (Test2*)0).getTypeLibType(),
+ cpp_queryInterface, cpp_acquire, cpp_release );
+ OSL_ASSERT( bAssignable );
+ OSL_ASSERT( sz2.nInt16 == 2 && sz2.aTest1.nInt16 == 4
+ && sz2.aTest1.dDouble == 3.6 && sz2.aTest1.bBool == sal_True);
+
+ Test3 a3;
+ Test3 sz3;
+ a3.nInt8 = 2;
+ a3.nFloat = (float)2;
+ a3.nDouble = 2;
+ a3.nInt16 = 2;
+ a3.aString = OUString::createFromAscii("2");
+ a3.nuInt16 = 2;
+ a3.nInt64 = 2;
+ a3.nInt32 = 2;
+ a3.nuInt64 = 2;
+ a3.nuInt32 = 2;
+ a3.eType = TypeClass_STRUCT;
+ a3.wChar = L'2';
+ a3.td.nInt16 = 2;
+ a3.td.dDouble = 2;
+ a3.bBool = sal_True;
+ a3.aAny = makeAny( (sal_Int32)2 );
+ bAssignable = uno_type_assignData(
+ &sz3, getCppuType( (Test3*)0).getTypeLibType(),
+ &a3, getCppuType( (Test3*)0).getTypeLibType(),
+ cpp_queryInterface, cpp_acquire, cpp_release );
+ OSL_ASSERT( bAssignable );
+ OSL_ASSERT( sz3.nInt8 == 2 );
+ OSL_ASSERT( sz3.nFloat == (float)2 );
+ OSL_ASSERT( sz3.nDouble == 2 );
+ OSL_ASSERT( sz3.nInt16 == 2 );
+ OSL_ASSERT( sz3.aString == OUString::createFromAscii("2") );
+ OSL_ASSERT( sz3.nuInt16 == 2 );
+ OSL_ASSERT( sz3.nInt64 == 2 );
+ OSL_ASSERT( sz3.nInt32 == 2 );
+ OSL_ASSERT( sz3.nuInt64 == 2 );
+ OSL_ASSERT( sz3.nuInt32 == 2 );
+ OSL_ASSERT( sz3.eType == TypeClass_STRUCT );
+ OSL_ASSERT( sz3.wChar == L'2' );
+ OSL_ASSERT( sz3.td.nInt16 == 2 );
+ OSL_ASSERT( sz3.td.dDouble == 2 );
+ OSL_ASSERT( sz3.bBool == sal_True );
+ OSL_ASSERT( sz3.aAny.getValueType() == getCppuType( (sal_Int32 *)0 ) );
+ OSL_ASSERT( *(sal_Int32*)sz3.aAny.getValue() == 2 );
+
+ // test not assigneable values
+ bAssignable = uno_type_assignData(
+ &a1, getCppuType( (Test1*)0).getTypeLibType(),
+ &a2, getCppuType( (Test2*)0).getTypeLibType(),
+ cpp_queryInterface, cpp_acquire, cpp_release );
+ OSL_ASSERT( !bAssignable );
+ }
+
+ {
+ // test any
+ Any aAny = makeAny( (sal_Int8)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_Int8 *)0 ) );
+ OSL_ASSERT( *(sal_Int8*)aAny.getValue() == 2 );
+ aAny = makeAny( (float)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (float *)0 ) );
+ OSL_ASSERT( *(float*)aAny.getValue() == (float)2 );
+ aAny = makeAny( (sal_Int8)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_Int8 *)0 ) );
+ OSL_ASSERT( *(sal_Int8*)aAny.getValue() == 2 );
+ aAny = makeAny( (double)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (double *)0 ) );
+ OSL_ASSERT( *(double*)aAny.getValue() == (double)2 );
+ aAny = makeAny( (sal_Int16)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_Int16 *)0 ) );
+ OSL_ASSERT( *(sal_Int16*)aAny.getValue() == 2 );
+ aAny = makeAny( OUString( RTL_CONSTASCII_USTRINGPARAM("test") ) );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (OUString *)0 ) );
+ OSL_ASSERT( *(OUString*)aAny.getValue() == OUString::createFromAscii("test") );
+ aAny = makeAny( (sal_uInt16)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_uInt16 *)0 ) );
+ OSL_ASSERT( *(sal_Int16*)aAny.getValue() == 2 );
+ sal_Int64 aInt64;
+ sal_setInt64( &aInt64, 2, 0 );
+ aAny = makeAny( aInt64 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_Int64 *)0 ) );
+ sal_uInt32 lowInt;
+ sal_Int32 highInt;
+ sal_getInt64( *(sal_Int64*)aAny.getValue(), &lowInt, &highInt );
+ OSL_ASSERT( lowInt == 2 && highInt == 0 );
+ aAny = makeAny( (sal_Int32)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_Int32 *)0 ) );
+ OSL_ASSERT( *(sal_Int32*)aAny.getValue() == 2 );
+ sal_uInt64 auInt64;
+ sal_setUInt64( &auInt64, 2, 0 );
+ aAny = makeAny( auInt64 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_uInt64 *)0 ) );
+ sal_uInt32 uhighInt;
+ sal_getUInt64( *(sal_Int64*)aAny.getValue(), &lowInt, &uhighInt );
+ OSL_ASSERT( lowInt == 2 && uhighInt == 0 );
+ aAny = makeAny( (sal_uInt32)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_uInt32 *)0 ) );
+ OSL_ASSERT( *(sal_uInt32*)aAny.getValue() == 2 );
+ aAny = makeAny( TypeClass_STRUCT );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (TypeClass *)0 ) );
+ OSL_ASSERT( *(TypeClass*)aAny.getValue() == TypeClass_STRUCT );
+ sal_Unicode c = L'2';
+ aAny.setValue( &c, getCppuCharType() );
+ OSL_ASSERT( aAny.getValueType() == getCppuCharType() );
+ OSL_ASSERT( *(sal_Unicode*)aAny.getValue() == L'2' );
+ sal_Bool b = sal_True;
+ aAny.setValue( &b, getCppuBooleanType() );
+ OSL_ASSERT( aAny.getValueType() == getCppuBooleanType() );
+ OSL_ASSERT( *(sal_Bool*)aAny.getValue() == sal_True );
+ }
+
+ {
+ // test: operator <<=( any, value )
+ Any aAny;
+ aAny <<= (sal_Int8)2;
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_Int8 *)0 ) );
+ OSL_ASSERT( *(sal_Int8*)aAny.getValue() == 2 );
+ aAny <<=( (float)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (float *)0 ) );
+ OSL_ASSERT( *(float*)aAny.getValue() == (float)2 );
+// aAny <<=( (sal_uInt8)2 );
+// OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_uInt8 *)0 ) );
+// OSL_ASSERT( *(sal_uInt8*)aAny.getValue() == 2 );
+ aAny <<=( (double)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (double *)0 ) );
+ OSL_ASSERT( *(double*)aAny.getValue() == (double)2 );
+ aAny <<=( (sal_Int16)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_Int16 *)0 ) );
+ OSL_ASSERT( *(sal_Int16*)aAny.getValue() == 2 );
+ aAny <<=( OUString( RTL_CONSTASCII_USTRINGPARAM("test") ) );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (OUString *)0 ) );
+ OSL_ASSERT( *(OUString*)aAny.getValue() == OUString::createFromAscii("test") );
+ aAny <<=( (sal_uInt16)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_uInt16 *)0 ) );
+ OSL_ASSERT( *(sal_Int16*)aAny.getValue() == 2 );
+ sal_Int64 aInt64;
+ sal_setInt64( &aInt64, 2, 0 );
+ aAny <<=( aInt64 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_Int64 *)0 ) );
+ sal_uInt32 lowInt;
+ sal_Int32 highInt;
+ sal_getInt64( *(sal_Int64*)aAny.getValue(), &lowInt, &highInt );
+ OSL_ASSERT( lowInt == 2 && highInt == 0 );
+ aAny <<=( (sal_Int32)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_Int32 *)0 ) );
+ OSL_ASSERT( *(sal_Int32*)aAny.getValue() == 2 );
+ sal_uInt64 auInt64;
+ sal_setUInt64( &auInt64, 2, 0 );
+ aAny <<=( auInt64 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_uInt64 *)0 ) );
+ sal_uInt32 uhighInt;
+ sal_getUInt64( *(sal_Int64*)aAny.getValue(), &lowInt, &uhighInt );
+ OSL_ASSERT( lowInt == 2 && uhighInt == 0 );
+ aAny <<=( (sal_uInt32)2 );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (sal_uInt32 *)0 ) );
+ OSL_ASSERT( *(sal_uInt32*)aAny.getValue() == 2 );
+ aAny <<=( TypeClass_STRUCT );
+ OSL_ASSERT( aAny.getValueType() == getCppuType( (TypeClass *)0 ) );
+ OSL_ASSERT( *(TypeClass*)aAny.getValue() == TypeClass_STRUCT );
+ }
+
+ {
+ // test: operator >>=( any, value )
+ Test3 a3;
+ makeAny( (sal_Int8)2) >>= a3.nInt8;
+ OSL_ASSERT( (makeAny( (sal_Int8)2) >>= a3.nInt8) && a3.nInt8 == 2 );
+ OSL_ASSERT( (makeAny( (float)2) >>= a3.nFloat) && a3.nFloat ==(float)2 );
+ OSL_ASSERT( (makeAny( (double)2) >>= a3.nDouble) && a3.nDouble == 2 );
+ OSL_ASSERT( (makeAny( (sal_Int16)2) >>= a3.nInt16) && a3.nInt16 == 2 );
+ OSL_ASSERT( (makeAny( OUString( RTL_CONSTASCII_USTRINGPARAM("2") )) >>= a3.aString) &&
+ a3.aString == OUString::createFromAscii("2") );
+ OSL_ASSERT( (makeAny( (sal_uInt16)2) >>= a3.nuInt16) && a3.nuInt16 == 2 );
+ sal_Int64 aInt64;
+ sal_uInt32 lowInt;
+ sal_Int32 highInt;
+ sal_setInt64( &aInt64, 2, 0 );
+ OSL_ASSERT( makeAny( aInt64 ) >>= a3.nInt64 );
+ sal_getInt64( a3.nInt64, &lowInt, &highInt );
+ OSL_ASSERT( lowInt == 2 );
+ OSL_ASSERT( (makeAny( (sal_Int32)2) >>= a3.nInt32) && a3.nInt32 == 2 );
+ sal_uInt64 auInt64;
+ sal_uInt32 uhighInt;
+ sal_setUInt64( &auInt64, 2, 0 );
+ OSL_ASSERT( makeAny( auInt64 ) >>= a3.nuInt64 );
+ sal_getUInt64( a3.nuInt64, &lowInt, &uhighInt );
+ OSL_ASSERT( lowInt == 2 );
+ OSL_ASSERT( (makeAny( (sal_uInt32)2) >>= a3.nuInt32) && a3.nuInt32 == 2 );
+ OSL_ASSERT( (makeAny( TypeClass_STRUCT) >>= a3.eType) && a3.eType == TypeClass_STRUCT );
+ //OSL_ASSERT( (makeAny( L'2' ) >>= a3.wChar) && a3.nInt8 ==L'2';
+ OSL_ASSERT( (makeAny( (sal_Int16)2) >>= a3.td.nInt16) && a3.nInt16 == 2 );
+ OSL_ASSERT( (makeAny( (double)2) >>= a3.td.dDouble) && a3.nDouble == 2 );
+ //OSL_ASSERT( (makeAny( (sal_True)2) >>= a3.bBool) && a3.nInt8 ==sal_True;
+
+ // Only one negative test, the implementation has only one if to test this
+ OSL_ASSERT( (makeAny( (float)2) >>= a3.nFloat) && a3.nFloat ==(float)2 );
+ }
+
+ {
+ // test: Sequence
+ Sequence< Test1 > aTestSeq;
+ OSL_ASSERT( aTestSeq.getLength() == 0 );
+ sal_Int32 szInt32[2] = { 1, 2 };
+ Sequence< sal_Int32 > aInt32Seq( szInt32, 2 );
+ OSL_ASSERT( aInt32Seq.getLength() == 2 );
+ OSL_ASSERT( aInt32Seq[0] == 1 && aInt32Seq[1] == 2 );
+ OSL_ASSERT( aInt32Seq.getArray()[0] == 1 && aInt32Seq.getArray()[1] == 2 );
+ Sequence< sal_Int32 > aNextInt32Seq( aInt32Seq );
+ OSL_ASSERT( aNextInt32Seq[0] == 1 && aNextInt32Seq[1] == 2 );
+ aInt32Seq[0] = 45;
+ OSL_ASSERT( aInt32Seq[0] == 45 && aInt32Seq[1] == 2 );
+ OSL_ASSERT( aNextInt32Seq[0] == 1 && aNextInt32Seq[1] == 2 );
+ sal_Int32 * pArray = aNextInt32Seq.getArray();
+ OSL_ASSERT( pArray[0] == 1 && pArray[1] == 2 );
+ Sequence< double > aDoubleSeq( 5 );
+ OSL_ASSERT( aDoubleSeq[4] == 0.0 );
+ Sequence< OUString > aStringSeq( 5 );
+ OSL_ASSERT( aStringSeq[4] == OUString() );
+ }
+ sal_Int32 szInt32[2] = { 1, 2 };
+ Sequence<sal_Int32 > aInt32Seq( szInt32, 2 );
+ Sequence<sal_Int32 > aNextInt32Seq( aInt32Seq );
+ aNextInt32Seq.realloc( 1 ); // split of sequence
+ const sal_Int32 * pArray = aNextInt32Seq.getConstArray();
+ OSL_ASSERT( pArray[0] == 1 );
+ aInt32Seq.realloc( 1 ); // reallocate mem
+ pArray = aInt32Seq.getConstArray();
+ OSL_ASSERT( pArray[0] == 1 );
+}
+
+class TestInterface : public XInterface
+{
+public:
+ // XInterface
+ void SAL_CALL acquire() { osl_incrementInterlockedCount( &nRefCount ); }
+ void SAL_CALL release()
+ {
+ if( !osl_decrementInterlockedCount( &nRefCount ) )
+ delete this;
+ }
+ Any SAL_CALL queryInterface( const Type & rType )
+ {
+ return cppu::queryInterface( rType, static_cast< XInterface* >( this ) );
+ }
+
+ TestInterface() : nRefCount( 0 ) {}
+
+ sal_Int32 nRefCount;
+};
+
+struct SimpleInterface : public TestInterface, public XSimpleInterface
+{
+ void SAL_CALL acquire() { TestInterface::acquire(); }
+ void SAL_CALL release() { TestInterface::release(); }
+ Any SAL_CALL queryInterface( const Type & rType )
+ {
+ Any aRet( cppu::queryInterface( rType, static_cast< XSimpleInterface * >( this ) ) );
+ return (aRet.hasValue() ? aRet : TestInterface::queryInterface( rType ));
+ }
+ virtual void SAL_CALL method() throw(::com::sun::star::uno::RuntimeException)
+ {}
+};
+
+static sal_Bool s_aAssignableFromTab[11][11] =
+{
+ /* from CH,BO,BY,SH,US,LO,UL,HY,UH,FL,DO */
+/* TypeClass_CHAR */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_BOOLEAN */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_BYTE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_UNSIGNED_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+/* TypeClass_UNSIGNED_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+/* TypeClass_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
+/* TypeClass_UNSIGNED_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
+/* TypeClass_FLOAT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0 },
+/* TypeClass_DOUBLE */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1 }
+};
+template < class T >
+static void test_assignSimple( const T & rVal, /*const*/ Any /*&*/ rAny )
+{
+ typelib_TypeDescription * pTD = 0;
+ ::getCppuType( &rVal ).getDescription( &pTD );
+ sal_Bool bTable = s_aAssignableFromTab[pTD->eTypeClass-1][rAny.getValueTypeClass()-1];
+ OSL_ASSERT(
+ (bTable!=sal_False) ==
+ (typelib_typedescriptionreference_isAssignableFrom(
+ pTD->pWeakRef, rAny.getValueTypeRef() )!=sal_False) );
+ T t;
+ OSL_ASSERT( (bTable!=sal_False) == ((rAny >>= t)!=sal_False) );
+ if (bTable)
+ OSL_ASSERT( t == rVal );
+ typelib_typedescription_release( pTD );
+}
+template < class T >
+static void test_simple_assignment( const T & rVal )
+{
+ // bool
+ sal_Bool tr = sal_True;
+ typelib_TypeDescription * pBoolTD = 0;
+ ::getCppuBooleanType().getDescription( &pBoolTD );
+ Any a( &tr, pBoolTD );
+ test_assignSimple( rVal, a );
+ OSL_ASSERT( typelib_typedescriptionreference_isAssignableFrom( pBoolTD->pWeakRef, a.getValueTypeRef() ) );
+ typelib_typedescription_release( pBoolTD );
+ OSL_ASSERT( *(sal_Bool *)a.getValue() );
+ // char
+ sal_Unicode ch = 'a';
+ typelib_TypeDescription * pCharTD = 0;
+ ::getCppuCharType().getDescription( &pCharTD );
+ a.setValue( &ch, pCharTD );
+ test_assignSimple( rVal, a );
+ OSL_ASSERT( typelib_typedescriptionreference_isAssignableFrom( pCharTD->pWeakRef, a.getValueTypeRef() ) );
+ typelib_typedescription_release( pCharTD );
+ OSL_ASSERT( *(sal_Unicode *)a.getValue() == 'a' );
+
+ // rest by template
+ a <<= (sal_Int8)5;
+ test_assignSimple( rVal, a );
+ a <<= (sal_Int16)5;
+ test_assignSimple( rVal, a );
+ a <<= (sal_uInt16)5;
+ test_assignSimple( rVal, a );
+ a <<= (sal_Int32)5;
+ test_assignSimple( rVal, a );
+ a <<= (sal_uInt32)5;
+ test_assignSimple( rVal, a );
+ a <<= (sal_Int64)5;
+ test_assignSimple( rVal, a );
+ a <<= (sal_uInt64)5;
+ test_assignSimple( rVal, a );
+ a <<= (float)5;
+ test_assignSimple( rVal, a );
+ a <<= (double)5;
+ test_assignSimple( rVal, a );
+}
+static void testAssignment()
+{
+ // simple types
+ test_simple_assignment( (sal_Int8)5 );
+ test_simple_assignment( (sal_Int16)5 );
+ test_simple_assignment( (sal_uInt16)5 );
+ test_simple_assignment( (sal_Int32)5 );
+ test_simple_assignment( (sal_uInt32)5 );
+ test_simple_assignment( (sal_Int64)5 );
+ test_simple_assignment( (sal_uInt64)5 );
+ test_simple_assignment( (float)5 );
+ test_simple_assignment( (double)5 );
+ // some complex things
+ Any a;
+ TestSimple ts;
+ TestElement te; // derived from simple
+ a <<= ts;
+ OSL_ASSERT( !(a >>= te) );
+ OSL_ASSERT( a >>= ts );
+ a <<= te;
+ OSL_ASSERT( (a >>= te) && (a >>= ts) );
+ // interface
+ Reference< XSimpleInterface > xOriginal( new SimpleInterface() );
+ a <<= xOriginal;
+ Reference< XInterface > x;
+ OSL_ASSERT( (a >>= x) && (a == xOriginal) && (xOriginal == x) && (x == xOriginal) );
+ // sequence
+ Sequence< TestElement > aSeq( 5 );
+ Sequence< TestElement > aSeq2( 3 );
+ aSeq[1].Byte = 17;
+ a <<= aSeq;
+ OSL_ASSERT( a >>= aSeq2 );
+ OSL_ASSERT( aSeq2[1].Byte == 17 );
+ aSeq2[1].Byte = 20;
+ OSL_ASSERT( aSeq != aSeq2 );
+ OSL_ASSERT( a != aSeq2 );
+ a <<= aSeq2;
+ OSL_ASSERT( a >>= aSeq );
+ OSL_ASSERT( a == aSeq );
+ OSL_ASSERT( !(a != aSeq) );
+ OSL_ASSERT( aSeq == aSeq2 );
+ OSL_ASSERT( aSeq[1].Byte == 20 );
+}
+
+void test_interface()
+{
+ {
+ // test: Interface
+ Reference< XInterface > xIFace;
+ OSL_ASSERT( !xIFace.is() );
+ xIFace.clear(); // do nothing
+ }
+}
+
+void test_inheritance()
+{
+ OSL_ASSERT( sizeof( Base ) == getSize( getCppuType( (Base *)0).getTypeLibType() ) );
+ OSL_ASSERT( sizeof( Base1 ) == getSize( getCppuType( (Base1 *)0).getTypeLibType() ) );
+ OSL_ASSERT( sizeof( Base2 ) == getSize( getCppuType( (Base2 *)0).getTypeLibType() ) );
+}
+
+sal_Int32 nCallback_1;
+sal_Int32 nCallback;
+void SAL_CALL typedescription_Callback_1
+(
+ void * pContext,
+ typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName
+)
+{
+ OSL_ENSHURE( pContext == (void *)1, "### unexpected context!" );
+ if( *ppRet )
+ {
+ typelib_typedescription_release( *ppRet );
+ *ppRet = 0;
+ }
+
+ OUString aTypeName( pTypeName );
+ if( -1 != aTypeName.indexOf( OUString::createFromAscii("1_") ) )
+ {
+ nCallback_1++;
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM("unsigned short") );
+ OUString empty;
+ typelib_CompoundMember_Init aMember = { typelib_TypeClass_UNSIGNED_SHORT,
+ aName.pData,
+ empty.pData };
+ typelib_typedescription_new(
+ ppRet,
+ typelib_TypeClass_STRUCT, pTypeName, 0,
+ 1,
+ &aMember
+ );
+ }
+}
+
+void SAL_CALL typedescription_Callback
+(
+ void * pContext,
+ typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName
+)
+{
+ OSL_ENSHURE( pContext == (void *)0, "### unexpected context!" );
+ if( *ppRet )
+ {
+ typelib_typedescription_release( *ppRet );
+ *ppRet = 0;
+ }
+
+ OUString aTypeName( pTypeName );
+ if( -1 != aTypeName.indexOf( OUString::createFromAscii("cachetest") ) )
+ {
+ nCallback++;
+ aTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("1_") ) + aTypeName;
+ OUString empty;
+ typelib_CompoundMember_Init aMember = { typelib_TypeClass_STRUCT,
+ aTypeName.pData,
+ empty.pData };
+ typelib_typedescription_new(
+ ppRet,
+ typelib_TypeClass_STRUCT, pTypeName, 0,
+ 1,
+ &aMember
+ );
+ }
+}
+
+void test_cache()
+{
+ typelib_typedescription_registerCallback( (void *)1, typedescription_Callback_1 );
+ typelib_typedescription_registerCallback( 0, typedescription_Callback );
+
+ for( sal_Int32 i = 0; i < 300; i++ )
+ {
+ typelib_TypeDescription * pTD = 0;
+ OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("cachetest") );
+ aTypeName = aTypeName + OUString::valueOf( i );
+ typelib_typedescription_getByName( &pTD, aTypeName.pData );
+ typelib_typedescription_release( pTD );
+ }
+ OSL_ASSERT( nCallback_1 == 300 );
+ OSL_ASSERT( nCallback == 300 );
+ // The cache size is 200 so the description "cachetest200" is in the cache
+ typelib_TypeDescription * pTD = 0;
+ OUString aName200( RTL_CONSTASCII_USTRINGPARAM("cachetest200") );
+ typelib_typedescription_getByName( &pTD, aName200.pData );
+ OSL_ASSERT( nCallback_1 == 300 );
+ OSL_ASSERT( nCallback == 300 );
+ // The cache size is 200 so the description "cachetest199" is not in the cache
+ // "1_cachetest199" is loaded too.
+ OUString aName199( RTL_CONSTASCII_USTRINGPARAM("cachetest199") );
+ typelib_typedescription_getByName( &pTD, aName199.pData );
+ typelib_typedescription_release( pTD );
+ OSL_ASSERT( nCallback_1 == 301 );
+ OSL_ASSERT( nCallback == 301 );
+
+ typelib_typedescription_revokeCallback( (void *)1, typedescription_Callback_1 );
+ typelib_typedescription_revokeCallback( 0, typedescription_Callback );
+}
+
+static OUString s_aAddPurpose;
+
+static void SAL_CALL getMappingCallback(
+ uno_Mapping ** ppMapping,
+ uno_Environment * pFrom, uno_Environment * pTo, rtl_uString * pAddPurpose )
+{
+ s_aAddPurpose = pAddPurpose;
+}
+static void testMappingCallback()
+{
+ uno_registerMappingCallback( getMappingCallback );
+ OSL_ASSERT( ! s_aAddPurpose.getLength() );
+ Mapping aTest(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("test") ) );
+ uno_revokeMappingCallback( getMappingCallback );
+ OSL_ASSERT( s_aAddPurpose.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("test") ) );
+ s_aAddPurpose = OUString();
+ Mapping aTest2(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("test") ) );
+ OSL_ASSERT( ! s_aAddPurpose.getLength() );
+}
+
+static void testEnvironment(void)
+{
+ uno_Environment * pEnv = 0;
+ void ** ppInterfaces = 0;
+ sal_Int32 nLen;
+
+ OUString aUnoEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) );
+ uno_getEnvironment( &pEnv, aUnoEnvTypeName.pData, 0 );
+ (*pEnv->pExtEnv->getRegisteredInterfaces)( pEnv->pExtEnv, &ppInterfaces, &nLen, rtl_allocateMemory );
+ while (nLen--)
+ {
+ uno_Interface * pUnoI = (uno_Interface *)ppInterfaces[nLen];
+ (*pUnoI->release)( pUnoI );
+ }
+ rtl_freeMemory( ppInterfaces );
+
+ OUString aCppEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ uno_getEnvironment( &pEnv, aCppEnvTypeName.pData, 0 );
+ (*pEnv->pExtEnv->getRegisteredInterfaces)( pEnv->pExtEnv, &ppInterfaces, &nLen, rtl_allocateMemory );
+ while (nLen--)
+ {
+ uno_Interface * pUnoI = (uno_Interface *)ppInterfaces[nLen];
+ (*pUnoI->release)( pUnoI );
+ }
+ rtl_freeMemory( ppInterfaces );
+ (*pEnv->release)( pEnv );
+}
+
+#ifdef SOLARIS
+extern "C" void ChangeGlobalInit();
+#endif
+
+/*
+ * main.
+ */
+int SAL_CALL main(int argc, char **argv)
+{
+#ifdef SOLARIS
+ ChangeGlobalInit();
+#endif
+ typelib_setCacheSize( 200 );
+#ifdef SAL_W32
+ Reference< XMultiServiceFactory > xMgr( cppu::createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("testcppu.rdb") ) ) );
+#endif
+ testEnvironment();
+ testMappingCallback();
+
+ // perform test
+ void test_di(void);
+ test_di();
+ void test_performance(void);
+ testAssignment();
+ testCppu();
+// test_cache(); // cache test not possible if types are loaded dynamically...
+ test_interface();
+ test_inheritance();
+
+ // shutdown
+#ifdef SAL_W32
+ Reference< XComponent > xComp( xMgr, UNO_QUERY );
+ OSL_ENSHURE( xComp.is(), "### serivce manager has to implement XComponent!" );
+ xComp->dispose();
+ xMgr.clear();
+#endif
+ typelib_setCacheSize( 0 );
+ testEnvironment();
+
+ return 0;
+}
diff --git a/cppu/test/testthreadpool.cxx b/cppu/test/testthreadpool.cxx
new file mode 100644
index 000000000000..2f2f84499599
--- /dev/null
+++ b/cppu/test/testthreadpool.cxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * $RCSfile: testthreadpool.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <osl/diagnose.h>
+
+#include <rtl/uuid.h>
+
+#include <uno/threadpool.h>
+
+#include <vos/thread.hxx>
+
+#define TEST_ENSURE OSL_ENSHURE
+
+using namespace ::vos;
+
+
+class OThread1 : public OThread
+{
+public:
+ OThread1( sal_uInt8 *pCallerUuid );
+ virtual void run();
+
+public:
+ sal_uInt8 *m_pCallerUuid;
+ sal_Int8 *m_pThreadIdentifier;
+ sal_Int32 m_nThreadIdentifierLength;
+
+ void *m_pThreadData;
+};
+
+OThread1::OThread1( sal_uInt8 *pCallerUuid ) :
+ m_pCallerUuid( pCallerUuid ),
+ m_pThreadData( (void*) 1 ),
+ m_pThreadIdentifier( 0 ),
+ m_nThreadIdentifierLength( 0 )
+{
+
+}
+
+void OThread1::run()
+{
+
+ uno_threadpool_Ticket *pTicket = uno_threadpool_createTicket( m_pCallerUuid );
+
+ uno_threadIdent_retrieve( &m_pThreadIdentifier , &m_nThreadIdentifierLength );
+
+ uno_threadpool_waitOnTicket( pTicket , &m_pThreadData );
+
+ uno_threadIdent_revoke();
+}
+
+
+void SAL_CALL doIt( void *pThreadData )
+{
+ *( sal_Int32 *) pThreadData = 2;
+}
+
+void testthreadpool()
+{
+ printf( "Testing threadpool ..." );
+ fflush( stdout );
+
+ sal_uInt8 pCallerUuid1[16];
+ sal_uInt8 pCallerUuid2[16];
+ rtl_createUuid( pCallerUuid1, 0 , sal_True );
+ rtl_createUuid( pCallerUuid2, 0 , sal_True );
+
+ //------------
+ // Test reply
+ //------------
+ {
+ OThread1 thread1( pCallerUuid1 );
+
+ thread1.create();
+
+ // do a busy wait
+ while( ! thread1.m_pThreadIdentifier && ! thread1.m_nThreadIdentifierLength );
+
+ void *pThreadData = (void*)0xdeadbabe;
+ uno_threadpool_reply( thread1.m_pThreadIdentifier ,
+ thread1.m_nThreadIdentifierLength,
+ pThreadData );
+
+ // do a busy wait
+ while( (void*)1 == thread1.m_pThreadData );
+
+ TEST_ENSURE( pThreadData == thread1.m_pThreadData, "uno_threadpool_reply error" );
+ }
+
+ //---------------
+ // Test request
+ //---------------
+ {
+ OThread1 thread1( pCallerUuid1 );
+
+ thread1.create();
+
+ // do a busy wait
+ while( ! thread1.m_pThreadIdentifier && ! thread1.m_nThreadIdentifierLength );
+
+ // do a request
+ sal_Int32 i = 1;
+ uno_threadpool_request( thread1.m_pThreadIdentifier ,
+ thread1.m_nThreadIdentifierLength,
+ &i,
+ doIt,
+ sal_False);
+
+ // do a busy wait
+ while( 1 == i );
+ TEST_ENSURE( 2 == i, "uno_threadpool_request error" );
+
+ // get it out of the pool
+ void *pThreadData = (void*)0xdeadbabe;
+ uno_threadpool_reply( thread1.m_pThreadIdentifier ,
+ thread1.m_nThreadIdentifierLength,
+ pThreadData );
+
+ // do a busy wait
+ while( pThreadData != thread1.m_pThreadData );
+
+ }
+
+ //---------------
+ // Test dispose threads
+ //---------------
+ {
+ OThread1 thread1( pCallerUuid1 );
+ OThread1 thread2( pCallerUuid2 );
+
+ thread1.create();
+ thread2.create();
+
+ // do a busy wait
+ while( ! thread1.m_pThreadIdentifier && ! thread1.m_nThreadIdentifierLength &&
+ ! thread2.m_pThreadIdentifier && ! thread2.m_nThreadIdentifierLength );
+
+ // dispose the first
+ uno_threadpool_disposeThreads( pCallerUuid1 );
+
+ while( (void*)1 == thread1.m_pThreadData );
+ TEST_ENSURE( (void*)0 == thread1.m_pThreadData, "disposing threads failed" );
+
+ TimeValue value = {1,0};
+ osl_waitThread( &value );
+ TEST_ENSURE( (void*)1 == thread2.m_pThreadData, "wrong thread disposed !" );
+
+ // test, if new threads are directly disposed
+ OThread1 thread3( pCallerUuid1 );
+ thread3.create();
+
+ while( (void*)1 == thread3.m_pThreadData );
+ TEST_ENSURE( (void*)0 == thread3.m_pThreadData ,
+ "new threads entering threadpool are not disposed" );
+
+ uno_threadpool_reply( thread2.m_pThreadIdentifier ,
+ thread2.m_nThreadIdentifierLength,
+ (void*)0x2 );
+
+ while( (void*)1 == thread2.m_pThreadData );
+ TEST_ENSURE( (void*)2 == thread2.m_pThreadData , "reply does not work correctly" );
+
+ uno_threadpool_stopDisposeThreads( pCallerUuid1 );
+ }
+ printf( "Done\n" );
+}
diff --git a/cppu/util/makefile.mk b/cppu/util/makefile.mk
new file mode 100644
index 000000000000..027f1ed04401
--- /dev/null
+++ b/cppu/util/makefile.mk
@@ -0,0 +1,120 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:54 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=cppu
+TARGET=cppu
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+.INCLUDE : ..$/version.mk
+
+# --- Files --------------------------------------------------------
+
+SHL1LIBS= \
+ $(SLB)$/cppu_typelib.lib \
+ $(SLB)$/cppu_uno.lib \
+ $(SLB)$/cppu_threadpool.lib
+
+SHL1TARGET= $(CPPU_TARGET)$(CPPU_MAJOR)
+
+SHL1STDLIBS= $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+DOCPPFILES= \
+ $(INC)$/typelib$/uik.h \
+ $(INC)$/typelib$/typeclass.h \
+ $(INC)$/typelib$/typedescription.h \
+ $(INC)$/typelib$/typedescription.hxx \
+ $(INC)$/uno$/any2.h \
+ $(INC)$/uno$/sequence2.h \
+ $(INC)$/uno$/data.h \
+ $(INC)$/uno$/environment.h \
+ $(INC)$/uno$/environment.hxx \
+ $(INC)$/uno$/mapping.h \
+ $(INC)$/uno$/mapping.hxx \
+ $(INC)$/uno$/dispatcher.h \
+ $(INC)$/uno$/threadpool.h \
+ $(INC)$/com$/sun$/star$/uno$/genfunc.h \
+ $(INC)$/com$/sun$/star$/uno$/Reference.h\
+ $(INC)$/com$/sun$/star$/uno$/Type.h \
+ $(INC)$/com$/sun$/star$/uno$/Any.h \
+ $(INC)$/com$/sun$/star$/uno$/Sequence.h
+
+docpp: $(DOCPPFILES)
+ +doc++ -H -m -f -u -d $(OUT)$/doc$/$(PRJNAME) $(DOCPPFILES)
diff --git a/cppu/util/makefile.pmk b/cppu/util/makefile.pmk
new file mode 100644
index 000000000000..a6963ff4dc68
--- /dev/null
+++ b/cppu/util/makefile.pmk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.pmk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:54 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
diff --git a/cppu/util/target.pmk b/cppu/util/target.pmk
new file mode 100644
index 000000000000..78aa9757958f
--- /dev/null
+++ b/cppu/util/target.pmk
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# $RCSfile: target.pmk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:54 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+.IF "$(debug)" == ""
+
+# switch on aggressive opt
+
+# msvc++
+.IF "$(COM)" == "MSC"
+CFLAGS += /O2gityb2 /Gs
+.ENDIF
+
+# sunpro 5
+.IF "$(COM)" == "C50"
+CFLAGS += -O5 -xO5
+.ENDIF
+
+# gcc
+.IF "$(COM)" == "GCC"
+CFLAGS += -O
+.ENDIF
+
+.ELSE
+
+# msvc++: no inlining
+.IF "$(COM)" == "MSC"
+CFLAGS += /Ob0
+.ENDIF
+
+.IF "$(cppu_assert)" != ""
+CFLAGS += -DCPPU_ASSERTIONS
+.ENDIF
+
+.ENDIF
+
+.IF "$(cppu_no_leak)" == ""
+CFLAGS += -DCPPU_LEAK_STATIC_DATA
+.ENDIF
diff --git a/cppuhelper/inc/cppuhelper/compbase.hxx b/cppuhelper/inc/cppuhelper/compbase.hxx
new file mode 100644
index 000000000000..7e3522e1097f
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase.hxx
@@ -0,0 +1,249 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#define _CPPUHELPER_COMPBASE_HXX_
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+
+//==================================================================================================
+#define __DEF_COMPIMPLHELPER_A( N ) \
+namespace cppu \
+{ \
+template< __CLASS_IFC##N > \
+class WeakComponentImplHelper##N \
+ : public ::cppu::OWeakObject \
+ , public ::com::sun::star::lang::XComponent \
+ , public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+protected: \
+ ::cppu::OBroadcastHelper rBHelper; \
+ virtual void SAL_CALL disposing() \
+ {} \
+public: \
+ WeakComponentImplHelper##N( ::osl::Mutex & rMutex ) \
+ : rBHelper( rMutex ) \
+ {} \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
+ if (aRet.hasValue()) \
+ return aRet; \
+ if (rType == ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > *)0 )) \
+ { \
+ void * p = static_cast< ::com::sun::star::lang::XComponent * >( this ); \
+ return ::com::sun::star::uno::Any( &p, rType ); \
+ } \
+ return OWeakObject::queryInterface( rType ); \
+ } \
+ virtual void SAL_CALL acquire() throw() \
+ { OWeakObject::acquire(); } \
+ virtual void SAL_CALL release() throw() \
+ { \
+ if (1 == m_refCount && !rBHelper.bDisposed) \
+ { \
+ dispose(); \
+ } \
+ OWeakObject::release(); \
+ } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getImplementationId(); } \
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::osl::ClearableMutexGuard aGuard( rBHelper.rMutex ); \
+ if (!rBHelper.bDisposed && !rBHelper.bInDispose) \
+ { \
+ rBHelper.bInDispose = sal_True; \
+ aGuard.clear(); \
+ ::com::sun::star::lang::EventObject aEvt( static_cast< ::cppu::OWeakObject * >( this ) ); \
+ rBHelper.aLC.disposeAndClear( aEvt ); \
+ disposing(); \
+ rBHelper.bDisposed = sal_True; \
+ rBHelper.bInDispose = sal_False; \
+ } \
+ } \
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::osl::MutexGuard aGuard( rBHelper.rMutex ); \
+ OSL_ENSHURE( !rBHelper.bInDispose, "do not add listeners in the dispose call" ); \
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" ); \
+ if (!rBHelper.bInDispose && !rBHelper.bDisposed) \
+ rBHelper.aLC.addInterface( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > *)0 ), xListener ); \
+ } \
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::osl::MutexGuard aGuard( rBHelper.rMutex ); \
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" ); \
+ if (!rBHelper.bInDispose && !rBHelper.bDisposed) \
+ rBHelper.aLC.removeInterface( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > *)0 ), xListener ); \
+ } \
+}; \
+template< __CLASS_IFC##N > \
+class WeakAggComponentImplHelper##N \
+ : public ::cppu::OWeakAggObject \
+ , public ::com::sun::star::lang::XComponent \
+ , public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+protected: \
+ ::cppu::OBroadcastHelper rBHelper; \
+ virtual void SAL_CALL disposing() \
+ {} \
+public: \
+ WeakAggComponentImplHelper##N( ::osl::Mutex & rMutex ) \
+ : rBHelper( rMutex ) \
+ {} \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) \
+ { return OWeakAggObject::queryInterface( rType ); } \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
+ if (aRet.hasValue()) \
+ return aRet; \
+ if (rType == ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > *)0 )) \
+ { \
+ void * p = static_cast< ::com::sun::star::lang::XComponent * >( this ); \
+ return ::com::sun::star::uno::Any( &p, rType ); \
+ } \
+ return OWeakAggObject::queryAggregation( rType ); \
+ } \
+ virtual void SAL_CALL acquire() throw() \
+ { OWeakAggObject::acquire(); } \
+ virtual void SAL_CALL release() throw() \
+ { \
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > x( xDelegator ); \
+ if (!x.is() && 1 == m_refCount && !rBHelper.bDisposed) \
+ dispose(); \
+ OWeakAggObject::release(); \
+ } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getImplementationId(); } \
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::osl::ClearableMutexGuard aGuard( rBHelper.rMutex ); \
+ if (!rBHelper.bDisposed && !rBHelper.bInDispose) \
+ { \
+ rBHelper.bInDispose = sal_True; \
+ aGuard.clear(); \
+ ::com::sun::star::lang::EventObject aEvt( static_cast< ::cppu::OWeakObject * >( this ) ); \
+ rBHelper.aLC.disposeAndClear( aEvt ); \
+ disposing(); \
+ rBHelper.bDisposed = sal_True; \
+ rBHelper.bInDispose = sal_False; \
+ } \
+ } \
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::osl::MutexGuard aGuard( rBHelper.rMutex ); \
+ OSL_ENSHURE( !rBHelper.bInDispose, "do not add listeners in the dispose call" ); \
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" ); \
+ if (!rBHelper.bInDispose && !rBHelper.bDisposed) \
+ rBHelper.aLC.addInterface( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > *)0 ), xListener ); \
+ } \
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::osl::MutexGuard aGuard( rBHelper.rMutex ); \
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" ); \
+ if (!rBHelper.bInDispose && !rBHelper.bDisposed) \
+ rBHelper.aLC.removeInterface( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > *)0 ), xListener ); \
+ } \
+};
+
+//==================================================================================================
+#define __DEF_COMPIMPLHELPER_B( N ) \
+template< __CLASS_IFC##N > \
+ClassData##N WeakComponentImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 4 ); \
+template< __CLASS_IFC##N > \
+ClassData##N WeakAggComponentImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 3 );
+//==================================================================================================
+#define __DEF_COMPIMPLHELPER_C( N ) \
+}
+//==================================================================================================
+// The Mac OS X gcc compiler cannot handle assignments to static data members
+// of the generic template class. It can only handle assignments to specific
+// instantiations of a template class.
+#ifdef MACOSX
+#define __DEF_COMPIMPLHELPER( N ) \
+__DEF_COMPIMPLHELPER_A( N ) \
+__DEF_COMPIMPLHELPER_C( N )
+#else /* MACOSX */
+#define __DEF_COMPIMPLHELPER( N ) \
+__DEF_COMPIMPLHELPER_A( N ) \
+__DEF_COMPIMPLHELPER_B( N ) \
+__DEF_COMPIMPLHELPER_C( N )
+#endif /* MACOSX */
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase1.hxx b/cppuhelper/inc/cppuhelper/compbase1.hxx
new file mode 100644
index 000000000000..e50d61b7eb5c
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase1.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase1.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE1_HXX_
+#define _CPPUHELPER_COMPBASE1_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 1 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase10.hxx b/cppuhelper/inc/cppuhelper/compbase10.hxx
new file mode 100644
index 000000000000..bd868f157133
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase10.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase10.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE10_HXX_
+#define _CPPUHELPER_COMPBASE10_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE10_HXX_
+#include <cppuhelper/implbase10.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 10 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase11.hxx b/cppuhelper/inc/cppuhelper/compbase11.hxx
new file mode 100644
index 000000000000..a16e743bdf4a
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase11.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase11.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE11_HXX_
+#define _CPPUHELPER_COMPBASE11_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE11_HXX_
+#include <cppuhelper/implbase11.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 11 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase12.hxx b/cppuhelper/inc/cppuhelper/compbase12.hxx
new file mode 100644
index 000000000000..cb54a6c008fa
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase12.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase12.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE12_HXX_
+#define _CPPUHELPER_COMPBASE12_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE12_HXX_
+#include <cppuhelper/implbase12.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 12 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase2.hxx b/cppuhelper/inc/cppuhelper/compbase2.hxx
new file mode 100644
index 000000000000..ff5d0d7af786
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase2.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase2.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE2_HXX_
+#define _CPPUHELPER_COMPBASE2_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 2 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase3.hxx b/cppuhelper/inc/cppuhelper/compbase3.hxx
new file mode 100644
index 000000000000..d74519250cf7
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase3.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase3.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE3_HXX_
+#define _CPPUHELPER_COMPBASE3_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 3 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase4.hxx b/cppuhelper/inc/cppuhelper/compbase4.hxx
new file mode 100644
index 000000000000..3639e183b87d
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase4.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase4.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE4_HXX_
+#define _CPPUHELPER_COMPBASE4_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#include <cppuhelper/implbase4.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 4 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase5.hxx b/cppuhelper/inc/cppuhelper/compbase5.hxx
new file mode 100644
index 000000000000..47ce9b31e2a4
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase5.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase5.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE5_HXX_
+#define _CPPUHELPER_COMPBASE5_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 5 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase6.hxx b/cppuhelper/inc/cppuhelper/compbase6.hxx
new file mode 100644
index 000000000000..9d5931064592
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase6.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase6.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE6_HXX_
+#define _CPPUHELPER_COMPBASE6_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE6_HXX_
+#include <cppuhelper/implbase6.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 6 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase7.hxx b/cppuhelper/inc/cppuhelper/compbase7.hxx
new file mode 100644
index 000000000000..d7791db9b068
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase7.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase7.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE7_HXX_
+#define _CPPUHELPER_COMPBASE7_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE7_HXX_
+#include <cppuhelper/implbase7.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 7 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase8.hxx b/cppuhelper/inc/cppuhelper/compbase8.hxx
new file mode 100644
index 000000000000..b15675bf0279
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase8.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase8.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE8_HXX_
+#define _CPPUHELPER_COMPBASE8_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE8_HXX_
+#include <cppuhelper/implbase8.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 8 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/compbase9.hxx b/cppuhelper/inc/cppuhelper/compbase9.hxx
new file mode 100644
index 000000000000..8ac9379daf7c
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/compbase9.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: compbase9.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPBASE9_HXX_
+#define _CPPUHELPER_COMPBASE9_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE9_HXX_
+#include <cppuhelper/implbase9.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPBASE_HXX_
+#include <cppuhelper/compbase.hxx>
+#endif
+
+__DEF_COMPIMPLHELPER( 9 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/component.hxx b/cppuhelper/inc/cppuhelper/component.hxx
new file mode 100644
index 000000000000..8689bf126f64
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/component.hxx
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * $RCSfile: component.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#define _CPPUHELPER_COMPONENT_HXX_
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAKAGG_HXX_
+#include <cppuhelper/weakagg.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+
+
+/** */ //for docpp
+namespace cppu
+{
+
+/**
+ * The helper implementation for a basic broadcaster. This implementation
+ * supports aggregation and weak references.
+ *
+ * @author Markus Meyer
+ * @since 98/04/12
+ */
+class OComponentHelper : public ::cppu::WeakAggImplHelper1< ::com::sun::star::lang::XComponent >
+{
+public:
+ /**
+ * Create an object that implements XComponent.
+ *
+ * @param rMutex the mutex used to protect multi thread access.
+ * The lifetime must be longer than the lifetime
+ * of this object.
+ */
+ OComponentHelper( ::osl::Mutex & rMutex );
+ /**
+ * If dispose is not previous called, first acquire is called to protect against
+ * double delete and than call dispose.<BR> Note in this situation no destructor
+ * of derived classes are called.
+ */
+ ~OComponentHelper();
+
+ // XInterface
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider getImplementationId() has to be implemented separately!
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException) = 0;
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
+ throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+ /**
+ * Called in the dispose method after the listeners are notified.
+ * In this situation rBHelper.bDisposed is false
+ * and rBHelper.bDisposing is true.
+ */
+ virtual void SAL_CALL disposing();
+
+ /**
+ * Contains a mutex, a listener container and the dispose states.
+ * Subclasses should only modify the listener container.
+ */
+ OBroadcastHelper rBHelper;
+private:
+ OComponentHelper( const OComponentHelper & );
+ OComponentHelper & operator = ( const OComponentHelper & );
+};
+
+}
+
+#endif
+
diff --git a/cppuhelper/inc/cppuhelper/exc_hlp.hxx b/cppuhelper/inc/cppuhelper/exc_hlp.hxx
new file mode 100644
index 000000000000..6ac1b14c62c8
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/exc_hlp.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * $RCSfile: exc_hlp.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#define _CPPUHELPER_EXC_HLP_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+
+namespace cppu
+{
+
+/**
+ * This function throws the exception given in the Any rExc. The given value has to be of type class
+ * EXCEPTION and must be dervived from or of type com.sun.star.uno.Exception.
+ *<BR>
+ * @param rExc exception to be thrown.
+ */
+void SAL_CALL throwException( const ::com::sun::star::uno::Any & rExc )
+ throw (::com::sun::star::uno::Exception);
+
+}
+
+#endif
+
diff --git a/cppuhelper/inc/cppuhelper/factory.hxx b/cppuhelper/inc/cppuhelper/factory.hxx
new file mode 100644
index 000000000000..44e157f3fe3a
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/factory.hxx
@@ -0,0 +1,272 @@
+/*************************************************************************
+ *
+ * $RCSfile: factory.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#define _CPPUHELPER_FACTORY_HXX_
+
+#ifndef _RTL_STRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+//##################################################################################################
+
+#define COMPONENT_GETENV "component_getImplementationEnvironment"
+#define COMPONENT_GETDESCRIPTION "component_getDescription"
+#define COMPONENT_WRITEINFO "component_writeInfo"
+#define COMPONENT_GETFACTORY "component_getFactory"
+
+typedef struct _uno_Environment uno_Environment;
+
+/***************************************************************************************************
+ * Function to determine the environment of the implementation.
+ * If the environment is NOT session specific (needs no additional context), then this function
+ * should return the environment type name and leave ppEnv (0).
+ *<BR>
+ * @param ppEnvTypeName environment type name; string must be constant
+ * @param ppEnv function returns its environment if the environment is
+ * session specific, i.e. has special context
+ */
+typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv );
+
+/***************************************************************************************************
+ * Optional function to retrieve a component description.
+ *<BR>
+ * @return an XML formatted string containing a short component description
+ */
+typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void);
+
+/***************************************************************************************************
+ * Writes component registry info, at least writing the supported service names.
+ *<BR>
+ * @param pServiceManager a service manager
+ * (the type is XMultiServiceFactory to be used by the environment
+ * returned by component_getImplementationEnvironment)
+ * @param pRegistryKey a registry key
+ * (the type is XRegistryKey to be used by the environment
+ * returned by component_getImplementationEnvironment)
+ * @return true if everything went fine
+ */
+typedef sal_Bool (SAL_CALL * component_writeInfoFunc)(
+ void * pServiceManager, void * pRegistryKey );
+
+/***************************************************************************************************
+ * Retrieves a factory to create component instances.
+ *<BR>
+ * @param pImplName desired implementation name
+ * @param pServiceManager a service manager
+ * (the type is XMultiServiceFactory to be used by the environment
+ * returned by component_getImplementationEnvironment)
+ * @param pRegistryKey a registry key
+ * (the type is XRegistryKey to be used by the environment
+ * returned by component_getImplementationEnvironment)
+ * @return acquired component factory
+ * (the type is XSingleServiceFactory to be used by the environment
+ * returned by component_getImplementationEnvironment)
+ */
+typedef void * (SAL_CALL * component_getFactoryFunc)(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
+
+//##################################################################################################
+
+#define WRITE_COMPONENT_INFO_FUNCTION "writeComponentInfo"
+#define CREATE_COMPONENT_FACTORY_FUNCTION "createComponentFactory"
+
+/** This function pointer describes a function to write needed administrativ information
+ * about a component into the registry.
+ */
+typedef sal_Bool (SAL_CALL * WriteComponentInfoFunc)( uno_Interface * pXKey );
+
+/** This function pointer describes a function to create a factory for one or more components.
+ */
+typedef uno_Interface* (SAL_CALL * CreateComponentFactoryFunc)(
+ const sal_Unicode *, uno_Interface * pXSMgr, uno_Interface * pXKey );
+
+
+/** */ //for docpp
+namespace cppu
+{
+
+/**
+ * The type of the instanciate function used as argument of the create*Fcatory functions.
+ * @see createSingleFactory
+ * @see createOneInstanceFactory
+ */
+typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(SAL_CALL * ComponentInstantiation)
+(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager
+);
+
+/**
+ * Create a single service factory.<BR>
+ * Note: The function pointer ComponentInstantiation points to a function throws Exception.
+ *
+ * @param rServiceManager the service manager used by the implementation.
+ * @param rImplementationName the implementation name. An empty string is possible.
+ * @param ComponentInstantiation the function pointer to create an object.
+ * @param rServiceNames the service supported by the implementation.
+ * @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ * XSingleServiceFactory and XComponent.
+ *
+ * @see createOneInstanceFactory
+ */
+::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createSingleFactory
+(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::rtl::OUString & rImplementationName,
+ ComponentInstantiation pCreateFunction,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames
+);
+
+/**
+ * Create a factory, that wrappes another one.<BR>
+ * This means the methods of the interfaces XServiceProvider, XServiceInfo and
+ * XSingleServiceFactory are forwarded.
+ * <B>It is not possible to put a factory into two service managers!<BR>
+ * The XComponent interface is not supported!</B>
+ *
+ * @param rServiceManager the service manager used by the implementation.
+ * @param xSingleServiceFactory the wrapped service factory.
+ * @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ * XSingleServiceFactory.
+ *
+ * @see createSingleFactory
+ */
+::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createFactoryProxy
+(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > & rFactory
+);
+
+/**
+ * Create a single service factory which hold the instance created. If the
+ * "XSingleServiceFactory::createFactoryWithArguments" method is called with arguments
+ * new objects are created.
+ * Note: The function pointer ComponentInstantiation points to a function throws Exception.
+ *
+ * @param rServiceManager the service manager used by the implementation.
+ * @param rImplementationName the implementation name. An empty string is possible.
+ * @param ComponentInstantiation the function pointer to create an object.
+ * @param rServiceNames the service supported by the implementation.
+ * @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ * XSingleServiceFactory and XComponent.
+ *
+ * @see createSingleFactory
+ */
+::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createOneInstanceFactory
+(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::rtl::OUString & rComponentName,
+ ComponentInstantiation pCreateFunction,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames
+);
+
+/**
+ * Create a single service factory.<BR>
+ * Note: The function pointer ComponentInstantiation points to a function throws Exception.
+ *
+ * @param rServiceManager the service manager used by the implementation.
+ * @param rImplementationName the implementation name. An empty string is possible.
+ * @param ComponentInstantiation the function pointer to create an object.
+ * @param rImplementationKey the registry key of the implementation section.
+ * @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ * XSingleServiceFactory and XComponent.
+ */
+SAL_DLLEXPORT ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createSingleRegistryFactory
+(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::rtl::OUString & rImplementationName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey
+);
+
+/**
+ * Create a single service factory which hold the instance created. If the
+ * "XSingleServiceFactory::createFactoryWithArguments" method is called with arguments
+ * new objects are created.
+ * Note: The function pointer ComponentInstantiation points to a function throws Exception.
+ *
+ * @param rServiceManager the service manager used by the implementation.
+ * @param rImplementationName the implementation name. An empty string is possible.
+ * @param ComponentInstantiation the function pointer to create an object.
+ * @param rImplementationKey the registry key of the implementation section.
+ * @return a factory that support the interfaces XServiceProvider, XServiceInfo
+ * XSingleServiceFactory and XComponent.
+ *
+ * @see createSingleRegistryFactory
+ */
+::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory
+(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
+ const ::rtl::OUString & rComponentName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey
+);
+
+}
+
+#endif
+
diff --git a/cppuhelper/inc/cppuhelper/implbase.hxx b/cppuhelper/inc/cppuhelper/implbase.hxx
new file mode 100644
index 000000000000..3d8696df1ffd
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase.hxx
@@ -0,0 +1,239 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#define _CPPUHELPER_IMPLBASE_HXX_
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAKAGG_HXX_
+#include <cppuhelper/weakagg.hxx>
+#endif
+
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+
+namespace cppu
+{
+
+struct Type_Offset
+{
+ sal_Int32 nOffset;
+ typelib_InterfaceTypeDescription * pTD;
+};
+struct ClassDataBase
+{
+ sal_Bool bOffsetsInit;
+ sal_Int32 nType2Offset;
+
+ sal_Int32 nClassCode;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > * pTypes;
+ ::com::sun::star::uno::Sequence< sal_Int8 > * pId;
+
+ ClassDataBase();
+ ClassDataBase( sal_Int32 nClassCode );
+ ~ClassDataBase();
+};
+struct ClassData : public ClassDataBase
+{
+ Type_Offset arType2Offset[1];
+
+ void SAL_CALL initTypeProvider();
+ void SAL_CALL writeTypeOffset( const ::com::sun::star::uno::Type & rType, sal_Int32 nOffset );
+
+ ::com::sun::star::uno::Any SAL_CALL query(
+ const ::com::sun::star::uno::Type & rType, ::com::sun::star::lang::XTypeProvider * pBase );
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes();
+ ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId();
+};
+
+}
+
+//
+// settle down beavis, here comes the macro template hell :]
+//
+
+//==================================================================================================
+#define __DEF_IMPLHELPER_PRE( N ) \
+namespace cppu \
+{ \
+struct ClassData##N : public ClassDataBase \
+{ \
+ Type_Offset arType2Offset[ N ]; \
+ ClassData##N( sal_Int32 nClassCode ) \
+ : ClassDataBase( nClassCode ) \
+ {} \
+}; \
+template< __CLASS_IFC##N > \
+class ImplHelperBase##N \
+ : public ::com::sun::star::lang::XTypeProvider, __PUBLIC_IFC##N \
+{ \
+protected: \
+ ClassData & SAL_CALL getClassData( ClassDataBase & s_aCD ) \
+ { \
+ ClassData & rCD = * static_cast< ClassData * >( &s_aCD ); \
+ if (! rCD.bOffsetsInit) \
+ { \
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); \
+ if (! rCD.bOffsetsInit) \
+ { \
+ char * pBase = (char *)this;
+//==================================================================================================
+#define __IFC_WRITEOFFSET( N ) \
+ rCD.writeTypeOffset( ::getCppuType( (const ::com::sun::star::uno::Reference< Ifc##N > *)0 ), \
+ (char *)(Ifc##N *)this - pBase );
+//==================================================================================================
+#define __DEF_IMPLHELPER_POST_A( N ) \
+ rCD.bOffsetsInit = sal_True; \
+ } \
+ } \
+ return rCD; \
+ } \
+}; \
+template< __CLASS_IFC##N > \
+class ImplHelper##N \
+ : public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getImplementationId(); } \
+}; \
+template< __CLASS_IFC##N > \
+class WeakImplHelper##N \
+ : public ::cppu::OWeakObject \
+ , public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
+ return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); \
+ } \
+ virtual void SAL_CALL acquire() throw() \
+ { OWeakObject::acquire(); } \
+ virtual void SAL_CALL release() throw() \
+ { OWeakObject::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getImplementationId(); } \
+}; \
+template< __CLASS_IFC##N > \
+class WeakAggImplHelper##N \
+ : public ::cppu::OWeakAggObject \
+ , public ImplHelperBase##N< __IFC##N > \
+{ \
+ static ClassData##N s_aCD; \
+public: \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) \
+ { return OWeakAggObject::queryInterface( rType ); } \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
+ return (aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( rType )); \
+ } \
+ virtual void SAL_CALL acquire() throw() \
+ { OWeakAggObject::acquire(); } \
+ virtual void SAL_CALL release() throw() \
+ { OWeakAggObject::release(); } \
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getTypes(); } \
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
+ { return getClassData( s_aCD ).getImplementationId(); } \
+};
+
+//==================================================================================================
+#define __DEF_IMPLHELPER_POST_B( N ) \
+template< __CLASS_IFC##N > \
+ClassData##N ImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 0 ); \
+template< __CLASS_IFC##N > \
+ClassData##N WeakImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 1 ); \
+template< __CLASS_IFC##N > \
+ClassData##N WeakAggImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 2 );
+//==================================================================================================
+#define __DEF_IMPLHELPER_POST_C( N ) \
+}
+//==================================================================================================
+// The Mac OS X gcc compiler cannot handle assignments to static data members
+// of the generic template class. It can only handle assignments to specific
+// instantiations of a template class.
+#ifdef MACOSX
+#define __DEF_IMPLHELPER_POST( N ) \
+__DEF_IMPLHELPER_POST_A( N ) \
+__DEF_IMPLHELPER_POST_C( N )
+#else /* MACOSX */
+#define __DEF_IMPLHELPER_POST( N ) \
+__DEF_IMPLHELPER_POST_A( N ) \
+__DEF_IMPLHELPER_POST_B( N ) \
+__DEF_IMPLHELPER_POST_C( N )
+#endif /* MACOSX */
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase1.hxx b/cppuhelper/inc/cppuhelper/implbase1.hxx
new file mode 100644
index 000000000000..83601a702a89
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase1.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase1.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#define _CPPUHELPER_IMPLBASE1_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC1 Ifc1
+#define __CLASS_IFC1 class Ifc1
+#define __PUBLIC_IFC1 public Ifc1
+__DEF_IMPLHELPER_PRE( 1 )
+ __IFC_WRITEOFFSET( 1 )
+__DEF_IMPLHELPER_POST( 1 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase10.hxx b/cppuhelper/inc/cppuhelper/implbase10.hxx
new file mode 100644
index 000000000000..567153e4da27
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase10.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase10.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE10_HXX_
+#define _CPPUHELPER_IMPLBASE10_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC10 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10
+#define __CLASS_IFC10 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10
+#define __PUBLIC_IFC10 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10
+__DEF_IMPLHELPER_PRE( 10 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ) __IFC_WRITEOFFSET( 4 )
+ __IFC_WRITEOFFSET( 5 ) __IFC_WRITEOFFSET( 6 ) __IFC_WRITEOFFSET( 7 ) __IFC_WRITEOFFSET( 8 )
+ __IFC_WRITEOFFSET( 9 ) __IFC_WRITEOFFSET( 10 )
+__DEF_IMPLHELPER_POST( 10 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase11.hxx b/cppuhelper/inc/cppuhelper/implbase11.hxx
new file mode 100644
index 000000000000..7524160f6912
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase11.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase11.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE11_HXX_
+#define _CPPUHELPER_IMPLBASE11_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC11 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11
+#define __CLASS_IFC11 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11
+#define __PUBLIC_IFC11 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11
+__DEF_IMPLHELPER_PRE( 11 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ) __IFC_WRITEOFFSET( 4 )
+ __IFC_WRITEOFFSET( 5 ) __IFC_WRITEOFFSET( 6 ) __IFC_WRITEOFFSET( 7 ) __IFC_WRITEOFFSET( 8 )
+ __IFC_WRITEOFFSET( 9 ) __IFC_WRITEOFFSET( 10 ) __IFC_WRITEOFFSET( 11 )
+__DEF_IMPLHELPER_POST( 11 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase12.hxx b/cppuhelper/inc/cppuhelper/implbase12.hxx
new file mode 100644
index 000000000000..703cdbae1147
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase12.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase12.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE12_HXX_
+#define _CPPUHELPER_IMPLBASE12_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC12 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12
+#define __CLASS_IFC12 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12
+#define __PUBLIC_IFC12 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12
+__DEF_IMPLHELPER_PRE( 12 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ) __IFC_WRITEOFFSET( 4 )
+ __IFC_WRITEOFFSET( 5 ) __IFC_WRITEOFFSET( 6 ) __IFC_WRITEOFFSET( 7 ) __IFC_WRITEOFFSET( 8 )
+ __IFC_WRITEOFFSET( 9 ) __IFC_WRITEOFFSET( 10 ) __IFC_WRITEOFFSET( 11 ) __IFC_WRITEOFFSET( 12 )
+__DEF_IMPLHELPER_POST( 12 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase2.hxx b/cppuhelper/inc/cppuhelper/implbase2.hxx
new file mode 100644
index 000000000000..a88647073d36
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase2.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase2.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#define _CPPUHELPER_IMPLBASE2_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC2 Ifc1, Ifc2
+#define __CLASS_IFC2 class Ifc1, class Ifc2
+#define __PUBLIC_IFC2 public Ifc1, public Ifc2
+__DEF_IMPLHELPER_PRE( 2 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 )
+__DEF_IMPLHELPER_POST( 2 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase3.hxx b/cppuhelper/inc/cppuhelper/implbase3.hxx
new file mode 100644
index 000000000000..aeeed371786d
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase3.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase3.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#define _CPPUHELPER_IMPLBASE3_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC3 Ifc1, Ifc2, Ifc3
+#define __CLASS_IFC3 class Ifc1, class Ifc2, class Ifc3
+#define __PUBLIC_IFC3 public Ifc1, public Ifc2, public Ifc3
+__DEF_IMPLHELPER_PRE( 3 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 )
+__DEF_IMPLHELPER_POST( 3 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase4.hxx b/cppuhelper/inc/cppuhelper/implbase4.hxx
new file mode 100644
index 000000000000..47da75657c7b
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase4.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase4.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#define _CPPUHELPER_IMPLBASE4_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC4 Ifc1, Ifc2, Ifc3, Ifc4
+#define __CLASS_IFC4 class Ifc1, class Ifc2, class Ifc3, class Ifc4
+#define __PUBLIC_IFC4 public Ifc1, public Ifc2, public Ifc3, public Ifc4
+__DEF_IMPLHELPER_PRE( 4 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ) __IFC_WRITEOFFSET( 4 )
+__DEF_IMPLHELPER_POST( 4 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase5.hxx b/cppuhelper/inc/cppuhelper/implbase5.hxx
new file mode 100644
index 000000000000..7310f5c56bd2
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase5.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase5.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#define _CPPUHELPER_IMPLBASE5_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC5 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5
+#define __CLASS_IFC5 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5
+#define __PUBLIC_IFC5 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
+__DEF_IMPLHELPER_PRE( 5 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ) __IFC_WRITEOFFSET( 4 )
+ __IFC_WRITEOFFSET( 5 )
+__DEF_IMPLHELPER_POST( 5 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase6.hxx b/cppuhelper/inc/cppuhelper/implbase6.hxx
new file mode 100644
index 000000000000..4ca1605d0372
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase6.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase6.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE6_HXX_
+#define _CPPUHELPER_IMPLBASE6_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC6 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6
+#define __CLASS_IFC6 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6
+#define __PUBLIC_IFC6 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6
+__DEF_IMPLHELPER_PRE( 6 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ) __IFC_WRITEOFFSET( 4 )
+ __IFC_WRITEOFFSET( 5 ) __IFC_WRITEOFFSET( 6 )
+__DEF_IMPLHELPER_POST( 6 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase7.hxx b/cppuhelper/inc/cppuhelper/implbase7.hxx
new file mode 100644
index 000000000000..3192c6adeb3b
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase7.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase7.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE7_HXX_
+#define _CPPUHELPER_IMPLBASE7_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC7 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7
+#define __CLASS_IFC7 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7
+#define __PUBLIC_IFC7 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7
+__DEF_IMPLHELPER_PRE( 7 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ) __IFC_WRITEOFFSET( 4 )
+ __IFC_WRITEOFFSET( 5 ) __IFC_WRITEOFFSET( 6 ) __IFC_WRITEOFFSET( 7 )
+__DEF_IMPLHELPER_POST( 7 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase8.hxx b/cppuhelper/inc/cppuhelper/implbase8.hxx
new file mode 100644
index 000000000000..174bff44675f
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase8.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase8.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE8_HXX_
+#define _CPPUHELPER_IMPLBASE8_HXX_
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC8 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8
+#define __CLASS_IFC8 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8
+#define __PUBLIC_IFC8 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8
+__DEF_IMPLHELPER_PRE( 8 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ) __IFC_WRITEOFFSET( 4 )
+ __IFC_WRITEOFFSET( 5 ) __IFC_WRITEOFFSET( 6 ) __IFC_WRITEOFFSET( 7 ) __IFC_WRITEOFFSET( 8 )
+__DEF_IMPLHELPER_POST( 8 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/implbase9.hxx b/cppuhelper/inc/cppuhelper/implbase9.hxx
new file mode 100644
index 000000000000..3c8bde78aca4
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/implbase9.hxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase9.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_IMPLBASE9_HXX_
+#define _CPPUHELPER_IMPLBASE9_HXX_
+
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#define __IFC9 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9
+#define __CLASS_IFC9 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9
+#define __PUBLIC_IFC9 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9
+__DEF_IMPLHELPER_PRE( 9 )
+ __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ) __IFC_WRITEOFFSET( 4 )
+ __IFC_WRITEOFFSET( 5 ) __IFC_WRITEOFFSET( 6 ) __IFC_WRITEOFFSET( 7 ) __IFC_WRITEOFFSET( 8 )
+ __IFC_WRITEOFFSET( 9 )
+__DEF_IMPLHELPER_POST( 9 )
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/interfacecontainer.h b/cppuhelper/inc/cppuhelper/interfacecontainer.h
new file mode 100644
index 000000000000..cfaaa8784350
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/interfacecontainer.h
@@ -0,0 +1,376 @@
+/*************************************************************************
+ *
+ * $RCSfile: interfacecontainer.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_INTERFACECONTAINER_H_
+#define _CPPUHELPER_INTERFACECONTAINER_H_
+
+#include <stl/hash_map>
+#include <stl/functional>
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
+#include <com/sun/star/uno/XInterface.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_EVENTOBJECT_HXX_
+#include <com/sun/star/lang/EventObject.hpp>
+#endif
+
+
+/** */ //for docpp
+namespace cppu
+{
+
+//===================================================================
+class OInterfaceContainerHelper;
+/**
+ * This is the iterator of a InterfaceContainerHelper. The iterator
+ * ist is not thread save. It is not allowed to assign or copy an
+ * instance of this class.
+ *
+ * @version 0.1
+ * @author Markus Meyer
+ * @since 03/12/98
+ * @see OInterfaceContainerHelper
+ */
+class OInterfaceIteratorHelper
+{
+public:
+ OInterfaceIteratorHelper();
+ /**
+ * Create an iterator over the elements of the container. The iterator
+ * copies the elements of the conatainer. A change to the container does not
+ * affect the iterator.<BR>
+ * Remark: The copy is on demand. The iterator copy the elements only if the container
+ * change the contens. It is not allowed to destroy the container if a iterator exist.
+ *
+ * @param rCont the container of the elements.
+ */
+ OInterfaceIteratorHelper( OInterfaceContainerHelper & rCont );
+
+ /**
+ * Release the connection to the container.
+ */
+ ~OInterfaceIteratorHelper();
+
+ /** Return true, if there are more elements in the iterator. */
+ sal_Bool SAL_CALL hasMoreElements() const { return nRemain != 0; }
+ /** Return the next element of the iterator. Call this method if
+ * hasMoreElements return false, is an error.
+ */
+ ::com::sun::star::uno::XInterface * SAL_CALL next();
+
+private:
+ OInterfaceContainerHelper & rCont;
+ sal_Bool bIsList;
+ void * pData;
+ sal_Int32 nRemain;
+
+ OInterfaceIteratorHelper( const OInterfaceIteratorHelper & );
+ OInterfaceIteratorHelper & operator = ( const OInterfaceIteratorHelper & );
+};
+
+//===================================================================
+/**
+ * A container of interfaces. To access the elements use an iterator.
+ * This implementation is thread save.<BR>
+ * <B>Inserting null pointers is allowed, but is not tested and does not work.</B>
+ *
+ * @version 0.1
+ * @author Markus Meyer
+ * @since 03/12/98
+ * @see OInterfaceIteratorHelper
+ */
+class OInterfaceContainerHelper
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ static void * SAL_CALL operator new( size_t nSize ) throw()
+ { return ::rtl_allocateMemory( nSize ); }
+ static void SAL_CALL operator delete( void * pMem ) throw()
+ { ::rtl_freeMemory( pMem ); }
+
+ /**
+ * Create an interface container. The internal representation
+ * is an array, so it is not effective to store a large number
+ * of elements.
+ *
+ * @param rMutex the mutex to protect multi thread access.
+ * The lifetime must be longer than the lifetime
+ * of this object.
+ */
+ OInterfaceContainerHelper( ::osl::Mutex & rMutex );
+ /**
+ * Release all interfaces. All iterators must be destroyed before
+ * the container.
+ */
+ ~OInterfaceContainerHelper();
+ /**
+ * Return the number of Elements in the container. Only usefull if you are acquire
+ * the mutex.
+ */
+ sal_Int32 SAL_CALL getLength() const;
+
+ /**
+ * Return all interfaces added to this container.
+ **/
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > SAL_CALL getElements() const;
+
+ /**
+ * Insert an element in the container. The position is not specified.
+ * @param rxIFace the added interface. It is allowed to insert null or
+ * the same pointer more than once.
+ * @return the new count of elements in the container.
+ */
+ sal_Int32 SAL_CALL addInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace );
+ /**
+ * Remove an element from the container. It uses the equal definition of
+ * uno objects to remove the interfaces.
+ * @param rxIFace the removed interface.
+ * @return the new count of elements in the container.
+ */
+ sal_Int32 SAL_CALL removeInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace );
+ /**
+ * Call disposing on all object in the container that
+ * support XEventListener. Than clear the container.
+ */
+ void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt );
+ /**
+ * Remove all elements.
+ */
+ void SAL_CALL clear();
+
+private:
+friend class OInterfaceIteratorHelper;
+ /**
+ * bIsList == TRUE -> pData of type Sequence< XInterfaceSequence >,
+ * otherwise pData == of type (XEventListener *)
+ */
+ void * pData;
+ ::osl::Mutex & rMutex;
+ /** TRUE -> used by an iterator. */
+ sal_Bool bInUse;
+ /** TRUE -> pData is of type Sequence< XInterfaceSequence >. */
+ sal_Bool bIsList;
+
+ OInterfaceContainerHelper( const OInterfaceContainerHelper & );
+ OInterfaceContainerHelper & operator = ( const OInterfaceContainerHelper & );
+
+ /**
+ * Dulicate content of the conaitner and release the old one without destroing.
+ * The mutex must be locked and the memberbInUse must be true.
+ */
+ void copyAndResetInUse();
+public:
+};
+
+
+
+//===================================================================
+/**
+ * A generic class to support the implementation of the XConnectionPointContainer interface.
+ * This class holds a STL hash_map to acces the InterfaceContainerHelper through a generic
+ * key value.
+ * The InterfaceContainerHelper you get with the method getContainer( ... ) exist
+ * until the whole PropertyListenerContainer is destroyed.
+ *
+ * @author Markus Meyer
+ * @since 03/12/98
+ * @see OInterfaceIteratorHelper
+ * @see OInterfaceContainerHelper
+ */
+template< class key , class hashImpl , class equalImpl >
+class OMultiTypeInterfaceContainerHelperVar
+{
+public:
+ /**
+ * Create a container of interface containers.
+ *
+ * @param rMutex the mutex to protect multi thread access.
+ * The lifetime must be longer than the lifetime
+ * of this object.
+ */
+ inline OMultiTypeInterfaceContainerHelperVar( ::osl::Mutex & );
+ /**
+ * Delete all containers.
+ */
+ inline ~OMultiTypeInterfaceContainerHelperVar();
+
+ /**
+ * Return all id's under which at least one interface is added.
+ */
+ inline ::com::sun::star::uno::Sequence< key > SAL_CALL getContainedTypes() const;
+
+ /**
+ * Return the container created under this key.
+ * @return the container created under this key. If the container
+ * was not created, null was returned.
+ */
+ inline OInterfaceContainerHelper * SAL_CALL getContainer( const key & ) const;
+
+ /**
+ * Insert an element in the container specified with the key. The position is not specified.
+ * @param rKey the id of the container.
+ * @param rxIFace the added interface. It is allowed to insert null or
+ * the same pointer more than once.
+ * @return the new count of elements in the container.
+ */
+ inline sal_Int32 SAL_CALL addInterface(
+ const key & rKey, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r );
+
+ /**
+ * Remove an element from the container specified with the key.
+ * It uses the equal definition of uno objects to remove the interfaces.
+ * @param rKey the id of the container.
+ * @param rxIFace the removed interface.
+ * @return the new count of elements in the container.
+ */
+ inline sal_Int32 SAL_CALL removeInterface(
+ const key & rKey, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace );
+
+ /**
+ * Call disposing on all object in the container that
+ * support XEventListener. Than clear the container.
+ */
+ inline void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt );
+ /**
+ * Remove all elements of all containers. Does not delete the container.
+ */
+ inline void SAL_CALL clear();
+
+private:
+ ::std::hash_map< key , void* , hashImpl , equalImpl > *m_pMap;
+ ::osl::Mutex & rMutex;
+
+ inline OMultiTypeInterfaceContainerHelperVar( const OMultiTypeInterfaceContainerHelperVar & );
+ inline OMultiTypeInterfaceContainerHelperVar & operator = ( const OMultiTypeInterfaceContainerHelperVar & );
+};
+
+
+
+
+/**
+ * This struct contain the standard variables of a broadcaster. Helper
+ * classes only know a reference to this struct instead of references
+ * to the four members. The access to the members must be guarded with
+ * rMutex.
+ *
+ * @author Markus Meyer
+ * @since 03/12/98
+ */
+template < class container >
+struct OBroadcastHelperVar
+{
+ /** The shared mutex. */
+ ::osl::Mutex & rMutex;
+ /** ListenerContainer class is thread save. */
+ container aLC;
+ /** Dispose call ready. */
+ sal_Bool bDisposed;
+ /** In dispose call. */
+ sal_Bool bInDispose;
+
+ /**
+ * Initialize the structur. bDispose and bInDispose are set to false.
+ * @param rMutex the mutex reference.
+ */
+ OBroadcastHelperVar( ::osl::Mutex & rMutex_ )
+ : rMutex( rMutex_ )
+ , aLC( rMutex_ )
+ , bDisposed( sal_False )
+ , bInDispose( sal_False )
+ {}
+};
+
+/*------------------------------------------
+*
+* In general, the above templates are used with a Type as key.
+* Therefore a default declaration is given ( OMultiTypeInterfaceContainerHelper and OBroadcastHelper )
+*
+*------------------------------------------*/
+
+// helper function call class
+struct hashType_Impl
+{
+ size_t operator()(const ::com::sun::star::uno::Type & s) const
+ { return s.getTypeName().hashCode(); }
+};
+
+
+typedef OMultiTypeInterfaceContainerHelperVar<
+ ::com::sun::star::uno::Type,
+ hashType_Impl,
+ std::equal_to< ::com::sun::star::uno::Type > > OMultiTypeInterfaceContainerHelper;
+
+typedef OBroadcastHelperVar< OMultiTypeInterfaceContainerHelper > OBroadcastHelper;
+
+}
+
+#endif
+
diff --git a/cppuhelper/inc/cppuhelper/interfacecontainer.hxx b/cppuhelper/inc/cppuhelper/interfacecontainer.hxx
new file mode 100644
index 000000000000..680407ac070a
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/interfacecontainer.hxx
@@ -0,0 +1,240 @@
+/*************************************************************************
+ *
+ * $RCSfile: interfacecontainer.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#define _CPPUHELPER_INTERFACECONTAINER_HXX_
+
+#include <cppuhelper/interfacecontainer.h>
+
+
+#define CONT_HASHMAP ::std::hash_map< key , void* , hashImpl , equalImpl >
+
+namespace cppu
+{
+
+template< class key , class hashImpl , class equalImpl >
+inline OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::OMultiTypeInterfaceContainerHelperVar( ::osl::Mutex & rMutex_ )
+ : rMutex( rMutex_ )
+{
+ m_pMap = new CONT_HASHMAP;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+inline OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::~OMultiTypeInterfaceContainerHelperVar()
+{
+ CONT_HASHMAP::iterator iter = m_pMap->begin();
+ CONT_HASHMAP::iterator end = m_pMap->end();
+
+ while( iter != end )
+ {
+ delete (OInterfaceContainerHelper*)(*iter).second;
+ (*iter).second = 0;
+ ++iter;
+ }
+ delete m_pMap;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+inline ::com::sun::star::uno::Sequence< key > OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::getContainedTypes() const
+{
+ CONT_HASHMAP::size_type nSize;
+
+ ::osl::MutexGuard aGuard( rMutex );
+ if( nSize = m_pMap->size() )
+ {
+ ::com::sun::star::uno::Sequence< key > aInterfaceTypes( nSize );
+ key * pArray = aInterfaceTypes.getArray();
+
+ CONT_HASHMAP::iterator iter = m_pMap->begin();
+ CONT_HASHMAP::iterator end = m_pMap->end();
+
+ sal_Int32 i = 0;
+ while( iter != end )
+ {
+ // are interfaces added to this container?
+ if( ((OInterfaceContainerHelper*)(*iter).second)->getLength() )
+ // yes, put the type in the array
+ pArray[i++] = (*iter).first;
+ iter++;
+ }
+ if( i != nSize ) {
+ // may be empty container, reduce the sequence to the right size
+ aInterfaceTypes = ::com::sun::star::uno::Sequence<key>( pArray, i );
+ }
+ return aInterfaceTypes;
+ }
+ return ::com::sun::star::uno::Sequence<key>();
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::getContainer
+(
+ const key & rKey
+) const
+{
+ ::osl::MutexGuard aGuard( rMutex );
+
+ CONT_HASHMAP::iterator iter = m_pMap->find( rKey );
+ if( iter != m_pMap->end() )
+ return (OInterfaceContainerHelper*) (*iter).second;
+ return 0;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+sal_Int32 OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::addInterface
+(
+ const key & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener
+)
+{
+ ::osl::MutexGuard aGuard( rMutex );
+ CONT_HASHMAP::iterator
+ iter = m_pMap->find( rKey );
+ if( iter == m_pMap->end() )
+ {
+ OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
+ (*m_pMap)[rKey] = pLC;
+ return pLC->addInterface( rListener );
+ }
+ else
+ return ((OInterfaceContainerHelper*)(*iter).second)->addInterface( rListener );
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+inline sal_Int32 OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::removeInterface
+(
+ const key & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener
+)
+{
+ ::osl::MutexGuard aGuard( rMutex );
+
+ // search container with id nUik
+ CONT_HASHMAP::iterator iter = m_pMap->find( rKey );
+ // container found?
+ if( iter != m_pMap->end() )
+ return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
+
+ // no container with this id. Always return 0
+ return 0;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+void OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt )
+{
+ CONT_HASHMAP::size_type nSize = 0;
+ OInterfaceContainerHelper ** ppListenerContainers = NULL;
+ {
+ ::osl::MutexGuard aGuard( rMutex );
+ if( nSize = m_pMap->size() )
+ {
+ typedef OInterfaceContainerHelper* ppp;
+ ppListenerContainers = new ppp[nSize];
+ //ppListenerContainers = new (ListenerContainer*)[nSize];
+
+ CONT_HASHMAP::iterator iter = m_pMap->begin();
+ CONT_HASHMAP::iterator end = m_pMap->end();
+
+ CONT_HASHMAP::size_type i = 0;
+ while( iter != end )
+ {
+ ppListenerContainers[i++] = (OInterfaceContainerHelper*)(*iter).second;
+ ++iter;
+ }
+ }
+ }
+
+ // create a copy, because do not fire event in a guarded section
+ for( CONT_HASHMAP::size_type i = 0;
+ i < nSize; i++ )
+ {
+ if( ppListenerContainers[i] )
+ ppListenerContainers[i]->disposeAndClear( rEvt );
+ }
+
+ delete [] ppListenerContainers;
+}
+
+//===================================================================
+template< class key , class hashImpl , class equalImpl >
+void OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::clear()
+{
+ ::osl::MutexGuard aGuard( rMutex );
+ CONT_HASHMAP::iterator iter = m_pMap->begin();
+ CONT_HASHMAP::iterator end = m_pMap->end();
+
+ while( iter != end )
+ {
+ ((OInterfaceContainerHelper*)(*iter)).second->clear();
+ ++iter;
+ }
+}
+
+
+}
+
+#endif
+
diff --git a/cppuhelper/inc/cppuhelper/propshlp.hxx b/cppuhelper/inc/cppuhelper/propshlp.hxx
new file mode 100644
index 000000000000..bf4449f94ca1
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/propshlp.hxx
@@ -0,0 +1,479 @@
+/*************************************************************************
+ *
+ * $RCSfile: propshlp.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_PROPSHLP_HXX
+#define _CPPUHELPER_PROPSHLP_HXX
+
+#include <rtl/alloc.h>
+
+#include <stl/hash_map>
+
+#include <cppuhelper/interfacecontainer.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+
+namespace cppu
+{
+
+
+/*************************************************************************
+*************************************************************************/
+
+
+/**
+ * This interface is used by the OPropertyHelper, to access the property description.
+ */
+class IPropertyArrayHelper
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ static void * SAL_CALL operator new( size_t nSize ) throw()
+ { return ::rtl_allocateMemory( nSize ); }
+ static void SAL_CALL operator delete( void * pMem ) throw()
+ { ::rtl_freeMemory( pMem ); }
+
+ /**
+ * Folowing the rule, the first virtual method impies the virtual destructor.
+ */
+ virtual ~IPropertyArrayHelper();
+
+ /**
+ * Return the property members Name and Attribute from the handle nHandle.
+ * @param nHandle the handle of a property. If the values of the handles
+ * are sorted in the same way as the names and the highest handle value
+ * is getCount() -1, than it must be an indexed acces to the property array.
+ * @param pPropName is an out parameter filled with property name of the property with the
+ * handle nHandle. May be NULL.
+ * @param rAttributes is an out parameter filled with attributes of the property with the
+ * handle nHandle. May be NULL.
+ * @return True, if the handle exist, otherwise false.
+ */
+ virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
+ ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) = 0;
+ /**
+ * Return the sequence of properties. The sequence is sorted by name.
+ */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void) = 0;
+ /**
+ * Return the property with the name rPropertyName.
+ * @param rPropertyName the name of the property.
+ * @exception UnknownPropertyException thrown if the property name is unknown.
+ */
+ virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName(
+ const ::rtl::OUString& rPropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException) = 0;
+ /**
+ * Return true if the property with the name rPropertyName exist, otherwise false.
+ * @param rPropertyName the name of the property.
+ */
+ virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0;
+ /**
+ * Return the handle of the property with the name rPropertyName.
+ * If the property does not exist -1 is returned.
+ * @param rPropertyName the name of the property.
+ */
+ virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0;
+ /**
+ * Fill the array with the handles of the properties.
+ * @return the handles of the names from the pHandles array. -1
+ * indicates an unknown property name.
+ */
+ virtual sal_Int32 SAL_CALL fillHandles(
+ /*out*/ sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0;
+};
+
+/**
+ * You can use this helper class to map a XPropertySet-Interface to a XFast-
+ * or a XMultiPropertySet interface.
+ */
+class OPropertyArrayHelper : public IPropertyArrayHelper
+{
+public:
+ /*********
+ * Create an object which supports the common property interfaces.
+ *
+ * @param pProps array of properties
+ * The array pProps should be sorted.
+ * @param nElements is the number of properties in the pProps structure.
+ * @param bSorted indicates that the elements are sorted.
+ *********/
+ OPropertyArrayHelper( ::com::sun::star::beans::Property *pProps,
+ sal_Int32 nElements ,
+ sal_Bool bSorted = sal_True );
+
+ /*********
+ * Create an object which supports the common property interfaces.
+ * @param aProps sequence of properties which are supported by this helper.
+ * The sequence aProps should be sorted.
+ * @param bSorted indicates that the elements are sorted.
+ *********/
+ OPropertyArrayHelper( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > & aProps,
+ sal_Bool bSorted = sal_True );
+ /**
+ * Return the number of properties.
+ */
+ sal_Int32 SAL_CALL getCount() const;
+ /**
+ * Return the property members Name and Attribute from the handle nHandle.
+ * @param nHandle the handle of a property. If the values of the handles
+ * are sorted in the same way as the names and the highest handle value
+ * is getCount() -1, than it is only an indexed acces to the property array.
+ * Otherwise it is a linear search through the array.
+ * @param pPropName is an out parameter filled with property name of the property with the
+ * handle nHandle. May be NULL.
+ * @param rAttributes is an out parameter filled with attributes of the property with the
+ * handle nHandle. May be NULL.
+ * @return True, if the handle exist, otherwise false.
+ */
+ virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
+ ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle );
+ /**
+ * Return the sequence of properties. The sequence is sorted by name.
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void);
+ /**
+ * Return the property with the name rPropertyName.
+ * @param rPropertyName the name of the property.
+ * @exception UnknownPropertyException thrown if the property name is unknown.
+ */
+ ::com::sun::star::beans::Property SAL_CALL getPropertyByName(const ::rtl::OUString& rPropertyName)
+ throw (::com::sun::star::beans::UnknownPropertyException);
+ /**
+ * Return true if the property with the name rPropertyName exist, otherwise false.
+ * @param rPropertyName the name of the property.
+ */
+ sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName);
+ /**
+ * Return the handle of the property with the name rPropertyName.
+ * If the property does not exist -1 is returned.
+ * @param rPropertyName the name of the property.
+ */
+ sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName );
+ /**
+ * Fill the array with the handles of the properties.
+ * @return the handles of the names from the pHandles array. -1
+ * indicates an unknown property name.
+ */
+ sal_Int32 SAL_CALL fillHandles(
+ /*out*/sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames );
+private:
+ void init( sal_Bool bSorted );
+
+ /** The sequence generstet from the pProperties array. */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aInfos;
+ /**
+ * True, If the values of the handles are sorted in the same way as the names
+ * and the highest handle value is getCount() -1, otherwise false.
+ */
+ sal_Bool bRightOrdered;
+};
+
+
+/**
+ * This abstract class map the methods of the interfaces XMultiPropertySet, XFastPropertySet
+ * and XPropertySet to the methods getInfoHelper, convertFastPropertyValue,
+ * setFastPropertyValue_NoBroadcast and getFastPropertyValue. You must subclass
+ * this one and overload the methods.<BR>
+ * It provide a standard implementation of the XPropertySetInfo.<BR>
+ * The XPropertiesChangeListener are inserted in the rBHelper.aLC structure.<BR>
+ * The XPropertyChangeListener and XVetoableChangeListener with no names are inserted
+ * in the rBHelper.aLC structure. So it is possible to advise property listeners with
+ * the connection point interfaces. But only listeners that listen to all property changes.
+ * The subclass must explicite allow the access through the XConnectionPoint interface.<BR>
+ * <B>Not tested under MT conditions</B>
+ *
+ * @see OConnectionPointContainerHelper
+ * @see createPropertySetInfo
+ * @author Markus Meyer
+ * @since 12/04/98
+ */
+
+
+
+//-----------------------------------------------------------------------------
+// helper defines needed for an interface container with a 32 bit key values
+
+struct equalInt32_Impl
+{
+ bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const
+ { return i1 == i2; }
+};
+
+
+struct hashInt32_Impl
+{
+ size_t operator()(const sal_Int32 & i) const
+ { return i; }
+};
+typedef OMultiTypeInterfaceContainerHelperVar< sal_Int32, hashInt32_Impl, equalInt32_Impl >
+ OMultiTypeInterfaceContainerHelperInt32;
+
+
+class OPropertySetHelper : public ::com::sun::star::beans::XMultiPropertySet,
+ public ::com::sun::star::beans::XFastPropertySet,
+ public ::com::sun::star::beans::XPropertySet
+{
+public:
+ /**
+ * Create empty property listener container and hold the helper structure.
+ *
+ * @param rBHelper this structure containes the basic members of
+ * a broadcaster.
+ * The lifetime must be longer as the lifetime
+ * of this object. Stored in the variable rBHelper.
+ */
+ OPropertySetHelper( OBroadcastHelper & rBHelper );
+ /**
+ * You must call disposing before destruction.
+ */
+ ~OPropertySetHelper();
+
+ /**
+ * Only return a reference to XMultiPropertySet, XFastPropertySet, XPropertySet and
+ * XEventListener.
+ * <B>Do not return a reference to XInterface.</B>
+ */
+ ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType );
+
+ /**
+ * Send a disposing notification to the listeners in the conatiners aBoundLC
+ * and aVetoableLC.
+ *
+ * @see OComponentHelper
+ */
+ void SAL_CALL disposing();
+
+ // XPropertySet
+ //XPropertySetInfoRef getPropertySetInfo() const;
+ /**
+ * Throw UnknownPropertyException or PropertyVetoException if the property with the name
+ * rPropertyName does not exist or is readonly. Otherwise rPropertyName is changed to its handle
+ * value and setFastPropertyValue is called.
+ */
+ void SAL_CALL setPropertyValue(const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Any& aValue);
+ /**
+ * Throw UnknownPropertyException if the property with the name
+ * rPropertyName does not exist.
+ */
+ ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName);
+ /** Ignored if the property is not bound. */
+ void SAL_CALL addPropertyChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ /** Ignored if the property is not bound. */
+ void SAL_CALL removePropertyChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertyChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ /** Ignored if the property is not constrained. */
+ void SAL_CALL addVetoableChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ /** Ignored if the property is not constrained. */
+ void SAL_CALL removeVetoableChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XFastPropertySet
+ /**
+ * Throw UnknownPropertyException or PropertyVetoException if the property with the name
+ * rPropertyName does not exist or is readonly. Otherwise the method convertFastPropertyValue
+ * is called, than the vetoable listeners are notified. After this the value of the property
+ * is changed with the setFastPropertyValue_NoBroadcast method and the bound listeners are
+ * notified.
+ */
+ void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ /**
+ * Throw UnknownPropertyException if the property with the handle
+ * nHandle does not exist.
+ */
+ ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XMultiPropertySet
+ void SAL_CALL setPropertyValues(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames );
+
+ void SAL_CALL addPropertiesChangeListener(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener );
+
+ void SAL_CALL removePropertiesChangeListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener );
+ void SAL_CALL firePropertiesChangeEvent(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > & Listener );
+ /**
+ * The property sequence is create in the call. The interface isn't used after the call.
+ */
+ static ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo >
+ SAL_CALL createPropertySetInfo( IPropertyArrayHelper & rProperties );
+protected:
+ /**
+ * This method fire events to all registered property listeners.
+ * @param pnHandles the id's of the properties that changed.
+ * @param pNewValues the new values of the properties.
+ * @param pOldValues the old values of the properties.
+ * @param nCount the number of elements in the arrays pnHandles, pNewValues and pOldValues.
+ * @param bVetoable true means fire to VetoableChangeListener, false means fire to
+ * XPropertyChangedListener and XMultiPropertyChangedListener.
+ */
+ void SAL_CALL fire( sal_Int32 * pnHandles,
+ const ::com::sun::star::uno::Any * pNewValues,
+ const ::com::sun::star::uno::Any * pOldValues,
+ sal_Int32 nCount,
+ sal_Bool bVetoable );
+
+ /**
+ * Set multible properties with the handles.
+ * @param nSeqLen the length of the arrays pHandles and Values.
+ * @param pHandles the handles of the properties. The number of elements
+ * in the Values sequence is the length of the handle array. A value of -1
+ * of a handle means invalid property. These are ignored.
+ * @param pValues the values of the properties.
+ * @param nHitCount the number of valid entries in the handle array.
+ */
+ void SAL_CALL setFastPropertyValues( sal_Int32 nSeqLen,
+ sal_Int32 * pHandles,
+ const ::com::sun::star::uno::Any * pValues,
+ sal_Int32 nHitCount )
+ throw (::com::sun::star::uno::Exception);
+
+ /**
+ * This abstract method must return the name to index table. This table contains all property
+ * names and types of this object. The method is not implemented in this class.
+ */
+ virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
+
+ /**
+ * Converted the value rValue and return the result in rConvertedValue and the
+ * old value in rOldValue. A IllegalArgumentException is thrown.
+ * The method is not implemented in this class. After this call the vetoable
+ * listeners are notified.
+ *
+ * @param rConvertedValue the converted value. Only set if return is true.
+ * @param rOldValue the old value. Only set if return is true.
+ * @param nHandle the handle of the proberty.
+ * @return true if the value converted.
+ */
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException) = 0;
+ /**
+ * The same as setFastProperyValue, but no exception is thrown and nHandle
+ * is always valid. You must not broadcast the changes in this method.<BR>
+ * <B>You type is correct you need't test it.</B>
+ * The method is not implemented in this class.
+ */
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::uno::Exception) = 0;
+ /**
+ * The same as getFastProperyValue, but return the value through rValue and nHandle
+ * is always valid.
+ * The method is not implemented in this class.
+ */
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle ) const = 0;
+
+ /** The common data of a broadcaster. Use the mutex, disposing state and the listener container. */
+ OBroadcastHelper &rBHelper;
+ /**
+ * Container for the XProperyChangedListener. The listeners are inserted by handle.<BR>
+ * Listeners added without name are inserted in the rBHelper.aLC container under
+ * the Uik XPropertyChangeListener::getSmartUik().
+ */
+ OMultiTypeInterfaceContainerHelperInt32 aBoundLC;
+ /**
+ * Container for the XPropertyVetoableListener. The listeners are inserted by handle.
+ * Listeners added without name are inserted in the rBHelper.aLC container under
+ * the Uik XVetoableChangeListener::getSmartUik().
+ */
+ OMultiTypeInterfaceContainerHelperInt32 aVetoableLC;
+private:
+ OPropertySetHelper( const OPropertySetHelper & );
+ OPropertySetHelper & operator = ( const OPropertySetHelper & );
+};
+
+} // end namespace cppuhelper
+#endif //
+
+
+
diff --git a/cppuhelper/inc/cppuhelper/proptypehlp.h b/cppuhelper/inc/cppuhelper/proptypehlp.h
new file mode 100644
index 000000000000..3592932c34e7
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/proptypehlp.h
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * $RCSfile: proptypehlp.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_PROPTYPEHLP_H
+#define _CPPUHELPER_PROPTYPEHLP_H
+
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/uno/TypeClass.hpp>
+
+
+namespace cppu {
+
+/**
+ * Convert a property value to the specified type of the property.
+ * Look at the XPropertySet interface about the conversion rules.<BR>
+ *
+ * If a property could not be converted a IllegalArgumentException is thrown.
+ *
+ */
+
+template < class target >
+inline void SAL_CALL convertPropertyValue( target &value , const ::com::sun::star::uno::Any & a);
+// throw (::com::sun::star::lang::IllegalArgumentException);
+
+// This template is needed at least for msci4 compiler
+template < class target >
+inline void SAL_CALL convertPropertyValue( target &value , ::com::sun::star::uno::Any & a);
+// throw (::com::sun::star::lang::IllegalArgumentException);
+
+/****
+*
+* conversion of basic types
+*
+*****/
+inline void SAL_CALL convertPropertyValue( sal_Int64 & target , const ::com::sun::star::uno::Any & source )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+inline void SAL_CALL convertPropertyValue( sal_uInt64 & target, const ::com::sun::star::uno::Any & source )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+inline void SAL_CALL convertPropertyValue( sal_Int32 & target , const ::com::sun::star::uno::Any & source )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+inline void SAL_CALL convertPropertyValue( sal_uInt32 & target, const ::com::sun::star::uno::Any & source )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+inline void SAL_CALL convertPropertyValue( sal_Int16 & target , const ::com::sun::star::uno::Any & source )
+ throw( ::com::sun::star::lang::IllegalArgumentException);
+inline void SAL_CALL convertPropertyValue( sal_uInt16 & target, const ::com::sun::star::uno::Any & source )
+ throw( ::com::sun::star::lang::IllegalArgumentException);
+inline void SAL_CALL convertPropertyValue( sal_Int8 & target , const ::com::sun::star::uno::Any & source )
+ throw( ::com::sun::star::lang::IllegalArgumentException);
+inline void SAL_CALL convertPropertyValue( float & target , const ::com::sun::star::uno::Any & source )
+ throw( ::com::sun::star::lang::IllegalArgumentException);
+inline void SAL_CALL convertPropertyValue( double &target , const ::com::sun::star::uno::Any &source )
+ throw( ::com::sun::star::lang::IllegalArgumentException);
+inline void SAL_CALL convertPropertyValue( ::rtl::OUString &target , const ::com::sun::star::uno::Any &source )
+ throw( ::com::sun::star::lang::IllegalArgumentException);
+
+} // end namespace cppu
+
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/proptypehlp.hxx b/cppuhelper/inc/cppuhelper/proptypehlp.hxx
new file mode 100644
index 000000000000..174b4a081a89
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/proptypehlp.hxx
@@ -0,0 +1,556 @@
+/*************************************************************************
+ *
+ * $RCSfile: proptypehlp.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_PROPTYPEHLP_HXX
+#define _CPPUHELPER_PROPTYPEHLP_HXX
+
+#include <cppuhelper/proptypehlp.h>
+
+namespace cppu
+{
+
+template < class target >
+inline void SAL_CALL convertPropertyValue( target &value , const ::com::sun::star::uno::Any & a)
+{
+// any sense ?
+// const ::com::sun::star::uno::Type &t = ::getCppuType( &value );
+// enum TypeClass tc = t.getTypeClass();
+
+ if( !( a >>= value ) ) {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+
+// This template is needed at least for msci4 compiler
+template < class target >
+inline void SAL_CALL convertPropertyValue( target &value , ::com::sun::star::uno::Any & a)
+{
+ convertPropertyValue( value , (const ::com::sun::star::uno::Any & ) a );
+}
+
+inline void SAL_CALL convertPropertyValue( sal_Bool & b , const ::com::sun::star::uno::Any & a )
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32;
+ a >>= i32;
+ b = ( sal_Bool )i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c = *(sal_Unicode*) a.getValue();
+ b = ( sal_Bool ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ b = ( sal_Bool ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ b = *((sal_Bool*)a.getValue());
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ b = ( sal_Bool ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ b = ( sal_Bool ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32;
+ a >>= i32;
+ b = ( sal_Bool ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( sal_Int64 & i , const ::com::sun::star::uno::Any & a )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_HYPER == tc ) {
+ a >>= i;
+ }
+ else if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+ sal_uInt64 i64;
+ a >>= i64;
+ i = ( sal_Int64 ) i64;
+ }
+ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32;
+ a >>= i32;
+ i = ( sal_Int64 )i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode *)a.getValue();
+ i = ( sal_Int64 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ i = ( sal_Int64 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int64 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ i = ( sal_Int64 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ i = ( sal_Int64 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32;
+ a >>= i32;
+ i = ( sal_Int64 ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+
+inline void SAL_CALL convertPropertyValue( sal_uInt64 & i , const ::com::sun::star::uno::Any & a )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+ a >>= i;
+ }
+ if( ::com::sun::star::uno::TypeClass_HYPER == tc ) {
+ sal_Int64 i64;
+ a >>= i64;
+ i = ( sal_uInt64 ) i64;
+ }
+ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32;
+ a >>= i32;
+ i = ( sal_uInt64 )i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *( sal_Unicode * ) a.getValue() ;
+ i = ( sal_uInt64 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ i = ( sal_uInt64 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_uInt64 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ i = ( sal_uInt64 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ i = ( sal_uInt64 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32;
+ a >>= i32;
+ i = ( sal_uInt64 ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+// the basic types
+// sal_Int32
+inline void SAL_CALL convertPropertyValue( sal_Int32 & i , const ::com::sun::star::uno::Any & a )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ a >>= i;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ i = ( sal_Int32 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ i = ( sal_Int32 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int32 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ i = ( sal_Int32 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ i = ( sal_Int32 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32;
+ a >>= i32;
+ i = ( sal_Int32 ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( sal_uInt32 & i , const ::com::sun::star::uno::Any & a )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ a >>= i;
+ }
+ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32;
+ a >>= i32;
+ i = (sal_uInt32 ) i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ i = ( sal_uInt32 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ i = ( sal_uInt32 ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_uInt32 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ i = ( sal_uInt32 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ i = ( sal_uInt32 ) i16;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+
+inline void SAL_CALL convertPropertyValue( sal_Int16 & i , const ::com::sun::star::uno::Any & a )
+ throw( ::com::sun::star::lang::IllegalArgumentException)
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ a >>= i;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ i = ( sal_Int16 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int16 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ i = ( sal_Int16 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ i = ( sal_Int16 ) i16;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( sal_uInt16 & i , const ::com::sun::star::uno::Any & a )
+ throw( ::com::sun::star::lang::IllegalArgumentException)
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ a >>= i;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode *) a.getValue();
+ i = ( sal_Int16 ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int16 ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ i = ( sal_Int16 ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ i = ( sal_Int16 ) i16;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( sal_Int8 & i , const ::com::sun::star::uno::Any & a )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ a >>= i;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ i = ( sal_Int8 ) b;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( float &f , const ::com::sun::star::uno::Any &a )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if ( ::com::sun::star::uno::TypeClass_FLOAT == tc ) {
+ a >>= f;
+ }
+ else if( ::com::sun::star::uno::TypeClass_DOUBLE == tc ) {
+ double d;
+ a >>= d;
+ f = ( float ) d;
+ }
+ else if( ::com::sun::star::uno::TypeClass_HYPER == tc ) {
+ sal_Int64 i64;
+ a >>= i64;
+ f = ( float ) i64;
+ }
+ // msci 4 does not support this conversion
+/* else if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+ sal_uInt64 i64;
+ a >>= i64;
+ f = ( float ) i64;
+ }
+*/ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32;
+ a >>= i32;
+ f = ( float )i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ f = ( float ) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ f = ( float ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ f = ( float ) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ f = ( float ) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ f = ( float ) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32;
+ a >>= i32;
+ f = ( float ) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+
+inline void SAL_CALL convertPropertyValue( double &d , const ::com::sun::star::uno::Any &a )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass();
+
+ if( ::com::sun::star::uno::TypeClass_DOUBLE == tc ) {
+ float f;
+ a >>= f;
+ d = ( double ) f;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_FLOAT == tc ) {
+ float f;
+ a >>= f;
+ d = (double) f;
+ }
+ else if( ::com::sun::star::uno::TypeClass_HYPER == tc ) {
+ sal_Int64 i64;
+ a >>= i64;
+ d = (double) i64;
+ }
+ // msci 4 does not support this
+/* else if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) {
+ sal_uInt64 i64;
+ a >>= i64;
+ d = (double) i64;
+ }
+*/ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) {
+ sal_Int32 i32;
+ a >>= i32;
+ d = (double)i32;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) {
+ sal_Unicode c;
+ c = *(sal_Unicode*) a.getValue();
+ d = (double) c;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) {
+ sal_Int16 i16;
+ a >>= i16;
+ d = (double) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) {
+ sal_Bool b;
+ b = *((sal_Bool * )a.getValue());
+ d = (double) b;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) {
+ sal_Int8 i8;
+ a >>= i8;
+ d = (double) i8;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) {
+ sal_uInt16 i16;
+ a >>= i16;
+ d = (double) i16;
+ }
+ else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) {
+ sal_uInt32 i32;
+ a >>= i32;
+ d = (double) i32;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+inline void SAL_CALL convertPropertyValue( ::rtl::OUString &ow , const ::com::sun::star::uno::Any &a )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ if( ::com::sun::star::uno::TypeClass_STRING == a.getValueType().getTypeClass() ) {
+ a >>= ow;
+ }
+ else {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+}
+
+} // end namespace cppu
+
+#endif
+
+
diff --git a/cppuhelper/inc/cppuhelper/queryinterface.hxx b/cppuhelper/inc/cppuhelper/queryinterface.hxx
new file mode 100644
index 000000000000..67272aa33c4a
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/queryinterface.hxx
@@ -0,0 +1,487 @@
+/*************************************************************************
+ *
+ * $RCSfile: queryinterface.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#define _CPPUHELPER_QUERYINTERFACE_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
+#include <com/sun/star/uno/XInterface.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#include <com/sun/star/uno/Reference.hxx>
+#endif
+
+/** */ //for docpp
+namespace cppu
+{
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ */
+template< class Interface1 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ */
+template< class Interface1, class Interface2 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ * @param p4 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3, class Interface4 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *)0 ))
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ * @param p4 a pointer to an interface.
+ * @param p5 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *)0 ))
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *)0 ))
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ * @param p4 a pointer to an interface.
+ * @param p5 a pointer to an interface.
+ * @param p6 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *)0 ))
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *)0 ))
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *)0 ))
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ * @param p4 a pointer to an interface.
+ * @param p5 a pointer to an interface.
+ * @param p6 a pointer to an interface.
+ * @param p7 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *)0 ))
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *)0 ))
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *)0 ))
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *)0 ))
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ * @param p4 a pointer to an interface.
+ * @param p5 a pointer to an interface.
+ * @param p6 a pointer to an interface.
+ * @param p7 a pointer to an interface.
+ * @param p8 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *)0 ))
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *)0 ))
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *)0 ))
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *)0 ))
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface8 > *)0 ))
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ * @param p4 a pointer to an interface.
+ * @param p5 a pointer to an interface.
+ * @param p6 a pointer to an interface.
+ * @param p7 a pointer to an interface.
+ * @param p8 a pointer to an interface.
+ * @param p9 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8, class Interface9 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *)0 ))
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *)0 ))
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *)0 ))
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *)0 ))
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface8 > *)0 ))
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface9 > *)0 ))
+ return ::com::sun::star::uno::Any( &p9, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ * @param p4 a pointer to an interface.
+ * @param p5 a pointer to an interface.
+ * @param p6 a pointer to an interface.
+ * @param p7 a pointer to an interface.
+ * @param p8 a pointer to an interface.
+ * @param p9 a pointer to an interface.
+ * @param p10 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8, class Interface9, class Interface10 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *)0 ))
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *)0 ))
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *)0 ))
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *)0 ))
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface8 > *)0 ))
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface9 > *)0 ))
+ return ::com::sun::star::uno::Any( &p9, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface10 > *)0 ))
+ return ::com::sun::star::uno::Any( &p10, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ * @param p4 a pointer to an interface.
+ * @param p5 a pointer to an interface.
+ * @param p6 a pointer to an interface.
+ * @param p7 a pointer to an interface.
+ * @param p8 a pointer to an interface.
+ * @param p9 a pointer to an interface.
+ * @param p10 a pointer to an interface.
+ * @param p11 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
+ class Interface11 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
+ Interface11 * p11 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *)0 ))
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *)0 ))
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *)0 ))
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *)0 ))
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface8 > *)0 ))
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface9 > *)0 ))
+ return ::com::sun::star::uno::Any( &p9, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface10 > *)0 ))
+ return ::com::sun::star::uno::Any( &p10, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface11 > *)0 ))
+ return ::com::sun::star::uno::Any( &p11, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+/**
+ * Compare types and choose return proper interface.
+ *<BR>
+ * @param p1 a pointer to an interface.
+ * @param p2 a pointer to an interface.
+ * @param p3 a pointer to an interface.
+ * @param p4 a pointer to an interface.
+ * @param p5 a pointer to an interface.
+ * @param p6 a pointer to an interface.
+ * @param p7 a pointer to an interface.
+ * @param p8 a pointer to an interface.
+ * @param p9 a pointer to an interface.
+ * @param p10 a pointer to an interface.
+ * @param p11 a pointer to an interface.
+ * @param p12 a pointer to an interface.
+ */
+template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
+ class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
+ class Interface11, class Interface12 >
+inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType,
+ Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
+ Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
+ Interface11 * p11, Interface12 * p12 )
+{
+ if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *)0 ))
+ return ::com::sun::star::uno::Any( &p1, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *)0 ))
+ return ::com::sun::star::uno::Any( &p2, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *)0 ))
+ return ::com::sun::star::uno::Any( &p3, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *)0 ))
+ return ::com::sun::star::uno::Any( &p4, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *)0 ))
+ return ::com::sun::star::uno::Any( &p5, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *)0 ))
+ return ::com::sun::star::uno::Any( &p6, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *)0 ))
+ return ::com::sun::star::uno::Any( &p7, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface8 > *)0 ))
+ return ::com::sun::star::uno::Any( &p8, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface9 > *)0 ))
+ return ::com::sun::star::uno::Any( &p9, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface10 > *)0 ))
+ return ::com::sun::star::uno::Any( &p10, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface11 > *)0 ))
+ return ::com::sun::star::uno::Any( &p11, rType );
+ else if (rType == ::getCppuType( (::com::sun::star::uno::Reference< Interface12 > *)0 ))
+ return ::com::sun::star::uno::Any( &p12, rType );
+ else
+ return ::com::sun::star::uno::Any();
+}
+
+}
+
+#endif
+
diff --git a/cppuhelper/inc/cppuhelper/servicefactory.hxx b/cppuhelper/inc/cppuhelper/servicefactory.hxx
new file mode 100644
index 000000000000..c24b0dbe7534
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/servicefactory.hxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * $RCSfile: servicefactory.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/*
+ * This bootstraps an initial service factory up to the point
+ * that a dll component loader, simple and default registry and an implementation registration
+ * service is registered and available.
+ * All other services have to be registered somewhere else.
+ */
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#define _CPPUHELPER_SERVICEFACTORY_HXX_
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+
+namespace cppu
+{
+
+/**
+ * This bootstraps an initial service factory working on a registry. If the first or both
+ * parameters contain a value then the service factory is initialized with a simple registry
+ * or a nested registry. Otherwise the service factory must be initialized later with a valid
+ * registry.
+ *<BR>
+ * @param rWriteRegistryFile file name of the simple registry or the first registry file of
+ * the nested registry which will be opened with read/write rights. This
+ * file will be created if necessary.
+ * @param rReadRegistryFile file name of the second registry file of the nested registry
+ * which will be opened with readonly rights.
+ * @param bReadOnly flag which specify that the first registry file will be opened with
+ * readonly rights. Default is FALSE. If this flag is used the registry
+ * will not be created if not exist.
+ * @param rBootstrapPath specify a path where the bootstrap components could be find. If this
+ * parameter is an empty string the compoents will be searched in the normal
+ * path.
+ *
+ * @author Daniel Boelzle
+ */
+::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL
+ createRegistryServiceFactory( const ::rtl::OUString & rWriteRegistryFile,
+ const ::rtl::OUString & rReadRegistryFile,
+ sal_Bool bReadOnly = sal_False,
+ const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() )
+ throw( ::com::sun::star::uno::Exception );
+
+
+/**
+ * This bootstraps an initial service factory working on a registry file.
+ *<BR>
+ * @param rRegistryFile file name of the registry to use/ create; if this is an empty
+ * string, the default registry is used instead
+ * @param bReadOnly flag which specify that the registry file will be opened with
+ * readonly rights. Default is FALSE. If this flag is used the registry
+ * will not be created if not exist.
+ *
+ * @author Daniel Boelzle
+ */
+inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL
+ createRegistryServiceFactory( const ::rtl::OUString & rRegistryFile,
+ sal_Bool bReadOnly = sal_False,
+ const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() )
+ throw( ::com::sun::star::uno::Exception )
+{
+ return ::cppu::createRegistryServiceFactory( rRegistryFile, ::rtl::OUString(), bReadOnly, rBootstrapPath );
+}
+
+
+/**
+ * This bootstraps a service factory without initilaize a registry.
+ *<BR>
+ * @author Daniel Boelzle
+ */
+inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL
+ createServiceFactory(const ::rtl::OUString & rBootstrapPath = ::rtl::OUString())
+ throw( ::com::sun::star::uno::Exception )
+{
+ return ::cppu::createRegistryServiceFactory( ::rtl::OUString(), ::rtl::OUString(), sal_False, rBootstrapPath );
+}
+
+} // end namespace cppu
+
+#endif
+
diff --git a/cppuhelper/inc/cppuhelper/stdidlclass.hxx b/cppuhelper/inc/cppuhelper/stdidlclass.hxx
new file mode 100644
index 000000000000..b0a7ffc30593
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/stdidlclass.hxx
@@ -0,0 +1,554 @@
+/*************************************************************************
+ *
+ * $RCSfile: stdidlclass.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_STDIDLCLASS_HXX_
+#define _CPPUHELPER_STDIDLCLASS_HXX_
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/reflection/XIdlClass.hpp>
+
+
+namespace cppu {
+
+/*****
+*
+* Standardfunction to create a XIdlClass for a component.
+* This method is usually used as a helper class. ( Better use the methods below ).
+*
+* HACK : Function returns pointer to XIdlClass instead of
+* a reference. This is because of a MSC 4.x bug.
+*
+******/
+::com::sun::star::reflection::XIdlClass * SAL_CALL createStandardClassWithSequence(
+ const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr ,
+ const ::rtl::OUString & sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > & rSuperClass,
+ const ::com::sun::star::uno::Sequence < ::rtl::OUString > &seq );
+
+
+
+/*--------------------------------------------------
+* Standardfunction to create an XIdlClass for a component. There is a function for each number of supported
+* interfaces up to 10.
+*
+* HACK : Function returns pointer to XIdlClass instead of
+* a reference. This is because of a MSC 4.x bug.
+*
+* Sample use for an XIdlClassProvider :
+*
+* // XIdlClassProvider
+*Sequence< Reference < XIdlClass > > SAL_CALL MyComponent::getIdlClasses(void)
+*{
+* // weak reference to cache the standard class
+* static WeakReference< XIdlClass > weakRef;
+*
+* // try to make weakref hard
+* Reference < XIdlClass > r = weakRef;
+*
+* if( ! r.is() ) {
+* // xidlclass has not been initialized before or has been destroyed already.
+* r = ::cppu::createStandardClass(
+* m_rSMgr , // Servicemanager
+* L"com.sun.star.comp.cppuhelper.OStdIdlClass" , // ImplementationName
+* Reference < XIdlClass > () , // Base classes
+* STATIC_CAST(XIdlClassProvider *, this), // Supported Interfaces
+* STATIC_CAST(XServiceInfo *, this ) ,
+* STATIC_CAST(XMyService * , this )
+* // ....
+* );
+*
+* // store reference for later use
+* weakRef = r;
+* }
+*
+* return Sequence < Reference < XIdlClass > > ( &r , 1 );
+*}
+*
+*--------------------------------------------------*/
+template < class Interface1 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(1);
+ seqInterface.getArray()[0] =
+ ::getCppuType( ( ::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+
+
+template < class Interface1, class Interface2 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1 ,
+ const Interface2 *p2
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(2);
+ seqInterface.getArray()[0] =
+ ::getCppuType( ( ::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[1] =
+ ::getCppuType( ( ::com::sun::star::uno::Reference< Interface2 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+
+
+
+
+template < class Interface1, class Interface2 , class Interface3 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1 ,
+ const Interface2 *p2 ,
+ const Interface3 *p3
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(3);
+ seqInterface.getArray()[0] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[1] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[2] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+
+
+
+
+template < class Interface1, class Interface2 , class Interface3 , class Interface4 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1 ,
+ const Interface2 *p2 ,
+ const Interface3 *p3 ,
+ const Interface4 *p4
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(4);
+ seqInterface.getArray()[0] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[1] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[2] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[3] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+
+
+
+
+
+
+template < class Interface1, class Interface2 , class Interface3 , class Interface4 , class Interface5 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1 ,
+ const Interface2 *p2 ,
+ const Interface3 *p3 ,
+ const Interface4 *p4 ,
+ const Interface5 *p5
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(5);
+ seqInterface.getArray()[0] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[1] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[2] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[3] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[4] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+
+
+
+template < class Interface1, class Interface2 , class Interface3 , class Interface4 , class Interface5 ,
+ class Interface6 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1 ,
+ const Interface2 *p2 ,
+ const Interface3 *p3 ,
+ const Interface4 *p4 ,
+ const Interface5 *p5 ,
+ const Interface6 *p6
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(6);
+ seqInterface.getArray()[0] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[1] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[2] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[3] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[4] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[5] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+
+
+
+
+template < class Interface1, class Interface2 , class Interface3 , class Interface4 , class Interface5 ,
+ class Interface6, class Interface7 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1 ,
+ const Interface2 *p2 ,
+ const Interface3 *p3 ,
+ const Interface4 *p4 ,
+ const Interface5 *p5 ,
+ const Interface6 *p6 ,
+ const Interface7 *p7
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(7);
+ seqInterface.getArray()[0] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[1] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[2] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[3] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[4] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[5] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[6] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+
+
+
+
+
+template < class Interface1, class Interface2, class Interface3 , class Interface4 , class Interface5 ,
+ class Interface6, class Interface7, class Interface8 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1 ,
+ const Interface2 *p2 ,
+ const Interface3 *p3 ,
+ const Interface4 *p4 ,
+ const Interface5 *p5 ,
+ const Interface6 *p6 ,
+ const Interface7 *p7 ,
+ const Interface8 *p8
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(8);
+ seqInterface.getArray()[0] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[1] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[2] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[3] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[4] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[5] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[6] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[7] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface8 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+
+
+
+template < class Interface1, class Interface2, class Interface3 , class Interface4 , class Interface5 ,
+ class Interface6, class Interface7, class Interface8 , class Interface9 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1 ,
+ const Interface2 *p2 ,
+ const Interface3 *p3 ,
+ const Interface4 *p4 ,
+ const Interface5 *p5 ,
+ const Interface6 *p6 ,
+ const Interface7 *p7 ,
+ const Interface8 *p8 ,
+ const Interface9 *p9
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(9);
+ seqInterface.getArray()[0] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[1] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[2] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[3] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[4] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[5] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[6] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[7] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface8 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[8] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface9 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+
+template < class Interface1, class Interface2, class Interface3 , class Interface4 , class Interface5 ,
+ class Interface6, class Interface7, class Interface8 , class Interface9 , class Interface10 >
+inline ::com::sun::star::reflection::XIdlClass * SAL_CALL
+//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass >
+createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr,
+ const ::rtl::OUString &sImplementationName ,
+ const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass ,
+ const Interface1 *p1 ,
+ const Interface2 *p2 ,
+ const Interface3 *p3 ,
+ const Interface4 *p4 ,
+ const Interface5 *p5 ,
+ const Interface6 *p6 ,
+ const Interface7 *p7 ,
+ const Interface8 *p8 ,
+ const Interface9 *p9 ,
+ const Interface10 *p10
+ )
+{
+ ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(10);
+ seqInterface.getArray()[0] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface1 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[1] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface2 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[2] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface3 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[3] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface4 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[4] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface5 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[5] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface6 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[6] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface7 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[7] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface8 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[8] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface9 > *) 0 ).getTypeName();
+
+ seqInterface.getArray()[9] =
+ ::getCppuType( (::com::sun::star::uno::Reference< Interface10 > *) 0 ).getTypeName();
+
+ return createStandardClassWithSequence(
+ rSMgr,
+ sImplementationName,
+ rSuperClass,
+ seqInterface
+ );
+}
+
+} // end namespace cppu
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/typeprovider.hxx b/cppuhelper/inc/cppuhelper/typeprovider.hxx
new file mode 100644
index 000000000000..b330363cd33f
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/typeprovider.hxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * $RCSfile: typeprovider.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#define _CPPUHELPER_TYPEPROVIDER_HXX_
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _RTL_UUID_H_
+#include <rtl/uuid.h>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+
+namespace cppu
+{
+
+//==================================================================================================
+class OTypeCollection
+{
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > _aTypes;
+
+public:
+ OTypeCollection( const OTypeCollection & rCollection )
+ : _aTypes( rCollection._aTypes )
+ {}
+
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Type & rType9,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Type & rType9,
+ const ::com::sun::star::uno::Type & rType10,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Type & rType9,
+ const ::com::sun::star::uno::Type & rType10,
+ const ::com::sun::star::uno::Type & rType11,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+ OTypeCollection(
+ const ::com::sun::star::uno::Type & rType1,
+ const ::com::sun::star::uno::Type & rType2,
+ const ::com::sun::star::uno::Type & rType3,
+ const ::com::sun::star::uno::Type & rType4,
+ const ::com::sun::star::uno::Type & rType5,
+ const ::com::sun::star::uno::Type & rType6,
+ const ::com::sun::star::uno::Type & rType7,
+ const ::com::sun::star::uno::Type & rType8,
+ const ::com::sun::star::uno::Type & rType9,
+ const ::com::sun::star::uno::Type & rType10,
+ const ::com::sun::star::uno::Type & rType11,
+ const ::com::sun::star::uno::Type & rType12,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ { return _aTypes; }
+};
+
+//==================================================================================================
+class OImplementationId
+{
+ mutable ::com::sun::star::uno::Sequence< sal_Int8 > * _pSeq;
+ sal_Bool _bUseEthernetAddress;
+
+public:
+ // these are here to force memory de/allocation to sal lib.
+ static void * SAL_CALL operator new( size_t nSize ) throw()
+ { return ::rtl_allocateMemory( nSize ); }
+ static void SAL_CALL operator delete( void * pMem ) throw()
+ { ::rtl_freeMemory( pMem ); }
+
+ ~OImplementationId();
+ OImplementationId( sal_Bool bUseEthernetAddress = sal_True )
+ : _pSeq( 0 )
+ , _bUseEthernetAddress( bUseEthernetAddress )
+ {}
+ OImplementationId( const ::com::sun::star::uno::Sequence< sal_Int8 > & rSeq )
+ : _pSeq( new ::com::sun::star::uno::Sequence< sal_Int8 >( rSeq ) )
+ {}
+ OImplementationId( const OImplementationId & rId )
+ : _pSeq( new ::com::sun::star::uno::Sequence< sal_Int8 >( rId.getImplementationId() ) )
+ {}
+
+ ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() const;
+};
+
+}
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/weak.hxx b/cppuhelper/inc/cppuhelper/weak.hxx
new file mode 100644
index 000000000000..a7886b725984
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/weak.hxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * $RCSfile: weak.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_WEAK_HXX_
+#define _CPPUHELPER_WEAK_HXX_
+
+#ifndef _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _CPPUHELPER_WEAKREF_HXX_
+#include <cppuhelper/weakref.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_WEAK_HPP_
+#include <com/sun/star/uno/XWeak.hpp>
+#endif
+
+/** */ //for docpp
+namespace cppu
+{
+
+class OWeakConnectionPoint;
+
+/**
+ * The basic implementation to support weak references. The weak
+ * implementation is based on interfaces, but you should use this base class to avoid
+ * problems against changes in the future.
+ * <BR><B>Not fully tested.</B>
+ *
+ * @author Markus Meyer
+ * @since 98/04/12
+ */
+class OWeakObject : public ::com::sun::star::uno::XWeak
+{
+ friend class OWeakConnectionPoint;
+protected:
+ /**
+ * Call the destructor is only allowed if the reference count is zero.
+ */
+ virtual ~OWeakObject() throw(::com::sun::star::uno::RuntimeException);
+
+ /**
+ * The reference counter.
+ */
+ oslInterlockedCount m_refCount;
+
+ /**
+ * The container of all weak reference listeners and the connection point
+ * from the weak reference. Increment the reference count at m_pWeakConnectionPoint
+ * object does not affect the
+ */
+ OWeakConnectionPoint * m_pWeakConnectionPoint;
+public:
+ // these are here to force memory de/allocation to sal lib.
+ static void * SAL_CALL operator new( size_t nSize ) throw()
+ { return ::rtl_allocateMemory( nSize ); }
+ static void SAL_CALL operator delete( void * pMem ) throw()
+ { ::rtl_freeMemory( pMem ); }
+
+ /**
+ * Set the reference count to zero.
+ */
+ OWeakObject() throw()
+ : m_refCount( 0 )
+ , m_pWeakConnectionPoint( 0 )
+ {}
+ /**
+ * Set the reference count to zero.
+ */
+ OWeakObject( const OWeakObject & rObj ) throw()
+ : m_refCount( 0 )
+ , m_pWeakConnectionPoint( 0 )
+ {}
+ /**
+ * The assignement does not affect the reference count and the weak references
+ * of this object.
+ */
+ inline OWeakObject & SAL_CALL operator = ( const OWeakObject & rObj) throw()
+ { return *this; }
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XWeak
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAdapter > SAL_CALL queryAdapter() throw();
+
+ /// Avoid ambigous cast error from compiler.
+ inline SAL_CALL operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () throw()
+ { return this; }
+};
+
+}
+
+#endif
+
+
diff --git a/cppuhelper/inc/cppuhelper/weakagg.hxx b/cppuhelper/inc/cppuhelper/weakagg.hxx
new file mode 100644
index 000000000000..4d87996a9f57
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/weakagg.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * $RCSfile: weakagg.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _CPPUHELPER_WEAKAGG_HXX_
+#define _CPPUHELPER_WEAKAGG_HXX_
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XAGGREGATION_HPP_
+#include <com/sun/star/uno/XAggregation.hpp>
+#endif
+
+/** */ //for docpp
+namespace cppu
+{
+
+/**
+ * The basic implementation to support weak references and aggregation. The aggregation
+ * implementation is based on interfaces, but you should use this class to avoid
+ * problems against changes in the future. Overload queryAggregation() instead of queryInterface()
+ * to return your interfaces.
+ * <BR><B>Not tested.</B>
+ *
+ * @author Markus Meyer
+ * @since 98/04/12
+ */
+class OWeakAggObject : public ::cppu::OWeakObject, public ::com::sun::star::uno::XAggregation
+{
+public:
+ /**
+ * Set the delegator to null.
+ */
+ OWeakAggObject()
+ {}
+
+ // XInterface
+ /**
+ * Increment the reference count if no delegator is set, otherwise call
+ * acquire at the delegator.
+ */
+ virtual void SAL_CALL acquire() throw();
+ /**
+ * Decrement the reference count if no delegator is set, otherwise call
+ * acquire at the delegator. If the reference count goes to zero the
+ * virtual destructor gets called.
+ */
+ virtual void SAL_CALL release() throw();
+ /**
+ * Delegates this call to the delegator, if one is set. Otherwise
+ * call the method queryAggregation.
+ * @see queryAggregation.
+ */
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XAggregation
+ /**
+ * Set the Delegator to the xDelegator member. This member is a weak
+ * reference.
+ * @param Delegator the object that delegate the queryInterface calls.
+ */
+ virtual void SAL_CALL setDelegator( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & Delegator )
+ throw(::com::sun::star::uno::RuntimeException);
+ /**
+ * Called from the delegator or queryInterface. Overload this method instead of
+ * queryInterface.
+ * @see queryInterfaces
+ */
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType )
+ throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+ /**
+ * Call the destructor is only allowed if the reference count is zero.
+ */
+ virtual ~OWeakAggObject();
+
+ /**
+ * The delegator set with setDelegator.
+ * @see setDelegator
+ */
+ ::com::sun::star::uno::WeakReferenceHelper xDelegator;
+private:
+ OWeakAggObject( const OWeakObject & rObj );
+
+ OWeakObject & operator = ( const OWeakObject & rObj );
+};
+
+}
+
+#endif
diff --git a/cppuhelper/inc/cppuhelper/weakref.hxx b/cppuhelper/inc/cppuhelper/weakref.hxx
new file mode 100644
index 000000000000..52eb59f5da70
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/weakref.hxx
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * $RCSfile: weakref.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:09 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_WEAKREF_HXX_
+#define _CPPUHELPER_WEAKREF_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
+#include <com/sun/star/uno/XInterface.hpp>
+#endif
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+class OWeakRefListener;
+
+//===================================================================
+/**
+ * Hold a weak reference to an object. This object must implement the XWeak interface.
+ * The implementation is thread safe. This means you can call set, assign and queryHardRef
+ * multible at one time.
+ *
+ * @see OWeakObject
+ * @see OWeakAggObject
+ * @author Markus Meyer
+ * @since 12/04/98
+ */
+class WeakReferenceHelper
+{
+public:
+ /** Create an empty weak reference. */
+ WeakReferenceHelper()
+ : m_pImpl( 0 )
+ {}
+
+ /** Initialize this reference with the same interface as in rWeakRef.*/
+ WeakReferenceHelper( const WeakReferenceHelper & rWeakRef );
+ /**
+ * Initialize this reference with the interface xInt. If the implementation behind
+ * xInt does not support XWeak or XInt is empty then this reference is empty too.
+ */
+ WeakReferenceHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt );
+ /**
+ * Release the reference.
+ */
+ ~WeakReferenceHelper();
+
+ /**
+ * Release the reference and take the from rWeakRef.
+ */
+ WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef );
+
+ /**
+ * Release the reference and take the from xInt. If the implementation behind
+ * xInt does not support XWeak or XInt is empty, than this reference is empty too.
+ */
+ WeakReferenceHelper & SAL_CALL operator = ( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt )
+ { return operator = ( WeakReferenceHelper( xInt ) ); }
+
+ /**
+ * Return true if both OWeakRefs refer to the same object.
+ */
+ sal_Bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const
+ { return (get() == rObj.get()); }
+
+ /**
+ * Get a real reference to the object.
+ * @return Null, if the interface was not found, otherwise the
+ * interface.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL get() const;
+
+ /**
+ * Return the reference to the interface. It is null, if the referenced object
+ * was destroyed or the weak reference was not set.
+ */
+ SAL_CALL operator Reference< XInterface > () const
+ { return get(); }
+
+protected:
+
+ OWeakRefListener * m_pImpl;
+};
+
+template< class interface_type >
+class WeakReference : public WeakReferenceHelper
+{
+public:
+ /** Set an empty weak reference. */
+ WeakReference()
+ : WeakReferenceHelper()
+ {}
+
+ /**
+ * Create a new weak reference with the given interface pInterface and acquire this one.
+ */
+ WeakReference( const Reference<interface_type > & rRef )
+ : WeakReferenceHelper( rRef )
+ {}
+
+ /**
+ * Return the reference to the interface. May be null.
+ */
+ SAL_CALL operator Reference< interface_type > () const
+ { return Reference< interface_type >::query( get() ); }
+};
+
+}
+}
+}
+}
+
+#endif
+
+
diff --git a/cppuhelper/prj/d.lst b/cppuhelper/prj/d.lst
new file mode 100644
index 000000000000..9f5ec8ad0afc
--- /dev/null
+++ b/cppuhelper/prj/d.lst
@@ -0,0 +1,57 @@
+mkdir: %_DEST%\inc%_EXT%\cppuhelper
+
+..\inc\cppuhelper\implbase.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase.hxx
+..\inc\cppuhelper\implbase1.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase1.hxx
+..\inc\cppuhelper\implbase2.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase2.hxx
+..\inc\cppuhelper\implbase3.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase3.hxx
+..\inc\cppuhelper\implbase4.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase4.hxx
+..\inc\cppuhelper\implbase5.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase5.hxx
+..\inc\cppuhelper\implbase6.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase6.hxx
+..\inc\cppuhelper\implbase7.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase7.hxx
+..\inc\cppuhelper\implbase8.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase8.hxx
+..\inc\cppuhelper\implbase9.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase9.hxx
+..\inc\cppuhelper\implbase10.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase10.hxx
+..\inc\cppuhelper\implbase11.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase11.hxx
+..\inc\cppuhelper\implbase12.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase12.hxx
+
+..\inc\cppuhelper\compbase.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase.hxx
+..\inc\cppuhelper\compbase1.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase1.hxx
+..\inc\cppuhelper\compbase2.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase2.hxx
+..\inc\cppuhelper\compbase3.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase3.hxx
+..\inc\cppuhelper\compbase4.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase4.hxx
+..\inc\cppuhelper\compbase5.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase5.hxx
+..\inc\cppuhelper\compbase6.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase6.hxx
+..\inc\cppuhelper\compbase7.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase7.hxx
+..\inc\cppuhelper\compbase8.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase8.hxx
+..\inc\cppuhelper\compbase9.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase9.hxx
+..\inc\cppuhelper\compbase10.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase10.hxx
+..\inc\cppuhelper\compbase11.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase11.hxx
+..\inc\cppuhelper\compbase12.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase12.hxx
+
+..\inc\cppuhelper\extract.hxx %_DEST%\inc%_EXT%\cppuhelper\extract.hxx
+..\inc\cppuhelper\exc_hlp.hxx %_DEST%\inc%_EXT%\cppuhelper\exc_hlp.hxx
+..\inc\cppuhelper\typeprovider.hxx %_DEST%\inc%_EXT%\cppuhelper\typeprovider.hxx
+..\inc\cppuhelper\factory.hxx %_DEST%\inc%_EXT%\cppuhelper\factory.hxx
+..\inc\cppuhelper\interfacecontainer.hxx %_DEST%\inc%_EXT%\cppuhelper\interfacecontainer.hxx
+..\inc\cppuhelper\interfacecontainer.h %_DEST%\inc%_EXT%\cppuhelper\interfacecontainer.h
+..\inc\cppuhelper\component.hxx %_DEST%\inc%_EXT%\cppuhelper\component.hxx
+..\inc\cppuhelper\propshlp.hxx %_DEST%\inc%_EXT%\cppuhelper\propshlp.hxx
+..\inc\cppuhelper\proptypehlp.hxx %_DEST%\inc%_EXT%\cppuhelper\proptypehlp.hxx
+..\inc\cppuhelper\proptypehlp.h %_DEST%\inc%_EXT%\cppuhelper\proptypehlp.h
+..\inc\cppuhelper\stdidlclass.hxx %_DEST%\inc%_EXT%\cppuhelper\stdidlclass.hxx
+..\inc\cppuhelper\weak.hxx %_DEST%\inc%_EXT%\cppuhelper\weak.hxx
+..\inc\cppuhelper\weakagg.hxx %_DEST%\inc%_EXT%\cppuhelper\weakagg.hxx
+..\inc\cppuhelper\queryinterface.hxx %_DEST%\inc%_EXT%\cppuhelper\queryinterface.hxx
+..\inc\cppuhelper\weakref.hxx %_DEST%\inc%_EXT%\cppuhelper\weakref.hxx
+..\inc\cppuhelper\servicefactory.hxx %_DEST%\inc%_EXT%\cppuhelper\servicefactory.hxx
+..\inc\cppuhelper\smartservices.hxx %_DEST%\inc%_EXT%\cppuhelper\smartservices.hxx
+
+..\%__SRC%\bin\cppuhelper*.dll %_DEST%\bin%_EXT%\cppuhelper*.dll
+..\%__SRC%\lib\*cppuhelper*.lib %_DEST%\lib%_EXT%\*
+
+..\%__SRC%\lib\libcppuhelper*.so %_DEST%\lib%_EXT%\*
+..\%__SRC%\lib\libcppuhelper*.dylib %_DEST%\lib%_EXT%\*
+..\%__SRC%\lib\libcppuhelper*.a %_DEST%\lib%_EXT%\*
+..\%__SRC%\lib\cppuhelper*.lib %_DEST%\lib%_EXT%\*
+..\%__SRC%\misc\cppuhelper*.pdb %_DEST%\misc%_EXT%\*
+..\version.mk %_DEST%\inc%_EXT%\cppuhelper\version.mk
diff --git a/cppuhelper/source/component.cxx b/cppuhelper/source/component.cxx
new file mode 100644
index 000000000000..1e21d6e7a554
--- /dev/null
+++ b/cppuhelper/source/component.cxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * $RCSfile: component.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::lang;
+
+namespace cppu
+{
+
+// ----------------------------------------------------
+// class OComponentHelper
+// ----------------------------------------------------
+OComponentHelper::OComponentHelper( Mutex & rMutex )
+ : rBHelper( rMutex )
+{
+}
+
+/**
+ * Call dispose if not previous called.
+ */
+OComponentHelper::~OComponentHelper()
+{
+}
+
+// XInterface
+void OComponentHelper::release() throw()
+{
+ Reference<XInterface > x( xDelegator );
+ if (! x.is())
+ {
+ if (osl_decrementInterlockedCount( &m_refCount ) == 0)
+ {
+ if (! rBHelper.bDisposed)
+ {
+ Reference<XInterface > xHoldAlive( *this );
+ // First dispose
+ try
+ {
+ dispose();
+ }
+ catch(::com::sun::star::uno::Exception&)
+ {
+ // release should not throw exceptions
+ }
+
+ // only the alive ref holds the object
+ OSL_ASSERT( m_refCount == 1 );
+ // destroy the object if xHoldAlive decrement the refcount to 0
+ return;
+ }
+ }
+ // restore the reference count
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+ OWeakAggObject::release();
+}
+
+// XComponent
+void OComponentHelper::disposing()
+{
+}
+
+// XComponent
+void OComponentHelper::dispose()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ // An frequently programming error is to release the last
+ // reference to this object in the disposing message.
+ // Make it rubust, hold a self Reference.
+ Reference<XComponent > xSelf( this );
+
+ // Guard dispose against multible threading
+ // Remark: It is an error to call dispose more than once
+ sal_Bool bDoDispose = sal_False;
+ {
+ MutexGuard aGuard( rBHelper.rMutex );
+ if( !rBHelper.bDisposed && !rBHelper.bInDispose )
+ {
+ // only one call go into this section
+ rBHelper.bInDispose = sal_True;
+ bDoDispose = sal_True;
+ }
+ }
+
+ OSL_ENSHURE( bDoDispose, "dispose called twice" );
+ // Do not hold the mutex because we are broadcasting
+ if( bDoDispose )
+ {
+ // Create an event with this as sender
+ try
+ {
+ Reference<XInterface > xSource( Reference<XInterface >::query( (XComponent *)this ) );
+ EventObject aEvt;
+ aEvt.Source = xSource;
+ // inform all listeners to release this object
+ // The listener container are automaticly cleared
+ rBHelper.aLC.disposeAndClear( aEvt );
+ // notify subclasses to do their dispose
+ disposing();
+ }
+ catch(::com::sun::star::uno::Exception& e)
+ {
+ // catch exception and throw again but signal that
+ // the object was disposed. Dispose should be called
+ // only once.
+ rBHelper.bDisposed = sal_True;
+ rBHelper.bInDispose = sal_False;
+ throw e;
+ }
+
+ // the values bDispose and bInDisposing must set in this order.
+ // No multithread call overcome the "!rBHelper.bDisposed && !rBHelper.bInDispose" guard.
+ rBHelper.bDisposed = sal_True;
+ rBHelper.bInDispose = sal_False;
+ }
+}
+
+// XComponent
+void OComponentHelper::addEventListener(const Reference<XEventListener > & rxListener)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bInDispose, "do not add listeners in the dispose call" );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+ // only add listeners if you are not disposed
+ rBHelper.aLC.addInterface( ::getCppuType( (Reference< XEventListener > *)0 ), rxListener );
+}
+
+// XComponent
+void OComponentHelper::removeEventListener(const Reference<XEventListener > & rxListener)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ // all listeners are automaticly released in a dispose call
+ if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+ rBHelper.aLC.removeInterface( ::getCppuType( (Reference< XEventListener > *)0 ), rxListener );
+}
+
+}
+
diff --git a/cppuhelper/source/exc_thrower.cxx b/cppuhelper/source/exc_thrower.cxx
new file mode 100644
index 000000000000..3fc8103d865e
--- /dev/null
+++ b/cppuhelper/source/exc_thrower.cxx
@@ -0,0 +1,287 @@
+/*************************************************************************
+ *
+ * $RCSfile: exc_thrower.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+using namespace com::sun::star::uno;
+using namespace rtl;
+
+
+namespace cppu
+{
+
+//************************************** generated, slightly modified for unicode revision
+class XThrower : public ::com::sun::star::uno::XInterface
+{
+public:
+
+ // Methods
+ virtual void SAL_CALL throwException( const ::com::sun::star::uno::Any& rExc ) throw(::com::sun::star::uno::Exception) = 0;
+};
+
+static
+const ::com::sun::star::uno::Type& getCppuType( const ::com::sun::star::uno::Reference< ::cppu::XThrower >* )
+{
+ static ::com::sun::star::uno::Type * pType_cppu_XThrower = 0;
+
+ if ( !pType_cppu_XThrower )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pType_cppu_XThrower )
+ {
+ // Start inline typedescription generation
+ typelib_InterfaceTypeDescription * pTD = 0;
+
+ const Type & rSuperType = ::getCppuType( ( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > *)0 );
+ typelib_TypeDescriptionReference * pMembers[1] = { 0 };
+ OUString aMemberTypeName( RTL_CONSTASCII_USTRINGPARAM("cppu.XThrower::throwException") );
+ typelib_typedescriptionreference_new( &pMembers[0],
+ (typelib_TypeClass)::com::sun::star::uno::TypeClass_INTERFACE_METHOD,
+ aMemberTypeName.pData );
+
+ OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("cppu.XThrower") );
+ typelib_typedescription_newInterface(
+ &pTD,
+ aTypeName.pData, 0x3313e220, 0xb491, 0xb491, 0x9ede0050, 0x04d7677e,
+ rSuperType.getTypeLibType(),
+ 1,
+ pMembers );
+
+ typelib_typedescription_register( (typelib_TypeDescription**)&pTD );
+ typelib_typedescriptionreference_release( pMembers[0] );
+ typelib_typedescription_release( (typelib_TypeDescription*)pTD );
+
+ static ::com::sun::star::uno::Type aType_cppu_XThrower(
+ ::com::sun::star::uno::TypeClass_INTERFACE, aTypeName.pData );
+ ::getCppuType( (const ::com::sun::star::uno::Exception*)0 );
+
+ typelib_InterfaceMethodTypeDescription * pMethod = 0;
+ {
+ typelib_Parameter_Init aParameters[1];
+ OUString aParamName( RTL_CONSTASCII_USTRINGPARAM("rExc") );
+ aParameters[0].pParamName = aParamName.pData;
+ aParameters[0].eTypeClass = (typelib_TypeClass)::com::sun::star::uno::TypeClass_ANY;
+ OUString aParamTypeName( RTL_CONSTASCII_USTRINGPARAM("any") );
+ aParameters[0].pTypeName = aParamTypeName.pData;
+ aParameters[0].bIn = sal_True;
+ aParameters[0].bOut = sal_False;
+ OUString aExceptionName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception") );
+ OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
+ typelib_typedescription_newInterfaceMethod( &pMethod,
+ 3, sal_False,
+ aMemberTypeName.pData,
+ (typelib_TypeClass)::com::sun::star::uno::TypeClass_VOID, aVoidName.pData,
+ 1, aParameters,
+ 1, &aExceptionName.pData );
+ typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );
+ }
+ typelib_typedescription_release( (typelib_TypeDescription*)pMethod );
+ // End inline typedescription generation
+ pType_cppu_XThrower = &aType_cppu_XThrower;
+ }
+ }
+ return *pType_cppu_XThrower;
+}
+//**************************************
+
+
+//==================================================================================================
+struct ExceptionThrower : public uno_Interface
+{
+ oslInterlockedCount nRef;
+
+ inline ExceptionThrower();
+};
+//--------------------------------------------------------------------------------------------------
+void SAL_CALL ExceptionThrower_acquire( uno_Interface * pUnoI )
+{
+ osl_incrementInterlockedCount( & SAL_STATIC_CAST( ExceptionThrower *, pUnoI )->nRef );
+}
+//--------------------------------------------------------------------------------------------------
+void SAL_CALL ExceptionThrower_release( uno_Interface * pUnoI )
+{
+ if (! osl_decrementInterlockedCount( & SAL_STATIC_CAST( ExceptionThrower *, pUnoI )->nRef ))
+ delete SAL_STATIC_CAST( ExceptionThrower *, pUnoI );
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL ExceptionThrower_dispatch(
+ uno_Interface * pUnoI, const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ OSL_ASSERT( pMemberType->eTypeClass == typelib_TypeClass_INTERFACE_METHOD );
+
+ switch (((typelib_InterfaceMemberTypeDescription *)pMemberType)->nPosition)
+ {
+ case 0: // queryInterace()
+ {
+ if (::getCppuType( (const Reference< XInterface > *)0 ).equals( *(const Type *)pArgs[0] ))
+ {
+ const Type & rType = ::getCppuType( (const Reference< XInterface > *)0 );
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, rType.getTypeLibType() );
+ uno_any_construct( (uno_Any *)pReturn, &pUnoI, pTD, 0 );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ else if (getCppuType( (const Reference< XThrower > *)0 ).equals( *(const Type *)pArgs[0] ))
+ {
+ const Type & rType = getCppuType( (const Reference< XThrower > *)0 );
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, rType.getTypeLibType() );
+ uno_any_construct( (uno_Any *)pReturn, &pUnoI, pTD, 0 );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ else
+ {
+ uno_any_construct( (uno_Any *)pReturn, 0, 0, 0 );
+ }
+ *ppException = 0;
+ break;
+ }
+ case 1: // acquire()
+ ExceptionThrower_acquire( pUnoI );
+ *ppException = 0;
+ break;
+ case 2: // release()
+ ExceptionThrower_release( pUnoI );
+ *ppException = 0;
+ break;
+ case 3: // throwException()
+ {
+ OSL_ASSERT( ((uno_Any *)pArgs[0])->pType->eTypeClass == typelib_TypeClass_EXCEPTION );
+
+ uno_type_any_construct(
+ *ppException, ((uno_Any *)pArgs[0])->pData, ((uno_Any *)pArgs[0])->pType, 0 );
+ break;
+ }
+ default:
+ OSL_ENSHURE( sal_False, "### illegal member called!" );
+ }
+}
+//__________________________________________________________________________________________________
+inline ExceptionThrower::ExceptionThrower()
+ : nRef( 0 )
+{
+ uno_Interface::acquire = ExceptionThrower_acquire;
+ uno_Interface::release = ExceptionThrower_release;
+ uno_Interface::pDispatcher = ExceptionThrower_dispatch;
+}
+
+//==================================================================================================
+void SAL_CALL throwException( const Any & rExc )
+ throw (Exception)
+{
+ if (rExc.getValueTypeClass() == TypeClass_EXCEPTION)
+ {
+ OUString aExceptionName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception") );
+ typelib_TypeDescription * pComp = 0;
+ TYPELIB_DANGER_GET( &pComp, rExc.getValueTypeRef() );
+ // must be derived from com.sun.star.uno.Exception
+ for ( typelib_CompoundTypeDescription * pTD = (typelib_CompoundTypeDescription *)pComp;
+ pTD; pTD = pTD->pBaseTypeDescription )
+ {
+ if (aExceptionName == ((typelib_TypeDescription *)pTD)->pTypeName)
+ {
+ Mapping aUno2Cpp( OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ) );
+ OSL_ENSHURE( aUno2Cpp.is(), "### cannot get uno to cpp mapping!" );
+ if (aUno2Cpp.is())
+ {
+ uno_Interface * pUnoI = new ExceptionThrower();
+ (*pUnoI->acquire)( pUnoI );
+ Reference< XThrower > xThrower;
+ aUno2Cpp.mapInterface(
+ reinterpret_cast< void ** >( &xThrower ),
+ pUnoI, ::cppu::getCppuType( (const Reference< XThrower > *)0 ) );
+ (*pUnoI->release)( pUnoI );
+
+ if (xThrower.is())
+ {
+ TYPELIB_DANGER_RELEASE( pComp );
+ xThrower->throwException( rExc );
+ }
+ }
+ break;
+ }
+ }
+ TYPELIB_DANGER_RELEASE( pComp );
+ }
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("failed throwing exception generically!") ),
+ Reference< XInterface >() );
+}
+
+}
diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx
new file mode 100644
index 000000000000..5271391d0beb
--- /dev/null
+++ b/cppuhelper/source/factory.cxx
@@ -0,0 +1,719 @@
+/*************************************************************************
+ *
+ * $RCSfile: factory.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/loader/XImplementationLoader.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+
+using namespace osl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::loader;
+using namespace com::sun::star::registry;
+
+namespace cppu
+{
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+class OSingleFactoryHelper
+ : public XServiceInfo
+ , public XSingleServiceFactory
+{
+public:
+ OSingleFactoryHelper( const Reference<XMultiServiceFactory > & rServiceManager,
+ const OUString & rImplementationName_,
+ ComponentInstantiation pCreateFunction_,
+ const Sequence< OUString > * pServiceNames_ )
+ : xSMgr( rServiceManager )
+ , aImplementationName( rImplementationName_ )
+ , pCreateFunction( pCreateFunction_ )
+ {
+ if( pServiceNames_ )
+ aServiceNames = *pServiceNames_;
+ }
+
+ // old function, only for backward compatibility
+ OSingleFactoryHelper( const Reference<XMultiServiceFactory > & rServiceManager,
+ const OUString & rImplementationName_ )
+ : xSMgr( rServiceManager )
+ , aImplementationName( rImplementationName_ )
+ , pCreateFunction( NULL )
+ {
+ }
+
+ // XInterface
+ Any SAL_CALL queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XSingleServiceFactory
+ Reference<XInterface > SAL_CALL createInstance(void)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
+ throw(::com::sun::star::uno::RuntimeException);
+ Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
+ throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+ /**
+ * Create an instance specified by the factory. The one instance logic is implemented
+ * in the createInstance and createInstanceWithArguments methods.
+ * @return the newly created instance. Do not return a previous (one instance) instance.
+ */
+ virtual Reference<XInterface > createInstanceEveryTime()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ Reference<XMultiServiceFactory > xSMgr;
+ ComponentInstantiation pCreateFunction;
+ Sequence< OUString > aServiceNames;
+ OUString aImplementationName;
+};
+
+//-----------------------------------------------------------------------------
+Any OSingleFactoryHelper::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::queryInterface(
+ rType, static_cast< XSingleServiceFactory * >( this ), static_cast< XServiceInfo * >( this ) );
+}
+
+// OSingleFactoryHelper
+Reference<XInterface > OSingleFactoryHelper::createInstanceEveryTime()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ if( pCreateFunction )
+ return pCreateFunction( xSMgr );
+ else
+ return Reference<XInterface >();
+}
+
+// XSingleServiceFactory
+Reference<XInterface > OSingleFactoryHelper::createInstance()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ return createInstanceEveryTime();
+}
+
+// XSingleServiceFactory
+Reference<XInterface > OSingleFactoryHelper::createInstanceWithArguments
+(
+ const Sequence<Any>& Arguments
+)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ Reference<XInterface > xRet = createInstanceEveryTime();
+
+ if( Arguments.getLength() )
+ {
+ Reference<XInitialization > xInit( xRet, UNO_QUERY );
+ if( xInit.is() )
+ xInit->initialize( Arguments );
+ else
+ throw IllegalArgumentException();
+ }
+ return xRet;
+}
+
+// XServiceInfo
+OUString OSingleFactoryHelper::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return aImplementationName;
+}
+
+// XServiceInfo
+sal_Bool OSingleFactoryHelper::supportsService(const OUString& ServiceName)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Sequence< OUString > seqServices = getSupportedServiceNames();
+ const OUString * pServices = seqServices.getConstArray();
+ for( sal_Int32 i = 0; i < seqServices.getLength(); i++ )
+ if( pServices[i] == ServiceName )
+ return sal_True;
+
+ return sal_False;
+}
+
+// XServiceInfo
+Sequence< OUString > OSingleFactoryHelper::getSupportedServiceNames(void)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return aServiceNames;
+}
+
+
+//----------------------------------------------------------------------
+//----------------------------------------------------------------------
+//----------------------------------------------------------------------
+struct OFactoryComponentHelper_Mutex
+{
+ Mutex aMutex;
+};
+
+class OFactoryComponentHelper
+ : public OFactoryComponentHelper_Mutex
+ , public OComponentHelper
+ , public OSingleFactoryHelper
+{
+public:
+ OFactoryComponentHelper( const Reference<XMultiServiceFactory > & rServiceManager,
+ const OUString & rImplementationName_,
+ ComponentInstantiation pCreateFunction_,
+ const Sequence< OUString > * pServiceNames_,
+ sal_Bool bOneInstance_ = sal_False )
+ : OComponentHelper( aMutex )
+ , OSingleFactoryHelper( rServiceManager, rImplementationName_, pCreateFunction_, pServiceNames_ )
+ , bOneInstance( bOneInstance_ )
+ {
+ }
+
+ // old function, only for backward compatibility
+ OFactoryComponentHelper( const Reference<XMultiServiceFactory > & rServiceManager,
+ const OUString & rImplementationName_,
+ sal_Bool bOneInstance_ = sal_False )
+ : OComponentHelper( aMutex )
+ , OSingleFactoryHelper( rServiceManager, rImplementationName_ )
+ , bOneInstance( bOneInstance_ )
+ {
+ }
+
+ // XInterface
+ Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+ { return OComponentHelper::queryInterface( rType ); }
+ void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException)
+ { OComponentHelper::acquire(); }
+ void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException)
+ { OComponentHelper::release(); }
+
+ // XSingleServiceFactory
+ Reference<XInterface > SAL_CALL createInstance()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ Reference<XInterface > SAL_CALL createInstanceWithArguments( const Sequence<Any>& Arguments )
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+ // XAggregation
+ Any SAL_CALL queryAggregation( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+
+private:
+ Reference<XInterface > xTheInstance;
+ sal_Bool bOneInstance;
+};
+
+// XAggregation
+Any OFactoryComponentHelper::queryAggregation( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( OComponentHelper::queryAggregation( rType ) );
+ return (aRet.hasValue() ? aRet : OSingleFactoryHelper::queryInterface( rType ));
+}
+
+// XTypeProvider
+Sequence< Type > OFactoryComponentHelper::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * pTypes = 0;
+ if (! pTypes)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pTypes)
+ {
+ static OTypeCollection aTypes(
+ ::getCppuType( (const Reference< XSingleServiceFactory > *)0 ),
+ ::getCppuType( (const Reference< XServiceInfo > *)0 ),
+ OComponentHelper::getTypes() );
+ pTypes = &aTypes;
+ }
+ }
+ return pTypes->getTypes();
+}
+Sequence< sal_Int8 > OFactoryComponentHelper::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// XSingleServiceFactory
+Reference<XInterface > OFactoryComponentHelper::createInstance()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ if( bOneInstance )
+ {
+ MutexGuard aGuard( aMutex );
+ if( !xTheInstance.is() )
+ xTheInstance = OSingleFactoryHelper::createInstance();
+ return xTheInstance;
+ }
+ return OSingleFactoryHelper::createInstance();
+}
+
+Reference<XInterface > OFactoryComponentHelper::createInstanceWithArguments(
+ const Sequence<Any>& Arguments )
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ if( bOneInstance )
+ {
+ MutexGuard aGuard( aMutex );
+ if( !xTheInstance.is() )
+ xTheInstance = OSingleFactoryHelper::createInstanceWithArguments( Arguments );
+ return xTheInstance;
+ }
+ return OSingleFactoryHelper::createInstanceWithArguments( Arguments );
+}
+
+// OComponentHelper
+void OFactoryComponentHelper::dispose()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ OComponentHelper::dispose();
+
+ Reference<XInterface > x;
+ {
+ // do not delete in the guard section
+ MutexGuard aGuard( aMutex );
+ x = xTheInstance;
+ xTheInstance = Reference<XInterface >();
+ }
+ // if it is a component call dispose at the component
+ Reference<XComponent > xComp( x, UNO_QUERY );
+ if( xComp.is() )
+ xComp->dispose();
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+class ORegistryFactoryHelper
+ : public OFactoryComponentHelper
+{
+public:
+ ORegistryFactoryHelper( const Reference<XMultiServiceFactory > & rServiceManager,
+ const OUString & rImplementationName_,
+ const Reference<XRegistryKey > & xImplementationKey_,
+ sal_Bool bOneInstance_ = sal_False )
+ : OFactoryComponentHelper( rServiceManager, rImplementationName_, 0, 0, bOneInstance_ )
+ , xImplementationKey( xImplementationKey_ )
+ {}
+
+ // OSingleFactoryHelper
+ Reference<XInterface > createInstanceEveryTime()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XSingleServiceFactory
+ Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
+ throw(::com::sun::star::uno::RuntimeException);
+
+private:
+ Reference< XSingleServiceFactory > createModuleFactory()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ /** The registry key of the implementation section */
+ Reference<XRegistryKey > xImplementationKey;
+ /** The factory created with the loader. */
+ Reference<XSingleServiceFactory > xModuleFactory;
+};
+
+Reference<XInterface > ORegistryFactoryHelper::createInstanceEveryTime()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ if( pCreateFunction )
+ // the create function is set, do not use the implementation loader.
+ return OFactoryComponentHelper::createInstanceEveryTime();
+
+ if( !xModuleFactory.is() )
+ xModuleFactory = createModuleFactory();
+
+ if( xModuleFactory.is() )
+ return xModuleFactory->createInstance();
+
+ return Reference<XInterface >();
+}
+
+// OSingleFactoryHelper
+Reference< XSingleServiceFactory > ORegistryFactoryHelper::createModuleFactory()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ Reference<XSingleServiceFactory > xFactory;
+ try
+ {
+ MutexGuard aGuard( aMutex );
+
+ OUString aActivatorUrl;
+ OUString aActivatorName;
+ OUString aLocation;
+
+ Reference<XRegistryKey > xActivatorKey = xImplementationKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") ) );
+ if( xActivatorKey.is() && xActivatorKey->getValueType() == RegistryValueType_ASCII )
+ {
+ aActivatorUrl = xActivatorKey->getAsciiValue();
+
+ OUString tmpActivator(aActivatorUrl.getStr());
+ aActivatorName = tmpActivator.getToken(0, L':').getStr();
+
+ Reference<XRegistryKey > xLocationKey = xImplementationKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/LOCATION") ) );
+ if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII )
+ aLocation = xLocationKey->getAsciiValue();
+ }
+ else
+ {
+ // old style"url"
+ // the location of the program code of the implementation
+ Reference<XRegistryKey > xLocationKey = xImplementationKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/URL") ) );
+ // is the the key of the right type ?
+ if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII )
+ {
+ // one implementation found -> try to activate
+ aLocation = xLocationKey->getAsciiValue();
+
+ // search protocol delemitter
+ sal_Int32 nPos = aLocation.search(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("://") ) );
+ if( nPos != -1 )
+ {
+ aActivatorName = aLocation.copy( 0, nPos );
+ if( aActivatorName.compareToAscii( "java" ) == 0 )
+ aActivatorName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.Java") );
+ else if( aActivatorName.compareToAscii( "module" ) == 0 )
+ aActivatorName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary") );
+ aLocation = aLocation.copy( nPos + 3 );
+ }
+ }
+ }
+
+ if( aActivatorName.len() != 0 )
+ {
+ Reference<XInterface > x = xSMgr->createInstance( aActivatorName );
+ Reference<XImplementationLoader > xLoader( x, UNO_QUERY );
+ Reference<XInterface > xMF;
+ if (xLoader.is())
+ {
+ // JSC: This exception must not be catched if a concept for exception handling
+ // is specified, implemented and used.
+ try
+ {
+ xMF = xLoader->activate( aImplementationName, aActivatorUrl, aLocation, xImplementationKey );
+ }
+ catch( CannotActivateFactoryException& e)
+ {
+ OString msg( OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US) );
+ OSL_ENSHURE( !msg.getLength(), msg.getStr() );
+ }
+ }
+ xFactory = Reference<XSingleServiceFactory >( xMF, UNO_QUERY );
+ }
+ }
+ catch (InvalidRegistryException &)
+ {
+ }
+
+ return xFactory;
+}
+
+Reference<XInterface > SAL_CALL ORegistryFactoryHelper::createInstanceWithArguments(const Sequence<Any>& Arguments)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ if( !xModuleFactory.is() )
+ xModuleFactory = createModuleFactory();
+
+ if( xModuleFactory.is() )
+ return xModuleFactory->createInstanceWithArguments( Arguments );
+
+ return Reference<XInterface >();
+}
+
+// XServiceInfo
+Sequence< OUString > ORegistryFactoryHelper::getSupportedServiceNames(void)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( aMutex );
+ if( aServiceNames.getLength() == 0 )
+ {
+ // not yet loaded
+ try
+ {
+ Reference<XRegistryKey > xKey = xImplementationKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("UNO/SERVICES") ) );
+
+ if (xKey.is())
+ {
+ // length of prefix. +1 for the '/' at the end
+ sal_Int32 nPrefixLen = xKey->getKeyName().len() + 1;
+
+ // Full qualified names like "IMPLEMENTATIONS/TEST/UNO/SERVICES/com.sun.star..."
+ Sequence<OUString> seqKeys = xKey->getKeyNames();
+ OUString* pKeys = seqKeys.getArray();
+ for( sal_Int32 i = 0; i < seqKeys.getLength(); i++ )
+ pKeys[i] = pKeys[i].copy(nPrefixLen);
+
+ aServiceNames = seqKeys;
+ }
+ }
+ catch (InvalidRegistryException &)
+ {
+ }
+ }
+ return aServiceNames;
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+
+class OFactoryProxyHelper : public WeakImplHelper2< XServiceInfo, XSingleServiceFactory >
+{
+ Reference<XSingleServiceFactory > xFactory;
+
+public:
+
+ OFactoryProxyHelper( const Reference<XMultiServiceFactory > & /*rServiceManager*/,
+ const Reference<XSingleServiceFactory > & rFactory )
+ : xFactory( rFactory )
+ {}
+
+ // XSingleServiceFactory
+ Reference<XInterface > SAL_CALL createInstance()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
+ throw(::com::sun::star::uno::RuntimeException);
+ Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+// XSingleServiceFactory
+Reference<XInterface > OFactoryProxyHelper::createInstance()
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ return xFactory->createInstance();
+}
+
+// XSingleServiceFactory
+Reference<XInterface > OFactoryProxyHelper::createInstanceWithArguments
+(
+ const Sequence<Any>& Arguments
+)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ return xFactory->createInstanceWithArguments( Arguments );
+}
+
+// XServiceInfo
+OUString OFactoryProxyHelper::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY );
+ if( xInfo.is() )
+ return xInfo->getImplementationName();
+ return OUString();
+}
+
+// XServiceInfo
+sal_Bool OFactoryProxyHelper::supportsService(const OUString& ServiceName)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY );
+ if( xInfo.is() )
+ return xInfo->supportsService( ServiceName );
+ return sal_False;
+}
+
+// XServiceInfo
+Sequence< OUString > OFactoryProxyHelper::getSupportedServiceNames(void)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY );
+ if( xInfo.is() )
+ return xInfo->getSupportedServiceNames();
+ return Sequence< OUString >();
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+// global function
+Reference<XSingleServiceFactory > SAL_CALL createSingleFactory
+(
+ const Reference<XMultiServiceFactory > & rServiceManager,
+ const OUString & rImplementationName,
+ ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames
+)
+{
+ return new OFactoryComponentHelper( rServiceManager, rImplementationName,
+ pCreateFunction, &rServiceNames, sal_False );
+}
+
+// global function
+Reference<XSingleServiceFactory > SAL_CALL createFactoryProxy
+(
+ const Reference<XMultiServiceFactory > & rServiceManager,
+ const Reference<XSingleServiceFactory > & rFactory
+)
+{
+ return new OFactoryProxyHelper( rServiceManager, rFactory );
+}
+
+// global function
+Reference<XSingleServiceFactory > SAL_CALL createOneInstanceFactory
+(
+ const Reference<XMultiServiceFactory > & rServiceManager,
+ const OUString & rImplementationName,
+ ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames
+)
+{
+ return new OFactoryComponentHelper( rServiceManager, rImplementationName,
+ pCreateFunction, &rServiceNames, sal_True );
+}
+
+// global function
+SAL_DLLEXPORT Reference<XSingleServiceFactory > SAL_CALL createSingleRegistryFactory
+(
+ const Reference<XMultiServiceFactory > & rServiceManager,
+ const OUString & rImplementationName,
+ const Reference<XRegistryKey > & rImplementationKey
+)
+{
+ return new ORegistryFactoryHelper( rServiceManager, rImplementationName,
+ rImplementationKey, sal_False );
+}
+
+// global function
+Reference<XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory
+(
+ const Reference<XMultiServiceFactory > & rServiceManager,
+ const OUString & rImplementationName,
+ const Reference<XRegistryKey > & rImplementationKey
+)
+{
+ return new ORegistryFactoryHelper( rServiceManager, rImplementationName,
+ rImplementationKey, sal_True );
+}
+
+}
+
+
diff --git a/cppuhelper/source/implbase.cxx b/cppuhelper/source/implbase.cxx
new file mode 100644
index 000000000000..a01c12fde4e0
--- /dev/null
+++ b/cppuhelper/source/implbase.cxx
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * $RCSfile: implbase.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_IMPLBASE_HXX_
+#include <cppuhelper/implbase.hxx>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _RTL_UUID_H_
+#include <rtl/uuid.h>
+#endif
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+using namespace osl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+
+namespace cppu
+{
+
+// ClassDataBase
+//__________________________________________________________________________________________________
+ClassDataBase::ClassDataBase()
+ : bOffsetsInit( sal_False )
+ , nType2Offset( 0 )
+ , nClassCode( 0 )
+ , pTypes( 0 )
+ , pId( 0 )
+{
+}
+//__________________________________________________________________________________________________
+ClassDataBase::ClassDataBase( sal_Int32 nClassCode_ )
+ : bOffsetsInit( sal_False )
+ , nType2Offset( 0 )
+ , nClassCode( nClassCode_ )
+ , pTypes( 0 )
+ , pId( 0 )
+{
+}
+//__________________________________________________________________________________________________
+ClassDataBase::~ClassDataBase()
+{
+ delete pTypes;
+ delete pId;
+
+ for ( sal_Int32 nPos = nType2Offset; nPos--; )
+ {
+ typelib_typedescription_release(
+ (typelib_TypeDescription *)((ClassData *)this)->arType2Offset[nPos].pTD );
+ }
+}
+
+// ClassData
+//__________________________________________________________________________________________________
+void ClassData::writeTypeOffset( const Type & rType, sal_Int32 nOffset )
+{
+ arType2Offset[nType2Offset].nOffset = nOffset;
+
+ arType2Offset[nType2Offset].pTD = 0;
+ typelib_typedescriptionreference_getDescription(
+ (typelib_TypeDescription **)&arType2Offset[nType2Offset].pTD, rType.getTypeLibType() );
+
+ if (arType2Offset[nType2Offset].pTD)
+ ++nType2Offset;
+#ifdef DEBUG
+ else
+ {
+ OString msg( "### cannot get type description for " );
+ msg += OUStringToOString( rType.getTypeName(), RTL_TEXTENCODING_ASCII_US );
+ OSL_ENSHURE( sal_False, msg.getStr() );
+ }
+#endif
+}
+//__________________________________________________________________________________________________
+void ClassData::initTypeProvider()
+{
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pTypes)
+ {
+ // create id
+ pId = new Sequence< sal_Int8 >( 16 );
+ rtl_createUuid( (sal_uInt8 *)pId->getArray(), 0, sal_True );
+
+ // collect types
+ Sequence< Type > * types = new Sequence< Type >(
+ nType2Offset + 1 + (nClassCode == 4 ? 2 : nClassCode) );
+ Type * pTypeAr = types->getArray();
+
+ // given types
+ sal_Int32 nPos = nType2Offset;
+ while (nPos--)
+ pTypeAr[nPos] = ((typelib_TypeDescription *)arType2Offset[nPos].pTD)->pWeakRef;
+
+ // XTypeProvider
+ pTypeAr[nType2Offset] = ::getCppuType( (const Reference< XTypeProvider > *)0 );
+
+ // class code extra types: [[XComponent,] XWeak[, XAggregation]]
+ switch (nClassCode)
+ {
+ case 4:
+ pTypeAr[nType2Offset +2] = ::getCppuType( (const Reference< XComponent > *)0 );
+ pTypeAr[nType2Offset +1] = ::getCppuType( (const Reference< XWeak > *)0 );
+ break;
+ case 3:
+ pTypeAr[nType2Offset +3] = ::getCppuType( (const Reference< XComponent > *)0 );
+ case 2:
+ pTypeAr[nType2Offset +2] = ::getCppuType( (const Reference< XAggregation > *)0 );
+ case 1:
+ pTypeAr[nType2Offset +1] = ::getCppuType( (const Reference< XWeak > *)0 );
+ }
+
+ pTypes = types;
+ }
+}
+//__________________________________________________________________________________________________
+Sequence< Type > ClassData::getTypes()
+{
+ if (! pTypes)
+ initTypeProvider();
+ return *pTypes;
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int8 > ClassData::getImplementationId()
+{
+ if (! pTypes)
+ initTypeProvider();
+ return *pId;
+}
+
+//--------------------------------------------------------------------------------------------------
+static inline sal_Bool td_equals( typelib_TypeDescription * pTD,
+ typelib_TypeDescriptionReference * pType )
+{
+ return (pTD->pWeakRef == pType ||
+ (pTD->pTypeName->length == pType->pTypeName->length &&
+ rtl_ustr_compare( pTD->pTypeName->buffer, pType->pTypeName->buffer ) == 0));
+}
+//__________________________________________________________________________________________________
+Any ClassData::query( const Type & rType, XTypeProvider * pBase )
+{
+ if (rType == ::getCppuType( (const Reference< XInterface > *)0 ))
+ return Any( &pBase, ::getCppuType( (const Reference< XInterface > *)0 ) );
+ for ( sal_Int32 nPos = 0; nPos < nType2Offset; ++nPos )
+ {
+ const Type_Offset & rTO = arType2Offset[nPos];
+ typelib_InterfaceTypeDescription * pTD = rTO.pTD;
+ while (pTD)
+ {
+ if (td_equals( (typelib_TypeDescription *)pTD,
+ *(typelib_TypeDescriptionReference **)&rType ))
+ {
+ void * pInterface = (char *)pBase + rTO.nOffset;
+ return Any( &pInterface, (typelib_TypeDescription *)pTD );
+ }
+ pTD = pTD->pBaseTypeDescription;
+ }
+ }
+ if (rType == ::getCppuType( (const Reference< XTypeProvider > *)0 ))
+ return Any( &pBase, ::getCppuType( (const Reference< XTypeProvider > *)0 ) );
+
+ return Any();
+}
+
+}
+
diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx
new file mode 100644
index 000000000000..baf0d696249a
--- /dev/null
+++ b/cppuhelper/source/interfacecontainer.cxx
@@ -0,0 +1,383 @@
+/*************************************************************************
+ *
+ * $RCSfile: interfacecontainer.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/queryinterface.hxx>
+
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+
+#include <hash_map>
+
+#include <assert.h>
+
+#include <com/sun/star/lang/XEventListener.hpp>
+
+
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+
+namespace cppu
+{
+
+//===================================================================
+//===================================================================
+//===================================================================
+/**
+ * Reallocate the sequence.
+ */
+static void realloc( Sequence< Reference< XInterface > > & rSeq, sal_Int32 nNewLen )
+{
+ Sequence< Reference< XInterface > > aNewSeq( nNewLen );
+ Reference< XInterface > * pDest = aNewSeq.getArray();
+ // getArray on a const sequence is faster
+ const Reference< XInterface > * pSource = ((const Sequence< Reference< XInterface > > &)rSeq).getConstArray();
+ for( sal_Int32 i = (nNewLen < rSeq.getLength() ? nNewLen : rSeq.getLength()) -1; i >= 0; i-- )
+ pDest[i] = pSource[i];
+ rSeq = aNewSeq;
+}
+
+/**
+ * Remove an element from an interface sequence.
+ */
+static void sequenceRemoveElementAt( Sequence< Reference< XInterface > > & rSeq, sal_Int32 index )
+{
+ sal_Int32 nNewLen = rSeq.getLength() - 1;
+
+ Sequence< Reference< XInterface > > aDestSeq( rSeq.getLength() - 1 );
+ // getArray on a const sequence is faster
+ const Reference< XInterface > * pSource = ((const Sequence< Reference< XInterface > > &)rSeq).getConstArray();
+ Reference< XInterface > * pDest = aDestSeq.getArray();
+ sal_Int32 i = 0;
+ for( ; i < index; i++ )
+ pDest[i] = pSource[i];
+ for( sal_Int32 j = i ; j < nNewLen; j++ )
+ pDest[j] = pSource[j+1];
+ rSeq = aDestSeq;
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+#ifdef SAL_WNT
+#pragma warning( disable: 4786 )
+#endif
+
+//===================================================================
+//===================================================================
+//===================================================================
+OInterfaceIteratorHelper::OInterfaceIteratorHelper( OInterfaceContainerHelper & rCont_ )
+ : rCont( rCont_ )
+{
+ MutexGuard aGuard( rCont.rMutex );
+ if( rCont.bInUse )
+ // worst case, two iterators at the same time
+ rCont.copyAndResetInUse();
+ bIsList = rCont_.bIsList;
+ pData = rCont_.pData;
+ if( bIsList )
+ {
+ rCont.bInUse = sal_True;
+ nRemain = ((Sequence< Reference< XInterface > >*)pData)->getLength();
+ }
+ else if( pData )
+ {
+ ((XInterface *)pData)->acquire();
+ nRemain = 1;
+ }
+ else
+ nRemain = 0;
+}
+
+OInterfaceIteratorHelper::~OInterfaceIteratorHelper()
+{
+ sal_Bool bShared;
+ {
+ MutexGuard aGuard( rCont.rMutex );
+ // bResetInUse protect the iterator against recursion
+ bShared = pData == rCont.pData && rCont.bIsList;
+ if( bShared )
+ {
+ OSL_ENSHURE( rCont.bInUse, "OInterfaceContainerHelper must be in use" );
+ rCont.bInUse = sal_False;
+ }
+ }
+
+ if( !bShared )
+ {
+ if( bIsList )
+ // Sequence owned by the iterator
+ delete (Sequence< Reference< XInterface > >*)pData;
+ else if( pData )
+ // Interface is acquired by the iterator
+ ((XInterface*)pData)->release();
+ }
+}
+
+XInterface * OInterfaceIteratorHelper::next()
+{
+ if( nRemain )
+ {
+ nRemain--;
+ if( bIsList )
+ // typecase to const,so the getArray method is faster
+ return ((const Sequence< Reference< XInterface > >*)pData)->getConstArray()[nRemain].get();
+ else if( pData )
+ return (XInterface*)pData;
+ }
+ // exception
+ return 0;
+}
+
+//===================================================================
+//===================================================================
+//===================================================================
+
+
+OInterfaceContainerHelper::OInterfaceContainerHelper( Mutex & rMutex_ )
+ : rMutex( rMutex_ )
+ , bInUse( sal_False )
+ , bIsList( sal_False )
+ , pData( 0 )
+{
+}
+
+OInterfaceContainerHelper::~OInterfaceContainerHelper()
+{
+ OSL_ENSHURE( !bInUse, "~OInterfaceContainerHelper but is in use" );
+ if( bIsList )
+ delete (Sequence< Reference< XInterface > >*)pData;
+ else if( pData )
+ ((XInterface*)pData)->release();
+}
+
+sal_Int32 OInterfaceContainerHelper::getLength() const
+{
+ MutexGuard aGuard( rMutex );
+ if( bIsList )
+ return ((Sequence< Reference< XInterface > >*)pData)->getLength();
+ else if( pData )
+ return 1;
+ return 0;
+}
+
+Sequence< Reference<XInterface> > OInterfaceContainerHelper::getElements() const
+{
+ MutexGuard aGuard( rMutex );
+ if( bIsList )
+ return *(Sequence< Reference< XInterface > >*)pData;
+ else if( pData )
+ {
+ Reference<XInterface> x( (XInterface *)pData );
+ return Sequence< Reference< XInterface > >( &x, 1 );
+ }
+ return Sequence< Reference< XInterface > >();
+}
+
+void OInterfaceContainerHelper::copyAndResetInUse()
+{
+ OSL_ENSHURE( bInUse, "OInterfaceContainerHelper not in use" );
+ if( bInUse )
+ {
+ // this should be the worst case. If a iterator is active
+ // and a new Listener is added.
+ if( bIsList )
+ pData = new Sequence< Reference< XInterface > >( *(Sequence< Reference< XInterface > >*)pData );
+ else if( pData )
+ ((XInterface*)pData)->acquire();
+
+ bInUse = sal_False;
+ }
+}
+
+sal_Int32 OInterfaceContainerHelper::addInterface( const Reference<XInterface> & rListener )
+{
+ assert( rListener.is() );
+ MutexGuard aGuard( rMutex );
+ if( bInUse )
+ copyAndResetInUse();
+
+ if( bIsList )
+ {
+ sal_Int32 nLen = ((Sequence< Reference< XInterface > >*)pData)->getLength();
+ realloc( *(Sequence< Reference< XInterface > >*)pData, nLen +1 );
+ ((Sequence< Reference< XInterface > >*)pData)->getArray()[ nLen ] = rListener;
+ return nLen +1;
+ }
+ else if( pData )
+ {
+ Sequence< Reference< XInterface > > * pSeq = new Sequence< Reference< XInterface > >( 2 );
+ Reference<XInterface> * pArray = pSeq->getArray();
+ pArray[0] = (XInterface *)pData;
+ pArray[1] = rListener;
+ ((XInterface *)pData)->release();
+ pData = pSeq;
+ bIsList = sal_True;
+ return 2;
+ }
+ else
+ {
+ pData = rListener.get();
+ if( rListener.is() )
+ rListener->acquire();
+ return 1;
+ }
+}
+
+sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference<XInterface> & rListener )
+{
+ assert( rListener.is() );
+ MutexGuard aGuard( rMutex );
+ if( bInUse )
+ copyAndResetInUse();
+
+ if( bIsList )
+ {
+ const Reference<XInterface> * pL = ((const Sequence< Reference< XInterface > >*)pData)->getConstArray();
+ sal_Int32 nLen = ((Sequence< Reference< XInterface > >*)pData)->getLength();
+ sal_Int32 i;
+ for( i = 0; i < nLen; i++ )
+ {
+ // It is not valid to compare the Pointer direkt, but is is is much
+ // more faster.
+ if( pL[i].get() == rListener.get() )
+ {
+ sequenceRemoveElementAt( *(Sequence< Reference< XInterface > >*)pData, i );
+ break;
+ }
+ }
+
+ if( i == nLen )
+ {
+ // interface not found, use the correct compare method
+ for( i = 0; i < nLen; i++ )
+ {
+ if( pL[i] == rListener )
+ {
+ sequenceRemoveElementAt(*(Sequence< Reference< XInterface > >*)pData, i );
+ break;
+ }
+ }
+ }
+
+ if( ((Sequence< Reference< XInterface > >*)pData)->getLength() == 1 )
+ {
+ XInterface * pL = ((const Sequence< Reference< XInterface > >*)pData)->getConstArray()[0].get();
+ pL->acquire();
+ delete (Sequence< Reference< XInterface > >*)pData;
+ pData = pL;
+ bIsList = sal_False;
+ return 1;
+ }
+ else
+ return ((Sequence< Reference< XInterface > >*)pData)->getLength();
+ }
+ else if( Reference<XInterface>( (XInterface*)pData ) == rListener )
+ {
+ ((XInterface *)pData)->release();
+ pData = 0;
+ }
+ return pData ? 1 : 0;
+}
+
+void OInterfaceContainerHelper::disposeAndClear( const EventObject & rEvt )
+{
+ ClearableMutexGuard aGuard( rMutex );
+ OInterfaceIteratorHelper aIt( *this );
+ // Container freigeben, falls im disposing neue Einträge kommen
+ OSL_ENSHURE( !bIsList || bInUse, "OInterfaceContainerHelper not in use" );
+ if( !bIsList && pData )
+ ((XInterface *)pData)->release();
+ // set the member to null, the iterator delete the values
+ pData = NULL;
+ bIsList = sal_False;
+ bInUse = sal_False;
+ aGuard.clear();
+ while( aIt.hasMoreElements() )
+ {
+ Reference<XEventListener > xLst( aIt.next(), UNO_QUERY );
+ if( xLst.is() )
+ xLst->disposing( rEvt );
+ }
+}
+
+
+void OInterfaceContainerHelper::clear( )
+{
+ ClearableMutexGuard aGuard( rMutex );
+ OInterfaceIteratorHelper aIt( *this );
+ // Container freigeben, falls im disposing neue Einträge kommen
+ OSL_ENSHURE( !bIsList || bInUse, "OInterfaceContainerHelper not in use" );
+ if( !bIsList && pData )
+ ((XInterface *)pData)->release();
+ // set the member to null, the iterator delete the values
+ pData = 0;
+ bIsList = sal_False;
+ bInUse = sal_False;
+ // release mutex before aIt destructor call
+ aGuard.clear();
+}
+
+
+}
+
diff --git a/cppuhelper/source/makefile.mk b/cppuhelper/source/makefile.mk
new file mode 100644
index 000000000000..08c617b3fbf0
--- /dev/null
+++ b/cppuhelper/source/makefile.mk
@@ -0,0 +1,167 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME= cppuhelper
+TARGET= cppuhelper
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+USE_DEFFILE= TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+.INCLUDE : ..$/version.mk
+
+# --- Files --------------------------------------------------------
+
+UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb
+UNOUCROUT= $(OUT)$/inc
+INCPRE+= $(OUT)$/inc
+
+CPPUMAKERFLAGS =
+
+UNOTYPES= \
+ com.sun.star.registry.XSimpleRegistry \
+ com.sun.star.registry.XImplementationRegistration \
+ com.sun.star.container.XSet \
+ com.sun.star.uno.XWeak \
+ com.sun.star.uno.XAggregation \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.lang.XServiceInfo \
+ com.sun.star.lang.XInitialization \
+ com.sun.star.reflection.XIdlReflection \
+ com.sun.star.reflection.XIdlClass \
+ com.sun.star.reflection.XIdlClassProvider \
+ com.sun.star.beans.XPropertySet \
+ com.sun.star.beans.XMultiPropertySet \
+ com.sun.star.beans.XFastPropertySet \
+ com.sun.star.beans.PropertyAttribute \
+ com.sun.star.registry.XRegistryKey \
+ com.sun.star.loader.XImplementationLoader \
+ com.sun.star.lang.XTypeProvider \
+ com.sun.star.lang.XComponent
+
+# LIB1TARGET= $(LB)$/a$(TARGET).lib
+# LIB1ARCHIV= $(LB)$/lib$(TARGET)$(CPPUHELPER_MAJOR)$(COM).a
+# LIB1FILES= $(LB)$/$(TARGET).lib
+
+SLOFILES= \
+ $(SLO)$/typeprovider.obj \
+ $(SLO)$/exc_thrower.obj \
+ $(SLO)$/servicefactory.obj \
+ $(SLO)$/implbase.obj \
+ $(SLO)$/propshlp.obj \
+ $(SLO)$/weak.obj \
+ $(SLO)$/interfacecontainer.obj \
+ $(SLO)$/stdidlclass.obj \
+ $(SLO)$/factory.obj \
+ $(SLO)$/component.obj
+
+# OBJFILES= \
+# $(OBJ)$/typeprovider.obj \
+# $(OBJ)$/exc_thrower.obj \
+# $(OBJ)$/servicefactory.obj \
+# $(OBJ)$/implbase.obj \
+# $(OBJ)$/propshlp.obj \
+# $(OBJ)$/weak.obj \
+# $(OBJ)$/interfacecontainer.obj \
+# $(OBJ)$/stdidlclass.obj \
+# $(OBJ)$/factory.obj \
+# $(OBJ)$/component.obj
+
+# NETBSD: somewhere we have to instantiate the static data members.
+# NETBSD-1.2.1 doesn't know about weak symbols so the default mechanism for GCC won't work.
+# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols
+.IF "$(OS)"=="NETBSD" || "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX"
+SLOFILES+=$(SLO)$/staticmb.obj
+#OBJFILES+=$(OBJ)$/staticmb.obj
+.ENDIF
+
+SHL1TARGET= $(TARGET)$(CPPUHELPER_MAJOR)$(COM)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt
+DEFLIB1NAME= $(TARGET)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(MISC)$/$(SHL1TARGET).flt : makefile.mk
+ +echo _TI2 >$@
+ +echo _TI1 >>$@
diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx
new file mode 100644
index 000000000000..1783d853908e
--- /dev/null
+++ b/cppuhelper/source/propshlp.cxx
@@ -0,0 +1,1106 @@
+/*************************************************************************
+ *
+ * $RCSfile: propshlp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#include <osl/diagnose.h>
+
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/propshlp.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace rtl;
+using namespace cppu;
+
+namespace cppu {
+
+IPropertyArrayHelper::~IPropertyArrayHelper()
+{
+}
+
+inline const ::com::sun::star::uno::Type & getPropertyTypeIdentifier( )
+{
+ return ::getCppuType( (Reference< XPropertyChangeListener > *)0 );
+}
+inline const ::com::sun::star::uno::Type & getPropertiesTypeIdentifier()
+{
+ return ::getCppuType( (Reference< XPropertiesChangeListener > *)0 );
+}
+inline const ::com::sun::star::uno::Type & getVetoableTypeIdentifier()
+{
+ return ::getCppuType( (Reference< XVetoableChangeListener > *)0 );
+}
+
+int SAL_CALL compare_OUString_Property_Impl( const void *arg1, const void *arg2 )
+{
+ return ((OUString *)arg1)->compareTo( ((Property *)arg2)->Name );
+}
+
+/**
+ * The class which implements the PropertySetInfo interface.
+ */
+class OPropertySetHelperInfo_Impl
+ : public WeakImplHelper1< ::com::sun::star::beans::XPropertySetInfo >
+{
+ Sequence < Property > aInfos;
+
+public:
+ OPropertySetHelperInfo_Impl( IPropertyArrayHelper & rHelper_ );
+
+ // XPropertySetInfo-Methoden
+ virtual Sequence< Property > SAL_CALL getProperties(void);
+ virtual Property SAL_CALL getPropertyByName(const OUString& PropertyName);
+ virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& PropertyName);
+};
+
+
+/**
+ * Create an object that implements XPropertySetInfo IPropertyArrayHelper.
+ */
+OPropertySetHelperInfo_Impl::OPropertySetHelperInfo_Impl( IPropertyArrayHelper & rHelper_ )
+ :aInfos( rHelper_.getProperties() )
+{
+}
+
+/**
+ * Return the sequence of properties, which are provided throug the constructor.
+ */
+Sequence< Property > OPropertySetHelperInfo_Impl::getProperties(void)
+{
+ return aInfos;
+}
+
+/**
+ * Return the sequence of properties, which are provided throug the constructor.
+ */
+Property OPropertySetHelperInfo_Impl::getPropertyByName( const OUString & PropertyName )
+{
+ Property * pR;
+ pR = (Property *)bsearch( &PropertyName, aInfos.getConstArray(), aInfos.getLength(),
+ sizeof( Property ),
+ compare_OUString_Property_Impl );
+ if( !pR ) {
+ throw UnknownPropertyException();
+ }
+
+ return *pR;
+}
+
+/**
+ * Return the sequence of properties, which are provided throug the constructor.
+ */
+sal_Bool OPropertySetHelperInfo_Impl::hasPropertyByName( const OUString & PropertyName )
+{
+ Property * pR;
+ pR = (Property *)bsearch( &PropertyName, aInfos.getConstArray(), aInfos.getLength(),
+ sizeof( Property ),
+ compare_OUString_Property_Impl );
+ return pR != NULL;
+}
+
+// ----------------------------------------------------
+// class PropertySetHelper
+// ----------------------------------------------------
+OPropertySetHelper::OPropertySetHelper(
+ OBroadcastHelper & rBHelper_ )
+ : rBHelper( rBHelper_ )
+ , aBoundLC( rBHelper_.rMutex )
+ , aVetoableLC( rBHelper_.rMutex )
+{
+}
+
+/**
+ * You must call disposing before.
+ */
+OPropertySetHelper::~OPropertySetHelper()
+{
+}
+
+/**
+ * These method is called from queryInterface, if no delegator is set.
+ * Otherwise this method is called from the delegator.
+ */
+// XAggregation
+Any OPropertySetHelper::queryInterface( const ::com::sun::star::uno::Type & rType )
+{
+ return ::cppu::queryInterface( rType,
+ static_cast< XPropertySet * >( this ),
+ static_cast< XMultiPropertySet * >( this ),
+ static_cast< XFastPropertySet * >( this ) );
+}
+
+// ComponentHelper
+void OPropertySetHelper::disposing()
+{
+ // Create an event with this as sender
+ Reference < XPropertySet > rSource( SAL_STATIC_CAST( XPropertySet * , this ) , UNO_QUERY );
+ EventObject aEvt;
+ aEvt.Source = rSource;
+
+ // inform all listeners to reelease this object
+ // The listener container are automaticly cleared
+ aBoundLC.disposeAndClear( aEvt );
+ aVetoableLC.disposeAndClear( aEvt );
+}
+
+Reference < XPropertySetInfo > OPropertySetHelper::createPropertySetInfo( IPropertyArrayHelper & rProperties )
+{
+ return static_cast< XPropertySetInfo * >( new OPropertySetHelperInfo_Impl( rProperties ) );
+}
+
+// XPropertySet
+void OPropertySetHelper::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
+{
+ // get the map table
+ IPropertyArrayHelper & rPH = getInfoHelper();
+ // map the name to the handle
+ sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+ // call the method of the XFastPropertySet interface
+ setFastPropertyValue( nHandle, rValue );
+}
+
+// XPropertySet
+Any OPropertySetHelper::getPropertyValue( const OUString& rPropertyName )
+{
+ // get the map table
+ IPropertyArrayHelper & rPH = getInfoHelper();
+ // map the name to the handle
+ sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+ // call the method of the XFastPropertySet interface
+ return getFastPropertyValue( nHandle );
+}
+
+// XPropertySet
+void OPropertySetHelper::addPropertyChangeListener(const OUString& rPropertyName,
+ const Reference < XPropertyChangeListener > & rxListener)
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bInDispose, "do not addPropertyChangeListener in the dispose call" );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+ {
+ // only add listeners if you are not disposed
+ // a listener with no name means all properties
+ if( rPropertyName.len() )
+ {
+ // get the map table
+ IPropertyArrayHelper & rPH = getInfoHelper();
+ // map the name to the handle
+ sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+ if( nHandle == -1 ) {
+ // property not known throw exception
+ throw UnknownPropertyException() ;
+ }
+
+ sal_Int16 nAttributes;
+ rPH.fillPropertyMembersByHandle( NULL, &nAttributes, nHandle );
+ if( !(nAttributes & ::com::sun::star::beans::PropertyAttribute::BOUND) )
+ {
+ OSL_ENSHURE( sal_False, "add listener to an unbound property" );
+ // silent ignore this
+ return;
+ }
+ // add the change listener to the helper container
+
+ aBoundLC.addInterface( (sal_Int32)nHandle, rxListener );
+ }
+ else
+ // add the change listener to the helper container
+ rBHelper.aLC.addInterface(
+ getPropertyTypeIdentifier( ),
+ rxListener
+ );
+ }
+}
+
+
+// XPropertySet
+void OPropertySetHelper::removePropertyChangeListener(const OUString& rPropertyName,
+ const Reference < XPropertyChangeListener >& rxListener)
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ // all listeners are automaticly released in a dispose call
+ if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+ {
+ if( rPropertyName.len() )
+ {
+ // get the map table
+ IPropertyArrayHelper & rPH = getInfoHelper();
+ // map the name to the handle
+ sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+ if( nHandle == -1 )
+ // property not known throw exception
+ throw UnknownPropertyException();
+ aBoundLC.removeInterface( (sal_Int32)nHandle, rxListener );
+ }
+ else {
+ // remove the change listener to the helper container
+ rBHelper.aLC.removeInterface(
+ getPropertyTypeIdentifier( ),
+ rxListener
+ );
+ }
+ }
+}
+
+// XPropertySet
+void OPropertySetHelper::addVetoableChangeListener
+(
+ const OUString& rPropertyName,
+ const Reference< XVetoableChangeListener > & rxListener
+)
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bInDispose, "do not addVetoableChangeListener in the dispose call" );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+ {
+ // only add listeners if you are not disposed
+ // a listener with no name means all properties
+ if( rPropertyName.len() )
+ {
+ // get the map table
+ IPropertyArrayHelper & rPH = getInfoHelper();
+ // map the name to the handle
+ sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+ if( nHandle == -1 ) {
+ // property not known throw exception
+ throw UnknownPropertyException();
+ }
+
+ sal_Int16 nAttributes;
+ rPH.fillPropertyMembersByHandle( NULL, &nAttributes, nHandle );
+ if( !(nAttributes & PropertyAttribute::CONSTRAINED) )
+ {
+ OSL_ENSHURE( sal_False, "addVetoableChangeListener, and property is not constrained" );
+ // silent ignore this
+ return;
+ }
+ // add the vetoable listener to the helper container
+ aVetoableLC.addInterface( (sal_Int32)nHandle, rxListener );
+ }
+ else
+ // add the vetoable listener to the helper container
+ rBHelper.aLC.addInterface(
+ getVetoableTypeIdentifier( ),
+ rxListener
+ );
+ }
+}
+
+// XPropertySet
+void OPropertySetHelper::removeVetoableChangeListener
+(
+ const OUString& rPropertyName,
+ const Reference < XVetoableChangeListener > & rxListener
+)
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ // all listeners are automaticly released in a dispose call
+ if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+ {
+ if( rPropertyName.len() )
+ {
+ // get the map table
+ IPropertyArrayHelper & rPH = getInfoHelper();
+ // map the name to the handle
+ sal_Int32 nHandle = rPH.getHandleByName( rPropertyName );
+ if( nHandle == -1 ) {
+ // property not known throw exception
+ throw UnknownPropertyException();
+ }
+ // remove the vetoable listener to the helper container
+ aVetoableLC.removeInterface( (sal_Int32)nHandle, rxListener );
+ }
+ else
+ // add the vetoable listener to the helper container
+ rBHelper.aLC.removeInterface(
+ getVetoableTypeIdentifier( ),
+ rxListener
+ );
+ }
+}
+
+// XFastPropertySet
+void OPropertySetHelper::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ OSL_ENSHURE( !rBHelper.bInDispose, "do not setFastPropertyValue in the dispose call" );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+
+ IPropertyArrayHelper & rInfo = getInfoHelper();
+ sal_Int16 nAttributes;
+ if( !rInfo.fillPropertyMembersByHandle( NULL, &nAttributes, nHandle ) ) {
+ // unknown property
+ throw UnknownPropertyException();
+ }
+ if( nAttributes & PropertyAttribute::READONLY )
+ throw PropertyVetoException();
+
+ Any aConvertedVal;
+ Any aOldVal;
+
+ // Will the property change?
+ sal_Bool bChanged;
+ {
+ MutexGuard aGuard( rBHelper.rMutex );
+ bChanged = convertFastPropertyValue( aConvertedVal, aOldVal, nHandle, rValue );
+ // release guard to fire events
+ }
+ if( bChanged )
+ {
+ // Is it a constrained property?
+ if( nAttributes & PropertyAttribute::CONSTRAINED )
+ {
+ // In aValue is the converted rValue
+ // fire a constarined event
+ // second parameter NULL means constrained
+ fire( &nHandle, &rValue, &aOldVal, 1, sal_True );
+ }
+
+ {
+ MutexGuard aGuard( rBHelper.rMutex );
+ // set the property to the new value
+ setFastPropertyValue_NoBroadcast( nHandle, aConvertedVal );
+ // release guard to fire events
+ }
+ // file a change event, if the value changed
+ fire( &nHandle, &rValue, &aOldVal, 1, sal_False );
+ }
+}
+
+// XFastPropertySet
+Any OPropertySetHelper::getFastPropertyValue( sal_Int32 nHandle )
+ throw(::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException)
+
+{
+ IPropertyArrayHelper & rInfo = getInfoHelper();
+ if( !rInfo.fillPropertyMembersByHandle( NULL, NULL, nHandle ) )
+ // unknown property
+ throw UnknownPropertyException();
+
+ Any aRet;
+ MutexGuard aGuard( rBHelper.rMutex );
+ getFastPropertyValue( aRet, nHandle );
+ return aRet;
+}
+
+//--------------------------------------------------------------------------
+void OPropertySetHelper::fire
+(
+ sal_Int32 * pnHandles,
+ const Any * pNewValues,
+ const Any * pOldValues,
+ sal_Int32 nHandles, // These is the Count of the array
+ sal_Bool bVetoable
+)
+{
+ // Only fire, if one or more properties changed
+ if( nHandles )
+ {
+ // create the event sequence of all changed properties
+ Sequence< PropertyChangeEvent > aEvts( nHandles );
+ PropertyChangeEvent * pEvts = aEvts.getArray();
+ Reference < XInterface > xSource( (XPropertySet *)this, UNO_QUERY );
+ sal_Int32 i;
+ sal_Int32 nChangesLen = 0;
+ // Loop over all changed properties to fill the event struct
+ for( i = 0; i < nHandles; i++ )
+ {
+ // Vetoable fire and constrained attribute set or
+ // Change fire and Changed and bound attribute set
+ IPropertyArrayHelper & rInfo = getInfoHelper();
+ sal_Int16 nAttributes;
+ OUString aPropName;
+ rInfo.fillPropertyMembersByHandle( &aPropName, &nAttributes, pnHandles[i] );
+
+ if( bVetoable && (nAttributes & PropertyAttribute::CONSTRAINED)
+ || !bVetoable && (nAttributes & PropertyAttribute::BOUND) )
+ {
+ pEvts[nChangesLen].Source = xSource;
+ pEvts[nChangesLen].PropertyName = aPropName;
+ pEvts[nChangesLen].PropertyHandle = pnHandles[i];
+ pEvts[nChangesLen].OldValue = pOldValues[i];
+ pEvts[nChangesLen].NewValue = pNewValues[i];
+ nChangesLen++;
+ }
+ }
+
+ // fire the events for all changed properties
+ for( i = 0; i < nChangesLen; i++ )
+ {
+ // get the listener container for the property name
+ OInterfaceContainerHelper * pLC;
+ if( bVetoable ) // fire change Events?
+ pLC = aVetoableLC.getContainer( pEvts[i].PropertyHandle );
+ else
+ pLC = aBoundLC.getContainer( pEvts[i].PropertyHandle );
+ if( pLC )
+ {
+ // Ueber alle Listener iterieren und Events senden
+ OInterfaceIteratorHelper aIt( *pLC);
+ while( aIt.hasMoreElements() )
+ {
+ XInterface * pL = aIt.next();
+ if( bVetoable ) // fire change Events?
+ ((XVetoableChangeListener *)pL)->vetoableChange( pEvts[i] );
+ else
+ ((XPropertyChangeListener *)pL)->propertyChange( pEvts[i] );
+ }
+ }
+ // broadcast to all listeners with "" property name
+ if( bVetoable ){
+ // fire change Events?
+ pLC = rBHelper.aLC.getContainer(
+ getVetoableTypeIdentifier()
+ );
+ }
+ else {
+ pLC = rBHelper.aLC.getContainer(
+ getPropertyTypeIdentifier( )
+ );
+ }
+ if( pLC )
+ {
+ // Ueber alle Listener iterieren und Events senden
+ OInterfaceIteratorHelper aIt( *pLC);
+ while( aIt.hasMoreElements() )
+ {
+ XInterface * pL = aIt.next();
+ if( bVetoable ) // fire change Events?
+ ((XVetoableChangeListener *)pL)->vetoableChange( pEvts[i] );
+ else
+ ((XPropertyChangeListener *)pL)->propertyChange( pEvts[i] );
+ }
+ }
+ }
+
+ // reduce array to changed properties
+ aEvts.realloc( nChangesLen );
+
+ if( !bVetoable )
+ {
+ OInterfaceContainerHelper * pCont = 0;
+ pCont = rBHelper.aLC.getContainer(
+ getPropertiesTypeIdentifier( )
+ );
+ if( pCont )
+ {
+ // Here is a Bug, unbound properties are also fired
+ OInterfaceIteratorHelper aIt( *pCont );
+ while( aIt.hasMoreElements() )
+ {
+ XPropertiesChangeListener * pL = (XPropertiesChangeListener *)aIt.next();
+ // fire the hole event sequence to the XPropertiesChangeListener's
+ pL->propertiesChange( aEvts );
+ }
+ }
+ }
+ }
+}
+
+// OPropertySetHelper
+void OPropertySetHelper::setFastPropertyValues
+(
+ sal_Int32 nSeqLen,
+ sal_Int32 * pHandles,
+ const Any * pValues,
+ sal_Int32 nHitCount
+)
+throw (Exception)
+{
+ OSL_ENSHURE( !rBHelper.bInDispose, "do not getFastPropertyValue in the dispose call" );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+
+ Any * pConvertedValues = NULL;
+ Any * pOldValues = NULL;
+
+ try
+ {
+ // get the map table
+ IPropertyArrayHelper & rPH = getInfoHelper();
+
+ pConvertedValues = new Any[ nHitCount ];
+ pOldValues = new Any[ nHitCount ];
+ sal_Int32 nHitCount = 0;
+ sal_Int32 i;
+
+ {
+ // must lock the mutex outside the loop. So all values are consistent.
+ MutexGuard aGuard( rBHelper.rMutex );
+ for( i = 0; i < nSeqLen; i++ )
+ {
+ if( pHandles[i] != -1 )
+ {
+ sal_Int16 nAttributes;
+ rPH.fillPropertyMembersByHandle( NULL, &nAttributes, pHandles[i] );
+ if( nAttributes & PropertyAttribute::READONLY ) {
+ throw PropertyVetoException();
+ }
+ // Will the property change?
+ if( convertFastPropertyValue( pConvertedValues[ nHitCount ], pOldValues[nHitCount],
+ pHandles[i], pValues[i] ) )
+ {
+ // only increment if the property really change
+ pHandles[nHitCount] = pHandles[i];
+ nHitCount++;
+ }
+ }
+ }
+ // release guard to fire events
+ }
+
+ // fire vetoable events
+ fire( pHandles, pConvertedValues, pOldValues, nHitCount, sal_True );
+
+ {
+ // must lock the mutex outside the loop.
+ MutexGuard aGuard( rBHelper.rMutex );
+ // Loop over all changed properties
+ for( i = 0; i < nHitCount; i++ )
+ {
+ // Will the property change?
+ setFastPropertyValue_NoBroadcast( pHandles[i], pConvertedValues[i] );
+ }
+ // release guard to fire events
+ }
+
+ // fire change events
+ fire( pHandles, pConvertedValues, pOldValues, nHitCount, sal_False );
+ }
+ catch( ... )
+ {
+ delete [] pOldValues;
+ delete [] pConvertedValues;
+ throw;
+ }
+ delete [] pOldValues;
+ delete [] pConvertedValues;
+}
+
+// XMultiPropertySet
+/**
+ * The sequence may be conatain not known properties. The implementation
+ * must ignore these properties.
+ */
+void OPropertySetHelper::setPropertyValues
+(
+ const Sequence<OUString>& rPropertyNames,
+ const Sequence<Any>& rValues
+)
+{
+ sal_Int32 * pHandles = NULL;
+ try
+ {
+ sal_Int32 nSeqLen = rPropertyNames.getLength();
+ pHandles = new sal_Int32[ nSeqLen ];
+ // get the map table
+ IPropertyArrayHelper & rPH = getInfoHelper();
+ // fill the handle array
+ sal_Int32 nHitCount = rPH.fillHandles( pHandles, rPropertyNames );
+ if( nHitCount != 0 )
+ setFastPropertyValues( nSeqLen, pHandles, rValues.getConstArray(), nHitCount );
+ }
+ catch( ... )
+ {
+ delete [] pHandles;
+ throw;
+ }
+ delete [] pHandles;
+}
+
+// XMultiPropertySet
+Sequence<Any> OPropertySetHelper::getPropertyValues( const Sequence<OUString>& rPropertyNames )
+{
+ sal_Int32 nSeqLen = rPropertyNames.getLength();
+ sal_Int32 * pHandles = new sal_Int32[ nSeqLen ];
+ Sequence< Any > aValues( nSeqLen );
+
+ // get the map table
+ IPropertyArrayHelper & rPH = getInfoHelper();
+ // fill the handle array
+ rPH.fillHandles( pHandles, rPropertyNames );
+
+ Any * pValues = aValues.getArray();
+ const OUString * pNames = rPropertyNames.getConstArray();
+
+ MutexGuard aGuard( rBHelper.rMutex );
+ // fill the sequence with the values
+ for( sal_Int32 i = 0; i < nSeqLen; i++ )
+ getFastPropertyValue( pValues[i], pHandles[i] );
+
+ delete [] pHandles;
+ return aValues;
+}
+
+// XMultiPropertySet
+void OPropertySetHelper::addPropertiesChangeListener (
+ const Sequence<OUString> & ,
+ const Reference < XPropertiesChangeListener > & rListener
+ )
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bInDispose, "do not addPropertyChangeListener in the dispose call" );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ // all listeners are automaticly released in a dispose call
+ if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+ {
+ // Listener wird zu allen Properties angemeldet, besser ist
+ // sie ueber die Namen anzumelden
+ rBHelper.aLC.addInterface(
+ getPropertiesTypeIdentifier( ),
+ rListener
+ );
+ }
+}
+
+// XMultiPropertySet
+void OPropertySetHelper::removePropertiesChangeListener
+ ( const Reference < XPropertiesChangeListener > & rxListener )
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+ OSL_ENSHURE( !rBHelper.bDisposed, "object is disposed" );
+ // all listeners are automaticly released in a dispose call
+ if( !rBHelper.bInDispose && !rBHelper.bDisposed )
+ {
+ rBHelper.aLC.removeInterface(
+ getPropertiesTypeIdentifier( ),
+ rxListener
+ );
+ }
+}
+
+// XMultiPropertySet
+void OPropertySetHelper::firePropertiesChangeEvent
+(
+ const Sequence<OUString>& rPropertyNames,
+ const Reference < XPropertiesChangeListener >& rListener
+)
+{
+ sal_Int32 nLen = rPropertyNames.getLength();
+ sal_Int32 * pHandles = new sal_Int32[nLen];
+ IPropertyArrayHelper & rPH = getInfoHelper();
+ rPH.fillHandles( pHandles, rPropertyNames );
+ const OUString* pNames = rPropertyNames.getConstArray();
+
+ // get the count of matching properties
+ sal_Int32 nFireLen = 0;
+ sal_Int32 i;
+ for( i = 0; i < nLen; i++ )
+ if( pHandles[i] != -1 )
+ nFireLen++;
+
+ Sequence<PropertyChangeEvent> aChanges( nFireLen );
+ PropertyChangeEvent* pChanges = aChanges.getArray();
+
+ sal_Int32 nFirePos = 0;
+ {
+ // must lock the mutex outside the loop. So all values are consistent.
+ MutexGuard aGuard( rBHelper.rMutex );
+ Reference < XInterface > xSource( (XPropertySet *)this, UNO_QUERY );
+ for( i = 0; i < nLen; i++ )
+ {
+ if( pHandles[i] != -1 )
+ {
+ pChanges[nFirePos].Source = xSource;
+ pChanges[nFirePos].PropertyName = pNames[i];
+ pChanges[nFirePos].PropertyHandle = pHandles[i];
+ getFastPropertyValue( pChanges[nFirePos].OldValue, pHandles[i] );
+ pChanges[nFirePos].NewValue = pChanges[nFirePos].OldValue;
+ nFirePos++;
+ }
+ }
+ // release guard to fire events
+ }
+ if( nFireLen )
+ rListener->propertiesChange( aChanges );
+
+ delete [] pHandles;
+}
+
+#ifdef xdvnsdfln
+// XPropertyState
+PropertyState OPropertySetHelper::getPropertyState( const OUString& PropertyName )
+{
+ PropertyState aState;
+ return aState;
+}
+
+// XPropertyState
+Sequence< PropertyState > OPropertySetHelper::getPropertyStates( const Sequence< OUString >& PropertyNames )
+{
+ ULONG nNames = PropertyNames.getLength();
+ const OUString* pNames = PropertyNames.getConstArray();
+
+ Sequence< PropertyState > aStates( nNames );
+ return aStates;
+
+}
+
+void OPropertySetHelper::setPropertyToDefault( const OUString& aPropertyName )
+{
+ setPropertyValue( aPropertyName, Any() );
+}
+
+Any OPropertySetHelper::getPropertyDefault( const OUString& aPropertyName ) const
+{
+ return Any();
+}
+
+void OPropertySetHelper::addPropertyStateChangeListener( const OUString& aPropertyName, const XPropertyStateChangeListenerRef& Listener )
+{
+}
+
+void OPropertySetHelper::removePropertyStateChangeListener( const OUString& aPropertyName, const XPropertyStateChangeListenerRef& Listener )
+{
+}
+#endif
+
+//========================================================================
+//== OPropertyArrayHelper ================================================
+//========================================================================
+
+//========================================================================
+
+// static OUString makeOUString( sal_Char *p )
+// {
+// sal_Int32 nLen = strlen(p);
+// sal_Unicode *pw = new sal_Unicode[nLen];
+
+// for( int i = 0 ; i < nLen ; i ++ ) {
+
+// // Only ascii strings allowed with this helper !
+// OSL_ASSERT( p[i] < 127 );
+// pw[i] = p[i];
+// }
+// OUString ow( pw , nLen );
+// delete pw;
+// return ow;
+// }
+
+int SAL_CALL compare_Property_Impl( const void *arg1, const void *arg2 )
+{
+ return ((Property *)arg1)->Name.compareTo( ((Property *)arg2)->Name );
+}
+
+void OPropertyArrayHelper::init( sal_Bool bSorted )
+{
+ sal_Int32 i, nElements = aInfos.getLength();
+ const Property* pProperties = aInfos.getConstArray();
+
+ for( i = 1; i < nElements; i++ )
+ {
+ if( pProperties[i-1].Name >= pProperties[i].Name )
+ {
+ OSL_ENSHURE( !bSorted, "Property array is not sorted" );
+ // not sorted
+ qsort( aInfos.getArray(), nElements, sizeof( Property ),
+ compare_Property_Impl );
+ break;
+ }
+ }
+ // may be that the array is resorted
+ pProperties = aInfos.getConstArray();
+ for( i = 0; i < nElements; i++ )
+ if( pProperties[i].Handle != i )
+ return;
+ // The handle is the index
+ bRightOrdered = sal_True;
+}
+
+OPropertyArrayHelper::OPropertyArrayHelper
+(
+ Property * pProps,
+ sal_Int32 nEle,
+ sal_Bool bSorted
+)
+ : aInfos(pProps, nEle)
+ , bRightOrdered( sal_False )
+{
+ init( bSorted );
+}
+
+OPropertyArrayHelper::OPropertyArrayHelper
+(
+ const Sequence< Property > & aProps,
+ sal_Bool bSorted
+)
+ : aInfos(aProps)
+ , bRightOrdered( sal_False )
+{
+ init( bSorted );
+}
+
+//========================================================================
+sal_Int32 OPropertyArrayHelper::getCount() const
+{
+ return aInfos.getLength();
+}
+
+//========================================================================
+sal_Bool OPropertyArrayHelper::fillPropertyMembersByHandle
+(
+ OUString * pPropName,
+ sal_Int16 * pAttributes,
+ sal_Int32 nHandle
+)
+{
+ const Property* pProperties = aInfos.getConstArray();
+ sal_Int32 nElements = aInfos.getLength();
+
+ if( bRightOrdered )
+ {
+ if( nHandle < 0 || nHandle >= nElements )
+ return sal_False;
+ if( pPropName )
+ *pPropName = pProperties[ nHandle ].Name;
+ if( pAttributes )
+ *pAttributes = pProperties[ nHandle ].Attributes;
+ return sal_True;
+ }
+ else
+ {
+ // normally the array is sorted
+ for( sal_Int32 i = 0; i < nElements; i++ )
+ {
+ if( pProperties[i].Handle == nHandle )
+ {
+ if( pPropName )
+ *pPropName = pProperties[ i ].Name;
+ if( pAttributes )
+ *pAttributes = pProperties[ i ].Attributes;
+ return sal_True;
+ }
+ }
+ }
+ return sal_False;
+}
+
+//========================================================================
+Sequence< Property > OPropertyArrayHelper::getProperties(void)
+{
+ /*if( aInfos.getLength() != nElements )
+ {
+ ((OPropertyArrayHelper *)this)->aInfos.realloc( nElements );
+ Property * pProps = ((OPropertyArrayHelper *)this)->aInfos.getArray();
+ for( sal_Int32 i = 0; i < nElements; i++ )
+ {
+ pProps[i].Name = pProperties[i].Name;
+ pProps[i].Handle = pProperties[i].Handle;
+ pProps[i].Type = pProperties[i].Type;
+ pProps[i].Attributes = pProperties[i].Attributes;
+ }
+ }*/
+ return aInfos;
+}
+
+//========================================================================
+Property OPropertyArrayHelper::getPropertyByName(const OUString& aPropertyName)
+ throw (UnknownPropertyException)
+{
+ Property * pR;
+ pR = (Property *)bsearch( &aPropertyName, aInfos.getConstArray(), aInfos.getLength(),
+ sizeof( Property ),
+ compare_OUString_Property_Impl );
+ if( !pR ) {
+ throw UnknownPropertyException();
+ }
+
+ /*Property aProp;
+ aProp.Name = pR->Name;
+ aProp.Handle = pR->Handle;
+ aProp.Type = pR->Type;
+ aProp.Attributes = pR->Attributes;
+ return aProp;*/
+ return *pR;
+}
+
+//========================================================================
+sal_Bool OPropertyArrayHelper::hasPropertyByName(const OUString& aPropertyName)
+{
+ Property * pR;
+ pR = (Property *)bsearch( &aPropertyName, aInfos.getConstArray(), aInfos.getLength(),
+ sizeof( Property ),
+ compare_OUString_Property_Impl );
+ return pR != NULL;
+}
+
+//========================================================================
+sal_Int32 OPropertyArrayHelper::getHandleByName( const OUString & rPropName )
+{
+ Property * pR;
+ pR = (Property *)bsearch( &rPropName, aInfos.getConstArray(), aInfos.getLength(),
+ sizeof( Property ),
+ compare_OUString_Property_Impl );
+ return pR ? pR->Handle : -1;
+}
+
+//========================================================================
+sal_Int32 OPropertyArrayHelper::fillHandles( sal_Int32 * pHandles, const Sequence< OUString > & rPropNames )
+{
+ sal_Int32 nHitCount = 0;
+ const OUString * pReqProps = rPropNames.getConstArray();
+ sal_Int32 nReqLen = rPropNames.getLength();
+ const Property * pCur = aInfos.getConstArray();
+ const Property * pEnd = pCur + aInfos.getLength();
+
+ for( sal_Int32 i = 0; i < nReqLen; i++ )
+ {
+ // Logarithmus ermitteln
+ sal_Int32 n = (sal_Int32)(pEnd - pCur);
+ sal_Int32 nLog = 0;
+ while( n )
+ {
+ nLog += 1;
+ n = n >> 1;
+ }
+
+ // Anzahl der noch zu suchenden Properties * dem Log2 der verbleibenden
+ // zu dursuchenden Properties.
+ if( (nReqLen - i) * nLog >= pEnd - pCur )
+ {
+ // linear search is better
+ while( pCur < pEnd && pReqProps[i] > pCur->Name )
+ {
+ pCur++;
+ }
+ if( pCur < pEnd && pReqProps[i] == pCur->Name )
+ {
+ pHandles[i] = pCur->Handle;
+ nHitCount++;
+ }
+ else
+ pHandles[i] = -1;
+ }
+ else
+ {
+ // binary search is better
+ sal_Int32 nCompVal = 1;
+ const Property * pOldEnd = pEnd--;
+ const Property * pMid = pCur;
+
+ while( nCompVal != 0 && pCur <= pEnd )
+ {
+ pMid = (pEnd - pCur) / 2 + pCur;
+
+ nCompVal = pReqProps[i].compareTo( pMid->Name );
+
+ if( nCompVal > 0 )
+ pCur = pMid + 1;
+ else
+ pEnd = pMid - 1;
+ }
+
+ if( nCompVal == 0 )
+ {
+ pHandles[i] = pMid->Handle;
+ nHitCount++;
+ pCur = pMid +1;
+ }
+ else if( nCompVal > 0 )
+ {
+ pHandles[i] = -1;
+ pCur = pMid +1;
+ }
+ else
+ {
+ pHandles[i] = -1;
+ pCur = pMid;
+ }
+ pEnd = pOldEnd;
+ }
+ }
+ return nHitCount;
+}
+
+} // end namespace cppu
+
+
+
diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx
new file mode 100644
index 000000000000..3e0bebf9b55c
--- /dev/null
+++ b/cppuhelper/source/servicefactory.cxx
@@ -0,0 +1,507 @@
+/*************************************************************************
+ *
+ * $RCSfile: servicefactory.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MODULE_H_
+#include <osl/module.h>
+#endif
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef _UNO_ENVIRONMENT_H_
+#include <uno/environment.h>
+#endif
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+
+using namespace rtl;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::container;
+
+
+namespace cppu
+{
+
+//==================================================================================================
+static Reference< XSingleServiceFactory > loadLibComponentFactory(
+ const OUString & rLibName, const OUString & rImplName, const OUString & rBootstrapPath,
+ const Reference< XMultiServiceFactory > & xSF, const Reference< XRegistryKey > & xKey )
+{
+ Reference< XSingleServiceFactory > xRet;
+ sal_uInt32 bufLen = 32;
+
+ if ( rBootstrapPath.getLength() > 0 )
+ {
+ bufLen += rBootstrapPath.getLength() + 1;
+ }
+
+ OUStringBuffer aLibNameBuf( bufLen );
+ if ( bufLen > 32 )
+ {
+ aLibNameBuf.append( rBootstrapPath );
+ aLibNameBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/") );
+ }
+
+#ifdef SAL_UNX
+ aLibNameBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM("lib") );
+ aLibNameBuf.append( rLibName );
+ aLibNameBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM(".so") );
+#else
+ aLibNameBuf.append( rLibName );
+ aLibNameBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM(".dll") );
+#endif
+ OUString aLibName( aLibNameBuf.makeStringAndClear() );
+ oslModule lib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
+
+ if (lib)
+ {
+ void * pSym;
+
+ // ========================= LATEST VERSION =========================
+ OUString aGetEnvName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_GETENV) );
+ if (pSym = osl_getSymbol( lib, aGetEnvName.pData ))
+ {
+ uno_Environment * pCurrentEnv = 0;
+ uno_Environment * pEnv = 0;
+ const sal_Char * pEnvTypeName = 0;
+ (*((component_getImplementationEnvironmentFunc)pSym))( &pEnvTypeName, &pEnv );
+
+ sal_Bool bNeedsMapping =
+ (pEnv || 0 != rtl_str_compare( pEnvTypeName, CPPU_CURRENT_LANGUAGE_BINDING_NAME ));
+
+ OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) );
+
+ if (bNeedsMapping)
+ {
+ if (! pEnv)
+ uno_getEnvironment( &pEnv, aEnvTypeName.pData, 0 );
+ if (pEnv)
+ {
+ OUString aCppEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ uno_getEnvironment( &pCurrentEnv, aCppEnvTypeName.pData, 0 );
+ if (pCurrentEnv)
+ bNeedsMapping = (pEnv != pCurrentEnv);
+ }
+ }
+
+ OUString aGetFactoryName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_GETFACTORY) );
+ if (pSym = osl_getSymbol( lib, aGetFactoryName.pData ))
+ {
+ OString aImplName( OUStringToOString( rImplName, RTL_TEXTENCODING_ASCII_US ) );
+
+ if (bNeedsMapping)
+ {
+ if (pEnv && pCurrentEnv)
+ {
+ Mapping aCurrent2Env( pCurrentEnv, pEnv );
+ Mapping aEnv2Current( pEnv, pCurrentEnv );
+
+ if (aCurrent2Env.is() && aEnv2Current.is())
+ {
+ void * pSMgr = aCurrent2Env.mapInterface(
+ xSF.get(), ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ) );
+ void * pKey = aCurrent2Env.mapInterface(
+ xKey.get(), ::getCppuType( (const Reference< XRegistryKey > *)0 ) );
+
+ void * pSSF = (*((component_getFactoryFunc)pSym))(
+ aImplName.getStr(), pSMgr, pKey );
+
+ if (pKey)
+ (*pEnv->pExtEnv->releaseInterface)( pEnv->pExtEnv, pKey );
+ if (pSMgr)
+ (*pEnv->pExtEnv->releaseInterface)( pEnv->pExtEnv, pSMgr );
+
+ if (pSSF)
+ {
+ aEnv2Current.mapInterface(
+ reinterpret_cast< void ** >( &xRet ),
+ pSSF, ::getCppuType( (const Reference< XSingleServiceFactory > *)0 ) );
+ (*pEnv->pExtEnv->releaseInterface)( pEnv->pExtEnv, pSSF );
+ }
+ }
+ }
+ }
+ else
+ {
+ XSingleServiceFactory * pRet = (XSingleServiceFactory *)
+ (*((component_getFactoryFunc)pSym))(
+ aImplName.getStr(), xSF.get(), xKey.get() );
+ if (pRet)
+ {
+ xRet = pRet;
+ pRet->release();
+ }
+ }
+ }
+
+ if (pEnv)
+ (*pEnv->release)( pEnv );
+ if (pCurrentEnv)
+ (*pCurrentEnv->release)( pCurrentEnv );
+ }
+
+ if (! xRet.is())
+ osl_unloadModule( lib );
+ }
+
+ return xRet;
+}
+//==================================================================================================
+static Reference< ::com::sun::star::lang::XSingleServiceFactory> SAL_CALL createLoaderFactory(
+ const Reference< XMultiServiceFactory > & xSF, const OUString & rBootstrapPath )
+{
+ return loadLibComponentFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("cpld") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.DLLComponentLoader") ),
+ rBootstrapPath, xSF, Reference< XRegistryKey >() );
+}
+//==================================================================================================
+static Reference< XSingleServiceFactory > SAL_CALL createSimpleRegistryFactory(
+ const Reference< XMultiServiceFactory > & xSF, const OUString & rBootstrapPath )
+{
+ return loadLibComponentFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("simreg") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.SimpleRegistry") ),
+ rBootstrapPath, xSF, Reference< XRegistryKey >() );
+}
+//==================================================================================================
+static Reference< XSingleServiceFactory> SAL_CALL createDefaultRegistryFactory(
+ const Reference< XMultiServiceFactory > & xSF, const OUString & rBootstrapPath )
+{
+ return loadLibComponentFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("defreg") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.DefaultRegistry") ),
+ rBootstrapPath, xSF, Reference< XRegistryKey >() );
+}
+//==================================================================================================
+static Reference< XSingleServiceFactory> SAL_CALL createNestedRegistryFactory(
+ const Reference< XMultiServiceFactory > & xSF, const OUString & rBootstrapPath )
+{
+ return loadLibComponentFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("defreg") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.NestedRegistry") ),
+ rBootstrapPath, xSF, Reference< XRegistryKey >() );
+}
+//==================================================================================================
+static Reference< XSingleServiceFactory> SAL_CALL createImplRegFactory(
+ const Reference< XMultiServiceFactory > & xSF, const OUString & rBootstrapPath )
+{
+ return loadLibComponentFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("impreg") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.ImplementationRegistration") ),
+ rBootstrapPath, xSF, Reference< XRegistryKey >() );
+}
+//==================================================================================================
+static Reference< XSingleServiceFactory> SAL_CALL createRegTDProviderFactory(
+ const Reference< XMultiServiceFactory > & xSF, const OUString & rBootstrapPath )
+{
+ return loadLibComponentFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("rdbtdp") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider") ),
+ rBootstrapPath, xSF, Reference< XRegistryKey >() );
+}
+//==================================================================================================
+static Reference< XSingleServiceFactory> SAL_CALL createTDManagerFactory(
+ const Reference< XMultiServiceFactory > & xSF, const OUString & rBootstrapPath )
+{
+ return loadLibComponentFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tdmgr") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.TypeDescriptionManager") ),
+ rBootstrapPath, xSF, Reference< XRegistryKey >() );
+}
+//==================================================================================================
+static Reference< XMultiServiceFactory > createImplServiceFactory( const OUString & rWriteRegistry,
+ const OUString & rReadRegistry,
+ sal_Bool bReadOnly,
+ const OUString & rBootstrapPath )
+ throw( ::com::sun::star::uno::Exception )
+{
+ // mappings held to avoid binding unloading...
+ Mapping aCpp2Uno(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ) );
+ Mapping aUno2Cpp(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ) );
+
+ Reference< XSingleServiceFactory > xSMFac( loadLibComponentFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("smgr") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.ORegistryServiceManager") ),
+ rBootstrapPath, Reference< XMultiServiceFactory >(), Reference< XRegistryKey >() ) );
+
+ // stop here if not at least a service manager is available
+ if ( !xSMFac.is() )
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("service manager component not available")),
+ Reference< XInterface >() );
+ }
+
+ Reference< XMultiServiceFactory > xSF( xSMFac->createInstance(), UNO_QUERY );
+ Reference< XInitialization > xInit( xSF, UNO_QUERY );
+
+ OSL_ENSHURE( xInit.is() && xSF.is(), "### failed loading servicemanager!" );
+ if (xInit.is() && xSF.is())
+ {
+ Reference< XSingleServiceFactory > xSimRegFac( createSimpleRegistryFactory( xSF, rBootstrapPath ) );
+ Reference< XSingleServiceFactory > xNesRegFac( createNestedRegistryFactory( xSF, rBootstrapPath ) );
+ OSL_ENSHURE( xSimRegFac.is() && xNesRegFac.is(), "### cannot get registry factories!" );
+
+ // write initial shared lib loader, simple registry, default registry, impl reg
+ Reference< XSet > xSet( xSF, UNO_QUERY );
+
+ // loader
+ {
+ Reference< XSingleServiceFactory > xFac( createLoaderFactory( xSF, rBootstrapPath ) );
+ if ( !xFac.is() )
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("shared library loader component not available")),
+ Reference< XInterface >() );
+ }
+ xSet->insert( makeAny( xFac ) );
+ OSL_ENSHURE( xSet->has( makeAny( xFac ) ), "### failed registering loader!" );
+ }
+ // simple registry
+ {
+ if ( !xSimRegFac.is() )
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("simple registry component not available")),
+ Reference< XInterface >() );
+ }
+ xSet->insert( makeAny( xSimRegFac ) );
+ OSL_ENSHURE( xSet->has( makeAny( xSimRegFac ) ), "### failed registering simple registry!" );
+ }
+ // nested registry
+ {
+ if ( !xNesRegFac.is() )
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("nested registry component not available")),
+ Reference< XInterface >() );
+ }
+ xSet->insert( makeAny( xNesRegFac ) );
+ OSL_ENSHURE( xSet->has( makeAny( xNesRegFac ) ), "### failed registering default registry!" );
+ }
+ // implementation registration
+ {
+ Reference< XSingleServiceFactory > xFac( createImplRegFactory( xSF, rBootstrapPath ) );
+ if ( !xFac.is() )
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("implementation registration component not available")),
+ Reference< XInterface >() );
+ }
+ xSet->insert( makeAny( xFac ) );
+ OSL_ENSHURE( xSet->has( makeAny( xFac ) ), "### failed registering impl reg!" );
+ }
+
+ Reference< XSimpleRegistry > xRegistry;
+
+ // open a registry
+ sal_Bool bRegistryShouldBeValid = sal_False;
+ if (rWriteRegistry.getLength() && !rReadRegistry.getLength())
+ {
+ bRegistryShouldBeValid = sal_True;
+ xRegistry = Reference< XSimpleRegistry >::query( xSimRegFac->createInstance() );
+ if (xRegistry.is())
+ {
+ if (bReadOnly)
+ {
+ xRegistry->open( rWriteRegistry, sal_True, sal_False );
+ } else
+ {
+ xRegistry->open( rWriteRegistry, sal_False, sal_True );
+ }
+ }
+ }
+ else // default registry
+ if (rWriteRegistry.getLength() && rReadRegistry.getLength() )
+ {
+ bRegistryShouldBeValid = sal_True;
+ xRegistry = Reference< XSimpleRegistry >::query( xNesRegFac->createInstance() );
+
+ Reference< XSimpleRegistry > xWriteReg = Reference< XSimpleRegistry >::query( xSimRegFac->createInstance() );
+ if ( xWriteReg.is() )
+ {
+ if (bReadOnly)
+ {
+ try
+ {
+ xWriteReg->open( rWriteRegistry, sal_True, sal_False );
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ if (!xWriteReg->isValid())
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("specified first registry could not be open readonly")),
+ Reference< XInterface >() );
+ }
+ } else
+ {
+ xWriteReg->open( rWriteRegistry, sal_False, sal_True );
+ }
+ }
+
+ Reference< XSimpleRegistry > xReadReg = Reference< XSimpleRegistry >::query( xSimRegFac->createInstance() );
+ if ( xReadReg.is() )
+ {
+ xReadReg->open( rReadRegistry, sal_True, sal_False );
+ }
+
+ Reference< XInitialization > xInit( xRegistry, UNO_QUERY );
+ Sequence< Any > aInitSeq( 2 );
+ aInitSeq[0] <<= xWriteReg;
+ aInitSeq[1] <<= xReadReg;
+ xInit->initialize( aInitSeq );
+ }
+
+ if (bRegistryShouldBeValid && (!xRegistry.is() || !xRegistry->isValid()))
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("specified registry could not be initialized")),
+ Reference< XInterface >() );
+ }
+
+// OSL_ENSHURE( xRegistry.is(), "### got no registry!" );
+ Reference< XInterface > xInst;
+ if (xRegistry.is())
+ {
+ // init service factory with registry
+ Sequence< Any > aSeq( 1 );
+ // registry to work on
+ aSeq[0] = makeAny( xRegistry );
+ xInit->initialize( aSeq );
+
+ xInst = xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.TypeDescriptionManager")) );
+ }
+
+ // initial td manager held by service manager
+ if (! xInst.is())
+ {
+ // td registry provider registration
+ {
+ Reference< XSingleServiceFactory > xFac( createRegTDProviderFactory( xSF, rBootstrapPath ) );
+ if ( !xFac.is() )
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("type description provider component not available")),
+ Reference< XInterface >() );
+ }
+ xSet->insert( makeAny( xFac ) );
+ OSL_ENSHURE( xSet->has( makeAny( xFac ) ), "### failed registering registry td provider!" );
+ }
+ // stoc td manager registration
+ {
+ Reference< XSingleServiceFactory > xFac( createTDManagerFactory( xSF, rBootstrapPath ) );
+ if ( !xFac.is() )
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("type description manager component not available")),
+ Reference< XInterface >() );
+ }
+ xSet->insert( makeAny( xFac ) );
+ OSL_ENSHURE( xSet->has( makeAny( xFac ) ), "### failed registering td manager!" );
+ }
+ xInst = xSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.TypeDescriptionManager")) );
+ }
+ if (xInst.is())
+ {
+ Reference< XInitialization > xTDMInit( xInst, UNO_QUERY );
+ if (xTDMInit.is())
+ xTDMInit->initialize( Sequence< Any >() );
+ } else
+ {
+ throw Exception( OUString(RTL_CONSTASCII_USTRINGPARAM("service \"com.sun.star.reflection.TypeDescriptionManager\" could not be initialized")),
+ Reference< XInterface >() );
+ }
+ return xSF;
+ }
+ return Reference< XMultiServiceFactory >();
+}
+
+//==================================================================================================
+Reference< XMultiServiceFactory > SAL_CALL createRegistryServiceFactory( const OUString & rWriteRegistry,
+ const OUString & rReadRegistry,
+ sal_Bool bReadOnly,
+ const OUString & rBootstrapPath )
+ throw( ::com::sun::star::uno::Exception )
+{
+ return createImplServiceFactory( rWriteRegistry, rReadRegistry, bReadOnly, rBootstrapPath );
+}
+
+}
+
diff --git a/cppuhelper/source/stdidlclass.cxx b/cppuhelper/source/stdidlclass.cxx
new file mode 100644
index 000000000000..139e1a8b53d1
--- /dev/null
+++ b/cppuhelper/source/stdidlclass.cxx
@@ -0,0 +1,240 @@
+/*************************************************************************
+ *
+ * $RCSfile: stdidlclass.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <cppuhelper/weakref.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/stdidlclass.hxx>
+
+#include <com/sun/star/reflection/XIdlClassProvider.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::reflection;
+using namespace rtl;
+
+namespace cppu {
+
+/*---------------------------------------------------------
+* This helper class implements XIdlClass. Is used by
+* createStdIdlClass()
+*---------------------------------------------------------*/
+class OStdIdlClass :
+ public OWeakObject,
+ public XIdlClass,
+ public XIdlClassProvider
+{
+public:
+ OStdIdlClass(
+ const Reference < XMultiServiceFactory > &rSMgr ,
+ const OUString & sImplementationName ,
+ const Reference < XIdlClass > & rSuperClass,
+ const Sequence < OUString > &seq
+ );
+
+ // XInterface
+ Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ void SAL_CALL acquire() { OWeakObject::acquire(); }
+ void SAL_CALL release() { OWeakObject::release(); }
+
+ // XIdlClassProvider
+ Sequence< Reference < XIdlClass > > SAL_CALL getIdlClasses(void);
+
+ // XIdlClass
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getClasses( ) throw(RuntimeException)
+ { return Sequence < Reference < XIdlClass > > (); }
+ virtual Reference< XIdlClass > SAL_CALL getClass( const ::rtl::OUString& aName ) throw(RuntimeException)
+ { return Reference < XIdlClass > (); }
+ virtual sal_Bool SAL_CALL equals( const Reference< XIdlClass >& Type ) throw(RuntimeException)
+ { return getName() == Type->getName(); }
+ virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass >& xType ) throw(RuntimeException)
+ { return equals( xType ); }
+ virtual TypeClass SAL_CALL getTypeClass( ) throw(RuntimeException)
+ { return TypeClass_UNKNOWN; }
+ virtual OUString SAL_CALL getName( ) throw(RuntimeException)
+ { return m_sImplementationName; }
+ virtual Uik SAL_CALL getUik( ) throw(RuntimeException)
+ { return Uik(); }
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses( ) throw(RuntimeException)
+ { return m_seqSuperClasses; }
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getInterfaces( ) throw(RuntimeException);
+
+ virtual Reference< XIdlClass > SAL_CALL getComponentType( ) throw(RuntimeException)
+ { return Reference < XIdlClass > (); }
+ virtual Reference< XIdlField > SAL_CALL getField( const ::rtl::OUString& aName ) throw(RuntimeException)
+ { return Reference < XIdlField > (); }
+ virtual Sequence< Reference< XIdlField > > SAL_CALL getFields( ) throw(RuntimeException)
+ { return Sequence< Reference < XIdlField > > (); }
+ virtual Reference< XIdlMethod > SAL_CALL getMethod( const ::rtl::OUString& aName ) throw(RuntimeException)
+ { return Reference < XIdlMethod > (); }
+ virtual Sequence< Reference< XIdlMethod > > SAL_CALL getMethods( ) throw(RuntimeException)
+ { return Sequence < Reference < XIdlMethod > > (); }
+ virtual Reference< XIdlArray > SAL_CALL getArray( ) throw(RuntimeException)
+ { return Reference < XIdlArray > (); }
+ virtual void SAL_CALL createObject( Any& obj ) throw(RuntimeException) {}
+
+private:
+ OUString m_sImplementationName;
+ Sequence < OUString > m_seqSupportedInterface;
+ Sequence < Reference < XIdlClass > > m_seqSuperClasses;
+ Reference < XMultiServiceFactory > m_rSMgr;
+};
+
+
+OStdIdlClass::OStdIdlClass(
+ const Reference < XMultiServiceFactory > &rSMgr ,
+ const OUString & sImplementationName ,
+ const Reference < XIdlClass > & rSuperClass,
+ const Sequence < OUString > &seq
+ ) :
+ m_rSMgr( rSMgr ) ,
+ m_sImplementationName( sImplementationName ) ,
+ m_seqSupportedInterface( seq )
+{
+ if( rSuperClass.is() )
+ m_seqSuperClasses = Sequence< Reference < XIdlClass > >( &rSuperClass, 1 );
+
+}
+
+Any SAL_CALL OStdIdlClass::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( ::cppu::queryInterface(
+ rType, static_cast< XIdlClass * >( this ), static_cast< XIdlClassProvider * >( this ) ) );
+
+ return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
+}
+
+
+Sequence< Reference< XIdlClass > > SAL_CALL OStdIdlClass::getInterfaces( ) throw(RuntimeException)
+{
+ int nMax = m_seqSupportedInterface.getLength();
+
+ if( m_rSMgr.is() ) {
+ Reference < XIdlReflection > rCoreRefl = Reference < XIdlReflection > (
+ m_rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.CoreReflection") ) ),
+ UNO_QUERY );
+
+ if( rCoreRefl.is() ) {
+
+ Sequence< Reference< XIdlClass > > seqClasses( nMax );
+
+ for( int n = 0 ; n < nMax ; n++ ) {
+ seqClasses.getArray()[n] = rCoreRefl->forName( m_seqSupportedInterface.getArray()[n] );
+ }
+
+ return seqClasses;
+ }
+ }
+ return Sequence< Reference< XIdlClass > > () ;
+}
+
+
+// XIdlClassProvider
+Sequence< Reference < XIdlClass > > SAL_CALL OStdIdlClass::getIdlClasses(void)
+{
+ // weak reference to cache the standard class
+ static WeakReference< XIdlClass > weakRef;
+
+ // try to make weakref hard
+ Reference < XIdlClass > r = weakRef;
+
+ if( ! r.is() ) {
+ // xidlclass has not been initialized before or has been destroyed already.
+ r = ::cppu::createStandardClass(
+ m_rSMgr ,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.cppuhelper.OStdIdlClass") ) ,
+ Reference < XIdlClass > () ,
+ SAL_STATIC_CAST( XIdlClassProvider * , this ) ,
+ SAL_STATIC_CAST( XIdlClass * , this )
+ );
+
+ // store reference for later use
+ weakRef = r;
+ }
+
+ return Sequence < Reference < XIdlClass > > ( &r , 1 );
+}
+
+
+
+
+// external constructor
+XIdlClass * SAL_CALL createStandardClassWithSequence(
+ const Reference < XMultiServiceFactory > &rSMgr ,
+ const OUString & sImplementationName ,
+ const Reference < XIdlClass > & rSuperClass,
+ const Sequence < OUString > &seqInterfaceNames )
+{
+ return SAL_STATIC_CAST(
+ XIdlClass * ,
+ new OStdIdlClass(
+ rSMgr ,
+ sImplementationName,
+ rSuperClass,
+ seqInterfaceNames
+ )
+ );
+}
+
+} //end namespace cppu
diff --git a/cppuhelper/source/typeprovider.cxx b/cppuhelper/source/typeprovider.cxx
new file mode 100644
index 000000000000..585c50a68071
--- /dev/null
+++ b/cppuhelper/source/typeprovider.cxx
@@ -0,0 +1,344 @@
+/*************************************************************************
+ *
+ * $RCSfile: typeprovider.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <cppuhelper/typeprovider.hxx>
+#include <osl/mutex.hxx>
+
+using namespace osl;
+using namespace com::sun::star::uno;
+
+namespace cppu
+{
+
+//__________________________________________________________________________________________________
+OImplementationId::~OImplementationId()
+{
+ delete _pSeq;
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int8 > OImplementationId::getImplementationId() const
+{
+ if (! _pSeq)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! _pSeq)
+ {
+ Sequence< sal_Int8 > * pSeq = new Sequence< sal_Int8 >( 16 );
+ ::rtl_createUuid( (sal_uInt8 *)pSeq->getArray(), 0, _bUseEthernetAddress );
+ _pSeq = pSeq;
+ }
+ }
+ return *_pSeq;
+}
+
+//--------------------------------------------------------------------------------------------------
+static inline void copy( Sequence< Type > & rDest, const Sequence< Type > & rSource, sal_Int32 nOffset )
+{
+ Type * pDest = rDest.getArray();
+ const Type * pSource = rSource.getConstArray();
+
+ for ( sal_Int32 nPos = rSource.getLength(); nPos--; )
+ pDest[nOffset+ nPos] = pSource[nPos];
+}
+
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 1 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ copy( _aTypes, rAddTypes, 1 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 2 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ copy( _aTypes, rAddTypes, 2 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 3 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ copy( _aTypes, rAddTypes, 3 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Type & rType4,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 4 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ _aTypes[3] = rType4;
+ copy( _aTypes, rAddTypes, 4 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Type & rType4,
+ const Type & rType5,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 5 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ _aTypes[3] = rType4;
+ _aTypes[4] = rType5;
+ copy( _aTypes, rAddTypes, 5 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Type & rType4,
+ const Type & rType5,
+ const Type & rType6,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 6 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ _aTypes[3] = rType4;
+ _aTypes[4] = rType5;
+ _aTypes[5] = rType6;
+ copy( _aTypes, rAddTypes, 6 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Type & rType4,
+ const Type & rType5,
+ const Type & rType6,
+ const Type & rType7,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 7 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ _aTypes[3] = rType4;
+ _aTypes[4] = rType5;
+ _aTypes[5] = rType6;
+ _aTypes[6] = rType7;
+ copy( _aTypes, rAddTypes, 7 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Type & rType4,
+ const Type & rType5,
+ const Type & rType6,
+ const Type & rType7,
+ const Type & rType8,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 8 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ _aTypes[3] = rType4;
+ _aTypes[4] = rType5;
+ _aTypes[5] = rType6;
+ _aTypes[6] = rType7;
+ _aTypes[7] = rType8;
+ copy( _aTypes, rAddTypes, 8 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Type & rType4,
+ const Type & rType5,
+ const Type & rType6,
+ const Type & rType7,
+ const Type & rType8,
+ const Type & rType9,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 9 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ _aTypes[3] = rType4;
+ _aTypes[4] = rType5;
+ _aTypes[5] = rType6;
+ _aTypes[6] = rType7;
+ _aTypes[7] = rType8;
+ _aTypes[8] = rType9;
+ copy( _aTypes, rAddTypes, 9 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Type & rType4,
+ const Type & rType5,
+ const Type & rType6,
+ const Type & rType7,
+ const Type & rType8,
+ const Type & rType9,
+ const Type & rType10,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 10 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ _aTypes[3] = rType4;
+ _aTypes[4] = rType5;
+ _aTypes[5] = rType6;
+ _aTypes[6] = rType7;
+ _aTypes[7] = rType8;
+ _aTypes[8] = rType9;
+ _aTypes[9] = rType10;
+ copy( _aTypes, rAddTypes, 10 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Type & rType4,
+ const Type & rType5,
+ const Type & rType6,
+ const Type & rType7,
+ const Type & rType8,
+ const Type & rType9,
+ const Type & rType10,
+ const Type & rType11,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 11 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ _aTypes[3] = rType4;
+ _aTypes[4] = rType5;
+ _aTypes[5] = rType6;
+ _aTypes[6] = rType7;
+ _aTypes[7] = rType8;
+ _aTypes[8] = rType9;
+ _aTypes[9] = rType10;
+ _aTypes[10] = rType11;
+ copy( _aTypes, rAddTypes, 11 );
+}
+//__________________________________________________________________________________________________
+OTypeCollection::OTypeCollection(
+ const Type & rType1,
+ const Type & rType2,
+ const Type & rType3,
+ const Type & rType4,
+ const Type & rType5,
+ const Type & rType6,
+ const Type & rType7,
+ const Type & rType8,
+ const Type & rType9,
+ const Type & rType10,
+ const Type & rType11,
+ const Type & rType12,
+ const Sequence< Type > & rAddTypes )
+ : _aTypes( 12 + rAddTypes.getLength() )
+{
+ _aTypes[0] = rType1;
+ _aTypes[1] = rType2;
+ _aTypes[2] = rType3;
+ _aTypes[3] = rType4;
+ _aTypes[4] = rType5;
+ _aTypes[5] = rType6;
+ _aTypes[6] = rType7;
+ _aTypes[7] = rType8;
+ _aTypes[8] = rType9;
+ _aTypes[9] = rType10;
+ _aTypes[10] = rType11;
+ _aTypes[11] = rType12;
+ copy( _aTypes, rAddTypes, 12 );
+}
+
+}
+
diff --git a/cppuhelper/source/weak.cxx b/cppuhelper/source/weak.cxx
new file mode 100644
index 000000000000..3765fc5e7852
--- /dev/null
+++ b/cppuhelper/source/weak.cxx
@@ -0,0 +1,521 @@
+/*************************************************************************
+ *
+ * $RCSfile: weak.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _CPPU_WEAKAGG_HXX_
+#include <cppuhelper/weakagg.hxx>
+#endif
+#ifndef _CPPU_HELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+using namespace osl;
+using namespace com::sun::star::uno;
+
+/** */ //for docpp
+namespace cppu
+{
+
+/**
+ The mutex to synchronize the the queryAdapted call throug the connection point
+ with the release call at the weak object.
+ */
+/*
+struct WeakMutexStatic
+{
+ Mutex aMutex;
+ sal_Bool bDestructed;
+
+ WeakMutexStatic()
+ : bDestructed( sal_False )
+ {}
+ ~WeakMutexStatic()
+ { bDestructed = sal_True; }
+};
+
+inline static Mutex & getWeakMutex() throw()
+{
+ static WeakMutexStatic s_wmstatic;
+ if (s_wmstatic.bDestructed)
+ return *Mutex::getGlobalMutex();
+ else
+ return s_wmstatic.aMutex;
+}
+*/
+
+// due to static Reflection destruction from usr, ther must be a mutex leak (#73272#)
+inline static Mutex & getWeakMutex() throw()
+{
+ static Mutex * s_pMutex = 0;
+ if (! s_pMutex)
+ s_pMutex = new Mutex();
+ return *s_pMutex;
+}
+
+//------------------------------------------------------------------------
+//-- OWeakConnectionPoint ----------------------------------------------------
+//------------------------------------------------------------------------
+class OWeakConnectionPoint : public XAdapter
+{
+public:
+ /**
+ Hold the weak object without an acquire (only the pointer).
+ */
+ OWeakConnectionPoint( OWeakObject* pObj ) throw()
+ : m_aRefCount( 0 )
+ , m_pObject(pObj)
+ , m_aReferences( getWeakMutex() )
+ {}
+
+ // XInterface
+ Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL acquire() throw();
+ void SAL_CALL release() throw();
+
+ // XAdapter
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL queryAdapted() throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL addReference( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XReference >& xRef ) throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL removeReference( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XReference >& xRef ) throw(::com::sun::star::uno::RuntimeException);
+
+ /// Called from the weak object if the reference count goes to zero.
+ void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+protected:
+ /// The reference counter.
+ oslInterlockedCount m_aRefCount;
+ /// The weak object
+ OWeakObject* m_pObject;
+ /// The container to hold the weak references
+ OInterfaceContainerHelper m_aReferences;
+};
+
+// XInterface
+Any SAL_CALL OWeakConnectionPoint::queryInterface( const Type & rType )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::queryInterface(
+ rType, static_cast< XAdapter * >( this ), static_cast< XInterface * >( this ) );
+}
+
+// XInterface
+void SAL_CALL OWeakConnectionPoint::acquire() throw()
+{
+ osl_incrementInterlockedCount( &m_aRefCount );
+}
+
+// XInterface
+void SAL_CALL OWeakConnectionPoint::release() throw()
+{
+ if (! osl_decrementInterlockedCount( &m_aRefCount ))
+ delete this;
+}
+
+void SAL_CALL OWeakConnectionPoint::dispose() throw(::com::sun::star::uno::RuntimeException)
+{
+ OInterfaceIteratorHelper aIt( m_aReferences );
+ while( aIt.hasMoreElements() )
+ ((XReference *)aIt.next())->dispose();
+}
+
+// XInterface
+Reference< XInterface > SAL_CALL OWeakConnectionPoint::queryAdapted() throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference< XInterface > ret;
+
+ ClearableMutexGuard guard(getWeakMutex());
+
+ if (m_pObject)
+ {
+ oslInterlockedCount n = osl_incrementInterlockedCount( &m_pObject->m_refCount );
+
+ if (n > 1)
+ {
+ // The refence is incremented. The object cannot be destroyed.
+ // Release the guard at the earliest point.
+ guard.clear();
+ // WeakObject has a (XInterface *) cast operator
+ ret = *m_pObject;
+ n = osl_decrementInterlockedCount( &m_pObject->m_refCount );
+ }
+ else
+ // Another thread wait in the dispose method at the guard
+ n = osl_decrementInterlockedCount( &m_pObject->m_refCount );
+ }
+
+ return ret;
+}
+
+// XInterface
+void SAL_CALL OWeakConnectionPoint::addReference(const Reference< XReference >& rRef)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ m_aReferences.addInterface( (const Reference< XInterface > &)rRef );
+}
+
+// XInterface
+void SAL_CALL OWeakConnectionPoint::removeReference(const Reference< XReference >& rRef)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ m_aReferences.removeInterface( (const Reference< XInterface > &)rRef );
+}
+
+
+//------------------------------------------------------------------------
+//-- OWeakObject -------------------------------------------------------
+//------------------------------------------------------------------------
+
+// XInterface
+Any SAL_CALL OWeakObject::queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::queryInterface(
+ rType,
+ static_cast< XWeak * >( this ), static_cast< XInterface * >( this ) );
+}
+
+// XInterface
+void SAL_CALL OWeakObject::acquire() throw()
+{
+ osl_incrementInterlockedCount( &m_refCount );
+}
+
+// XInterface
+void SAL_CALL OWeakObject::release() throw()
+{
+ if (osl_decrementInterlockedCount( &m_refCount ) == 0)
+ {
+ if (m_pWeakConnectionPoint)
+ {
+ OWeakConnectionPoint * p = m_pWeakConnectionPoint;
+ m_pWeakConnectionPoint = 0;
+ p->dispose();
+ p->release();
+ }
+ delete this;
+ }
+}
+
+OWeakObject::~OWeakObject() throw(::com::sun::star::uno::RuntimeException)
+{
+}
+
+// XWeak
+Reference< XAdapter > SAL_CALL OWeakObject::queryAdapter(void) throw()
+{
+ if (!m_pWeakConnectionPoint)
+ {
+ // only acquire mutex if member is not created
+ MutexGuard aGuard( getWeakMutex() );
+ if( !m_pWeakConnectionPoint )
+ {
+ OWeakConnectionPoint * p = new OWeakConnectionPoint(this);
+ p->acquire();
+ m_pWeakConnectionPoint = p;
+ }
+ }
+
+ return m_pWeakConnectionPoint;
+}
+
+//------------------------------------------------------------------------
+//-- OWeakAggObject ----------------------------------------------------
+//------------------------------------------------------------------------
+OWeakAggObject::~OWeakAggObject()
+{
+}
+
+// XInterface
+void OWeakAggObject::acquire() throw()
+{
+ Reference<XInterface > x( xDelegator );
+ if (x.is())
+ x->acquire();
+ else
+ OWeakObject::acquire();
+}
+
+// XInterface
+void OWeakAggObject::release() throw()
+{
+ Reference<XInterface > x( xDelegator );
+ if (x.is())
+ x->release();
+ else
+ OWeakObject::release();
+}
+
+// XInterface
+Any OWeakAggObject::queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference< XInterface > x( xDelegator ); // harden ref
+ return (x.is() ? x->queryInterface( rType ) : queryAggregation( rType ));
+
+// // set rOut to zero, if failed
+// if( !xDelegator.queryHardRef( aUik, rOut ) )
+// {
+// XInterfaceRef x;
+// if( !xDelegator.queryHardRef( ((XInterface*)0)->getSmartUik(), x ) )
+// // reference is not valid
+// queryAggregation( aUik, rOut );
+// }
+// return rOut.is();
+}
+
+// XAggregation
+Any OWeakAggObject::queryAggregation( const Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::queryInterface(
+ rType,
+ static_cast< XInterface * >( static_cast< OWeakObject * >( this ) ),
+ static_cast< XAggregation * >( this ),
+ static_cast< XWeak * >( this ) );
+}
+
+// XAggregation
+void OWeakAggObject::setDelegator( const Reference<XInterface > & rDelegator ) throw(::com::sun::star::uno::RuntimeException)
+{
+ xDelegator = rDelegator;
+}
+
+}
+
+/** */ //for docpp
+namespace com
+{
+/** */ //for docpp
+namespace sun
+{
+/** */ //for docpp
+namespace star
+{
+/** */ //for docpp
+namespace uno
+{
+
+
+//------------------------------------------------------------------------
+//-- OWeakRefListener -----------------------------------------------------
+//------------------------------------------------------------------------
+class OWeakRefListener : public XReference
+{
+public:
+ OWeakRefListener();
+ OWeakRefListener(const OWeakRefListener& rRef);
+ OWeakRefListener(const Reference< XInterface >& xInt);
+ ~OWeakRefListener();
+
+ // XInterface
+ Any SAL_CALL queryInterface( const Type & rType ) throw();
+ void SAL_CALL acquire() throw();
+ void SAL_CALL release() throw();
+
+ // XReference
+ void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+
+ /// The reference counter.
+ oslInterlockedCount m_aRefCount;
+ /// The connection point of the weak object
+ Reference< XAdapter > m_XWeakConnectionPoint;
+
+private:
+ OWeakRefListener& SAL_CALL operator=(const OWeakRefListener& rRef);
+};
+
+OWeakRefListener::OWeakRefListener()
+ : m_aRefCount( 0 )
+{
+}
+
+OWeakRefListener::OWeakRefListener(const OWeakRefListener& rRef)
+ : m_aRefCount( 0 )
+{
+ m_XWeakConnectionPoint = rRef.m_XWeakConnectionPoint;
+
+ if (m_XWeakConnectionPoint.is())
+ m_XWeakConnectionPoint->addReference((XReference*)this);
+}
+
+OWeakRefListener::OWeakRefListener(const Reference< XInterface >& xInt)
+ : m_aRefCount( 0 )
+{
+ Reference< XWeak > xWeak( Reference< XWeak >::query( xInt ) );
+
+ if (xWeak.is())
+ {
+ m_XWeakConnectionPoint = xWeak->queryAdapter();
+
+ if (m_XWeakConnectionPoint.is())
+ {
+ m_XWeakConnectionPoint->addReference((XReference*)this);
+ }
+ }
+}
+
+OWeakRefListener::~OWeakRefListener()
+{
+ acquire(); // dont die again
+ if (m_XWeakConnectionPoint.is())
+ m_XWeakConnectionPoint->removeReference((XReference*)this);
+}
+
+// XInterface
+Any SAL_CALL OWeakRefListener::queryInterface( const Type & rType ) throw()
+{
+ return ::cppu::queryInterface(
+ rType, static_cast< XReference * >( this ), static_cast< XInterface * >( this ) );
+}
+
+// XInterface
+void SAL_CALL OWeakRefListener::acquire() throw()
+{
+ osl_incrementInterlockedCount( &m_aRefCount );
+}
+
+// XInterface
+void SAL_CALL OWeakRefListener::release() throw()
+{
+ if( ! osl_decrementInterlockedCount( &m_aRefCount ) )
+ delete this;
+}
+
+void SAL_CALL OWeakRefListener::dispose()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference< XAdapter > xAdp;
+ {
+ MutexGuard guard(cppu::getWeakMutex());
+ if( m_XWeakConnectionPoint.is() )
+ {
+ xAdp = m_XWeakConnectionPoint;
+ m_XWeakConnectionPoint.clear();
+ }
+ }
+
+ if( xAdp.is() )
+ xAdp->removeReference((XReference*)this);
+}
+
+//------------------------------------------------------------------------
+//-- WeakReferenceHelper ----------------------------------------------------------
+//------------------------------------------------------------------------
+WeakReferenceHelper::WeakReferenceHelper(const Reference< XInterface >& xInt)
+{
+ m_pImpl = new OWeakRefListener(xInt);
+ m_pImpl->acquire();
+}
+
+WeakReferenceHelper::WeakReferenceHelper(const WeakReferenceHelper& rWeakRef)
+{
+ m_pImpl = rWeakRef.m_pImpl;
+
+ if( m_pImpl )
+ m_pImpl->acquire();
+}
+
+WeakReferenceHelper& WeakReferenceHelper::operator=(const WeakReferenceHelper& rWeakRef)
+{
+ OWeakRefListener* pOldImpl;
+ {
+ // the weak reference is multithread save
+ MutexGuard guard(cppu::getWeakMutex());
+ if (m_pImpl == rWeakRef.m_pImpl)
+ return *this;
+
+ pOldImpl = m_pImpl;
+
+ m_pImpl = rWeakRef.m_pImpl;
+ if ( m_pImpl )
+ {
+ m_pImpl->acquire();
+ }
+ }
+
+ // maybe call the destructor. It is better to release the guard before this call.
+ if( pOldImpl )
+ pOldImpl->release();
+ return *this;
+}
+
+WeakReferenceHelper::~WeakReferenceHelper()
+{
+ if (m_pImpl)
+ m_pImpl->release();
+}
+
+Reference< XInterface > WeakReferenceHelper::get() const
+{
+ Reference< XAdapter > xAdp;
+ {
+ MutexGuard guard(cppu::getWeakMutex());
+ if( m_pImpl && m_pImpl->m_XWeakConnectionPoint.is() )
+ xAdp = m_pImpl->m_XWeakConnectionPoint;
+ }
+
+ if (xAdp.is())
+ return xAdp->queryAdapted();
+
+ return Reference< XInterface >();
+}
+
+}
+}
+}
+}
+
diff --git a/cppuhelper/test/helpertest.idl b/cppuhelper/test/helpertest.idl
new file mode 100644
index 000000000000..eae610df7ab7
--- /dev/null
+++ b/cppuhelper/test/helpertest.idl
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * $RCSfile: helpertest.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _TEST_CPPUTEST_IDL_
+#define _TEST_CPPUTEST_IDL_
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/uno/TypeClass.idl>
+
+module test
+{
+
+
+[ uik(a6121273-3462-11d3-87A400A0-24494732), ident("A", 1.0) ]
+interface A : com::sun::star::uno::XInterface
+{
+ string a();
+};
+
+[ uik(b227a3A0-33d6-11d1-aabe02a0-249d5590), ident("BA", 1.0) ]
+interface BA : A
+{
+ string ba();
+};
+
+[ uik(ca27a3A0-33d6-11d1-aabe02a0-249d5590), ident("CA", 1.0) ]
+interface CA : A
+{
+ string ca();
+};
+
+[ uik(dba7a3A0-33d6-11d1-aabe02a0-249d5590), ident("DBA", 1.0) ]
+interface DBA : BA
+{
+ string dba();
+};
+
+[ uik(e227a3A0-33d6-11d1-aabe02a0-249d5590), ident("E", 1.0) ]
+interface E : com::sun::star::uno::XInterface
+{
+ string e();
+};
+
+[ uik(fe27a3A0-33d6-11d1-aabe02a0-249d5590), ident("FE", 1.0) ]
+interface FE : E
+{
+ string fe();
+};
+
+[ uik(0227a3A0-33d6-11d1-aabe02a0-249d5590), ident("G", 1.0) ]
+interface G : com::sun::star::uno::XInterface
+{
+ string g();
+ string a();
+};
+
+}; //module test
+
+#endif
diff --git a/cppuhelper/test/makefile.mk b/cppuhelper/test/makefile.mk
new file mode 100644
index 000000000000..1e3ca91a1071
--- /dev/null
+++ b/cppuhelper/test/makefile.mk
@@ -0,0 +1,133 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME= cppuhelper
+TARGET= testhelper
+LIBTARGET= NO
+TARGETTYPE= CUI
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC= TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb
+UNOUCROUT= $(OUT)$/inc$/test
+INCPRE+= $(OUT)$/inc$/test
+
+OBJFILES= \
+ $(OBJ)$/testhelper.obj \
+ $(OBJ)$/testpropshlp.obj \
+ $(OBJ)$/testidlclass.obj \
+ $(OBJ)$/testproptyphlp.obj \
+ $(OBJ)$/testimplhelper.obj
+
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJFILES)
+
+APP1STDLIBS+= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+APP1DEF= $(MISC)$/$(APP1TARGET).def
+
+ALLIDLFILES:= helpertest.idl
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : $(BIN)$/cpputest.rdb \
+ unoheader \
+ ALLTAR
+
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+CPPUMAKERFLAGS =
+.IF "$(COM)" == "MSC"
+CPPUMAKERFLAGS = -L
+.ENDIF
+
+TYPES:=test.A;test.BA;test.CA;test.DBA;test.E;test.FE;test.G
+HELPERTYPES:=com.sun.star.uno.XReference;com.sun.star.uno.XAdapter;com.sun.star.uno.XAggregation;com.sun.star.uno.XWeak;com.sun.star.lang.XComponent;com.sun.star.lang.XTypeProvider;com.sun.star.lang.XEventListener;com.sun.star.lang.XSingleServiceFactory;com.sun.star.lang.XMultiServiceFactory;com.sun.star.registry.XRegistryKey;com.sun.star.lang.XInitialization;com.sun.star.lang.XServiceInfo;com.sun.star.loader.XImplementationLoader;com.sun.star.lang.IllegalAccessException
+FACTORYTYPES:=com.sun.star.lang.XComponent;com.sun.star.registry.XSimpleRegistry;com.sun.star.lang.XInitialization;com.sun.star.lang.XMultiServiceFactory;com.sun.star.loader.XImplementationLoader;com.sun.star.registry.XImplementationRegistration;com.sun.star.container.XSet;com.sun.star.lang.XSingleServiceFactory
+
+$(BIN)$/cpputest.rdb: $(ALLIDLFILES)
+ +unoidl -I$(PRJ) -I$(SOLARIDLDIR) -Burd -OH$(BIN) $?
+ +regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)}
+ +regmerge $@ / $(UNOUCRRDB)
+ touch $@
+
+unoheader: $(BIN)$/cpputest.rdb
+ +cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TYPES);$(HELPERTYPES);$(FACTORYTYPES)" $(BIN)$/cpputest.rdb
+
diff --git a/cppuhelper/test/testhelper.cxx b/cppuhelper/test/testhelper.cxx
new file mode 100644
index 000000000000..b252daa08e8a
--- /dev/null
+++ b/cppuhelper/test/testhelper.cxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * $RCSfile: testhelper.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <rtl/ustrbuf.hxx>
+#include <osl/diagnose.h>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include "testhelper.hxx"
+
+using namespace rtl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int __cdecl main( int argc, char * argv[] )
+#endif
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("cpputest.rdb") ) ) );
+
+ sal_Bool bSucc = sal_False;
+ try
+ {
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.ImplementationRegistration") ) ),
+ UNO_QUERY );
+ OSL_ENSHURE( xImplReg.is(), "### no impl reg!" );
+
+#ifdef UNX
+#define REG_PREFIX "lib"
+#define DLL_POSTFIX ".so"
+#else
+#define REG_PREFIX ""
+#define DLL_POSTFIX ".dll"
+#endif
+ OString aLibName( REG_PREFIX );
+ aLibName += "corefl";
+#ifndef OS2
+ aLibName += DLL_POSTFIX;
+#endif
+ xImplReg->registerImplementation(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary") ),
+ OUString::createFromAscii( aLibName.getStr() ),
+ Reference< XSimpleRegistry >() );
+
+ testPropertyTypeHelper();
+ testidlclass( xMgr );
+ test_PropertySetHelper();
+ test_ImplHelper( xMgr );
+ }
+ catch (Exception & rExc)
+ {
+ OSL_ENSHURE( sal_False, "### exception occured!" );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### exception occured: " );
+ OSL_TRACE( aMsg.getStr() );
+ OSL_TRACE( "\n" );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+
+ printf( "Test finished\n" );
+ return 0;
+}
diff --git a/cppuhelper/test/testhelper.hxx b/cppuhelper/test/testhelper.hxx
new file mode 100644
index 000000000000..602fd19ca8e0
--- /dev/null
+++ b/cppuhelper/test/testhelper.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * $RCSfile: testhelper.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+void testidlclass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &r);
+void testPropertyTypeHelper();
+void test_PropertySetHelper();
+void test_ImplHelper( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > & xSF );
diff --git a/cppuhelper/test/testidlclass.cxx b/cppuhelper/test/testidlclass.cxx
new file mode 100644
index 000000000000..bcf2cb8b9aa2
--- /dev/null
+++ b/cppuhelper/test/testidlclass.cxx
@@ -0,0 +1,259 @@
+/*************************************************************************
+ *
+ * $RCSfile: testidlclass.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:10 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <assert.h>
+
+#include <cppuhelper/stdidlclass.hxx>
+
+#include <com/sun/star/reflection/XIdlClassProvider.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include "testhelper.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::reflection;
+using namespace ::rtl;
+
+
+
+
+void testidlclass( const Reference < XMultiServiceFactory > &rSMgr)
+{
+ const OUString sImplName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.cpputest") ) );
+
+ // this reference is static to test behaviour during exiting application
+ static Reference < XIdlClass > r =
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+
+ assert( r.is() );
+
+
+ { // test the xidlclassprovider interface !
+ Reference< XIdlClassProvider > rProv( r , UNO_QUERY );
+ assert( rProv.is() );
+
+ {
+ Sequence < Reference < XIdlClass > > seq = rProv->getIdlClasses();
+
+ // is always one
+ assert( seq.getLength() == 1 );
+
+ // test the weak reference
+ rProv->getIdlClasses();
+
+ }
+
+ rProv->getIdlClasses();
+
+
+ }
+
+
+ assert( r->getName() == sImplName );
+
+ // test equals
+ Reference < XIdlClass > r2 =
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+ // test for implementation name
+ assert( r2->equals( r ) );
+
+ Sequence < Reference < XIdlClass > > seqIdlClass = r->getInterfaces();
+
+ //TODO !
+ // one idl class for one interface
+ // this test fails, if core reflection fails !
+// assert( 1 == seqIdlClass.getLength() );
+// Reference < XIdlClass > rIdlInterface = seqIdlClass.getArray()[0];
+
+ // check for IdlClass interface returned by Core Reflection
+// assert( rIdlInterface.is() );
+
+
+
+ // Test all ten templates
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+
+ // Test all ten templates
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+
+
+ // Test all ten templates
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+
+
+
+ // Test all ten templates
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+
+
+
+ // Test all ten templates
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+
+
+ // Test all ten templates
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+
+
+
+
+ // Test all ten templates
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+
+ // Test all ten templates
+ ::cppu::createStandardClass(
+ rSMgr ,
+ sImplName,
+ Reference < XIdlClass > () ,
+ (XMultiServiceFactory * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0 ,
+ (XServiceInfo * ) 0
+ );
+}
diff --git a/cppuhelper/test/testimplhelper.cxx b/cppuhelper/test/testimplhelper.cxx
new file mode 100644
index 000000000000..0a0f1c1e18ba
--- /dev/null
+++ b/cppuhelper/test/testimplhelper.cxx
@@ -0,0 +1,387 @@
+/*************************************************************************
+ *
+ * $RCSfile: testimplhelper.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <osl/diagnose.h>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+
+#include <test/A.hpp>
+#include <test/BA.hpp>
+#include <test/CA.hpp>
+#include <test/DBA.hpp>
+#include <test/E.hpp>
+#include <test/FE.hpp>
+#include <test/G.hpp>
+
+#include <com/sun/star/lang/IllegalAccessException.hpp>
+
+using namespace test;
+using namespace rtl;
+using namespace osl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+
+//==================================================================================================
+struct TestImpl : public ImplHelper4< CA, DBA, FE, G >
+{
+ sal_Int32 nRef;
+
+ virtual ~TestImpl()
+ { OSL_TRACE( "> TestImpl dtor called... <\n" ); }
+
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+ { return ImplHelper4< CA, DBA, FE, G >::queryInterface( rType ); }
+ virtual void SAL_CALL acquire( ) throw(::com::sun::star::uno::RuntimeException)
+ { ++nRef; }
+ virtual void SAL_CALL release( ) throw(::com::sun::star::uno::RuntimeException)
+ { if (! --nRef) delete this; }
+
+ // A
+ virtual OUString SAL_CALL a() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
+ // BA
+ virtual OUString SAL_CALL ba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
+ // CA
+ virtual OUString SAL_CALL ca() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
+ // DBA
+ virtual OUString SAL_CALL dba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
+ // E
+ virtual OUString SAL_CALL e() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
+ // FE
+ virtual OUString SAL_CALL fe() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
+ // G
+ virtual OUString SAL_CALL g() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
+};
+
+//==================================================================================================
+struct TestWeakAggImpl : public WeakAggImplHelper4< CA, DBA, FE, G >
+{
+ virtual ~TestWeakAggImpl()
+ { OSL_TRACE( "> TestWeakAggImpl dtor called... <\n" ); }
+
+ // A
+ virtual OUString SAL_CALL a() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
+ // BA
+ virtual OUString SAL_CALL ba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
+ // CA
+ virtual OUString SAL_CALL ca() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
+ // DBA
+ virtual OUString SAL_CALL dba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
+ // E
+ virtual OUString SAL_CALL e() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
+ // FE
+ virtual OUString SAL_CALL fe() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
+ // G
+ virtual OUString SAL_CALL g() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
+};
+
+//==================================================================================================
+struct TestWeakImpl : public WeakImplHelper4< CA, DBA, FE, G >
+{
+ virtual ~TestWeakImpl()
+ { OSL_TRACE( "> TestWeakImpl dtor called... <\n" ); }
+
+ // A
+ virtual OUString SAL_CALL a() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
+ // BA
+ virtual OUString SAL_CALL ba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
+ // CA
+ virtual OUString SAL_CALL ca() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
+ // DBA
+ virtual OUString SAL_CALL dba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
+ // E
+ virtual OUString SAL_CALL e() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
+ // FE
+ virtual OUString SAL_CALL fe() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
+ // G
+ virtual OUString SAL_CALL g() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
+};
+
+//==================================================================================================
+struct TestWeakComponentImpl : public WeakComponentImplHelper4< CA, DBA, FE, G >
+{
+ Mutex m;
+ TestWeakComponentImpl()
+ : WeakComponentImplHelper4< CA, DBA, FE, G >( m )
+ {}
+ virtual ~TestWeakComponentImpl()
+ { OSL_TRACE( "> TestWeakComponentImpl dtor called... <\n" ); }
+
+ void SAL_CALL disposing()
+ { OSL_TRACE( "> TestWeakComponentImpl disposing called... <\n" ); }
+
+ // A
+ virtual OUString SAL_CALL a() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
+ // BA
+ virtual OUString SAL_CALL ba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
+ // CA
+ virtual OUString SAL_CALL ca() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
+ // DBA
+ virtual OUString SAL_CALL dba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
+ // E
+ virtual OUString SAL_CALL e() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
+ // FE
+ virtual OUString SAL_CALL fe() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
+ // G
+ virtual OUString SAL_CALL g() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
+};
+
+//==================================================================================================
+struct TestWeakAggComponentImpl : public WeakAggComponentImplHelper4< CA, DBA, FE, G >
+{
+ Mutex m;
+ TestWeakAggComponentImpl()
+ : WeakAggComponentImplHelper4< CA, DBA, FE, G >( m )
+ {}
+ virtual ~TestWeakAggComponentImpl()
+ { OSL_TRACE( "> TestWeakAggComponentImpl dtor called... <\n" ); }
+
+ void SAL_CALL disposing()
+ { OSL_TRACE( "> TestWeakAggComponentImpl disposing called... <\n" ); }
+
+ // A
+ virtual OUString SAL_CALL a() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
+ // BA
+ virtual OUString SAL_CALL ba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
+ // CA
+ virtual OUString SAL_CALL ca() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
+ // DBA
+ virtual OUString SAL_CALL dba() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
+ // E
+ virtual OUString SAL_CALL e() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
+ // FE
+ virtual OUString SAL_CALL fe() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
+ // G
+ virtual OUString SAL_CALL g() throw(RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
+};
+
+//==================================================================================================
+static void dotest( const Reference< XInterface > & xOriginal )
+{
+ Reference< A > xa( xOriginal, UNO_QUERY );
+ OSL_ENSHURE( xa->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### A failed!" );
+ Reference< BA > xba( xa, UNO_QUERY );
+ OSL_ENSHURE( xba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### BA failed!" );
+ OSL_ENSHURE( xba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### BA failed!" );
+ Reference< CA > xca( xba, UNO_QUERY );
+ OSL_ENSHURE( xca->ca().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ca") ), "### CA failed!" );
+ OSL_ENSHURE( xca->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### CA failed!" );
+ Reference< DBA > xdba( xca, UNO_QUERY );
+ OSL_ENSHURE( xdba->dba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dba") ), "### DBA failed!" );
+ OSL_ENSHURE( xdba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### DBA failed!" );
+ OSL_ENSHURE( xdba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### DBA failed!" );
+ Reference< E > xe( xdba, UNO_QUERY );
+ OSL_ENSHURE( xe->e().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("e") ), "### E failed!" );
+ Reference< FE > xfe( xe, UNO_QUERY );
+ OSL_ENSHURE( xfe->fe().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fe") ), "### FE failed!" );
+ Reference< G > xg( xfe, UNO_QUERY );
+ OSL_ENSHURE( xg->g().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("g") ), "### G failed!" );
+ OSL_ENSHURE( xg->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### G failed!" );
+
+ // type provider
+ Reference< XTypeProvider > xProv( xg, UNO_QUERY );
+ Sequence< Type > aTypes( xProv->getTypes() );
+
+ // CA, DBA, FE, G, XTypeProvider
+ OSL_ASSERT( aTypes[0].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("test.CA") ) );
+ OSL_ASSERT( aTypes[1].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("test.DBA") ) );
+ OSL_ASSERT( aTypes[2].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("test.FE") ) );
+ OSL_ASSERT( aTypes[3].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("test.G") ) );
+ OSL_ASSERT( aTypes[4].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.lang.XTypeProvider") ) );
+
+ Reference< XComponent > xComp( xg, UNO_QUERY );
+ Reference< XAggregation > xAgg( xg, UNO_QUERY );
+ if (xComp.is())
+ {
+ if (xAgg.is())
+ {
+ OSL_ASSERT( aTypes[5].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XWeak") ) );
+ OSL_ASSERT( aTypes[6].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XAggregation") ) );
+ OSL_ASSERT( aTypes[7].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.lang.XComponent") ) );
+ OSL_ASSERT( aTypes.getLength() == 8 );
+ }
+ else
+ {
+ OSL_ASSERT( aTypes[5].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XWeak") ) );
+ OSL_ASSERT( aTypes[6].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.lang.XComponent") ) );
+ OSL_ASSERT( aTypes.getLength() == 7 );
+ }
+ }
+ else
+ {
+ if (xAgg.is())
+ {
+ OSL_ASSERT( aTypes[5].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XWeak") ) );
+ OSL_ASSERT( aTypes[6].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XAggregation") ) );
+ OSL_ASSERT( aTypes.getLength() == 7 );
+ }
+ else
+ {
+ Reference< XWeak > xWeak( xg, UNO_QUERY );
+ if (xWeak.is())
+ {
+ OSL_ASSERT( aTypes[5].getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XWeak") ) );
+ OSL_ASSERT( aTypes.getLength() == 6 );
+ }
+ else
+ {
+ OSL_ASSERT( aTypes.getLength() == 5 );
+ }
+ }
+ }
+
+ OSL_ENSHURE( Reference< XInterface >::query( xg ) == xOriginal, "### root!" );
+}
+
+//==================================================================================================
+void test_ImplHelper( const Reference< XMultiServiceFactory > & xSF )
+{
+ Reference< XInterface > xImpl( (XTypeProvider *)new TestImpl() );
+ Reference< XInterface > xWeakImpl( (OWeakObject *)new TestWeakImpl() );
+ Reference< XInterface > xWeakAggImpl( (OWeakObject *)new TestWeakAggImpl() );
+ Reference< XInterface > xWeakComponentImpl( (OWeakObject *)new TestWeakComponentImpl() );
+ Reference< XInterface > xWeakAggComponentImpl( (OWeakObject *)new TestWeakAggComponentImpl() );
+ dotest( xImpl );
+ dotest( xWeakImpl );
+ dotest( xWeakAggImpl );
+ dotest( xWeakComponentImpl );
+ dotest( xWeakAggComponentImpl );
+ //
+
+ // exception helper test
+ try
+ {
+ throwException( makeAny( RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("runtime exc") ), xImpl ) ) );
+ }
+ catch (RuntimeException & rExc)
+ {
+ OSL_ENSHURE( rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("runtime exc") ) && rExc.Context == xImpl,
+ "### unexpected exception content!" );
+ try
+ {
+ throwException( makeAny( Exception(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("exc") ), rExc.Context ) ) );
+ }
+ catch (IllegalAccessException &)
+ {
+ OSL_ENSHURE( sal_False, "### unexpected IllegalAccessException exception caught!" );
+ }
+ catch (Exception rExc)
+ {
+ OSL_ENSHURE( rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("exc") ) && rExc.Context == xImpl,
+ "### unexpected exception content!" );
+ try
+ {
+ throwException( makeAny( IllegalAccessException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("axxess exc") ), rExc.Context ) ) );
+ }
+ catch (IllegalAccessException & rExc)
+ {
+ OSL_ENSHURE( rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("axxess exc") ) && rExc.Context == xImpl,
+ "### unexpected exception content!" );
+ return;
+ }
+ }
+ }
+ catch (...)
+ {
+ }
+ OSL_ENSHURE( sal_False, "### exception test failed!" );
+}
+
diff --git a/cppuhelper/test/testpropshlp.cxx b/cppuhelper/test/testpropshlp.cxx
new file mode 100644
index 000000000000..0626375085c2
--- /dev/null
+++ b/cppuhelper/test/testpropshlp.cxx
@@ -0,0 +1,1198 @@
+/*************************************************************************
+ *
+ * $RCSfile: testpropshlp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <osl/mutex.hxx>
+#include <osl/diagnose.h>
+
+#include <cppuhelper/propshlp.hxx>
+#include <cppuhelper/weak.hxx>
+
+#include <cppuhelper/proptypehlp.hxx>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include <cppuhelper/implbase3.hxx>
+
+using namespace ::cppu;
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+
+
+
+/**********************
+*
+**********************/
+static Property * getPropertyTable1()
+{
+ static Property *pTable = 0;
+
+ if( ! pTable ) {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pTable ) {
+ static Property aTable[] =
+ {
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString *)0) ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //OUString
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ) ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //Char
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0) ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //sal_Int32
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //double
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //BOOL
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any*)0) ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) //Any
+ };
+ pTable = aTable;
+ }
+ }
+ return pTable;
+}
+
+
+static Property * getPropertyTable2()
+{
+ static Property *pTable = 0;
+
+ if( ! pTable ) {
+ MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! pTable ) {
+ static Property aTable[] =
+ {
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Any
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Double
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0),
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // sal_Int32
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Bool
+ };
+ pTable = aTable;
+ }
+ }
+ return pTable;
+}
+
+static Property * getPropertyTable3()
+{
+ static Property *pTable = 0;
+
+ if( ! pTable ) {
+ MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! pTable ) {
+ static Property aTable[] =
+ {
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // any
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // OUString
+ };
+ pTable = aTable;
+ }
+ }
+ return pTable;
+}
+
+
+static Property * getPropertyTable4()
+{
+ static Property *pTable = 0;
+
+ if( ! pTable ) {
+ MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! pTable ) {
+ static Property aTable[] =
+ {
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 2, getCppuType( (Any *)0) ,
+ PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Any
+ };
+ pTable = aTable;
+ }
+ }
+ return pTable;
+}
+
+
+
+/**********************
+*
+* Note : all Property names must be in the 127 ASCII subset !
+*
+**********************/
+
+
+void test_PropertyArrayHelper()
+{
+ // Test getProperties() and getCount()
+ {
+ OPropertyArrayHelper a1( getPropertyTable1(), 6 );
+ OSL_ENSHURE( 6 == a1.getCount(), "not all properties inserted" );
+ Sequence< Property > aProps = a1.getProperties();
+ Property * pP = aProps.getArray();
+ OSL_ENSHURE( 6 == aProps.getLength(), "getProperties() gives not all properties" );
+ for( int i = 0; i < 6; i++ )
+ {
+ OSL_ENSHURE( pP[i].Name == getPropertyTable1()[i].Name , "Name not correct" );
+ OSL_ENSHURE( pP[i].Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
+ OSL_ENSHURE( pP[i].Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" );
+ OSL_ENSHURE( pP[i].Type == getPropertyTable1()[i].Type, "Type not correct" );
+ }
+ }
+
+ // Test sorting
+ {
+ OPropertyArrayHelper a1( getPropertyTable2(), 6, sal_False );
+ Sequence< Property > aProps = a1.getProperties();
+ Property * pP = aProps.getArray();
+ OSL_ENSHURE( 6 == aProps.getLength(), "getProperties() gives not all properties" );
+ for( int i = 0; i < 6; i++ )
+ {
+ OSL_ENSHURE( pP[i].Name == getPropertyTable2()[i].Name , "Name not correct" );
+ OSL_ENSHURE( pP[i].Handle == getPropertyTable2()[i].Handle, "Handle not correct" );
+ OSL_ENSHURE( pP[i].Attributes == getPropertyTable2()[i].Attributes, "Attributes not correct" );
+ OSL_ENSHURE( pP[i].Type == getPropertyTable2()[i].Type, "Type not correct" );
+ }
+ }
+
+ // Test sorting
+ {
+ OPropertyArrayHelper a1( getPropertyTable3(), 3, sal_False );
+ Sequence< Property > aProps = a1.getProperties();
+ Property * pP = aProps.getArray();
+ OSL_ENSHURE( 3 == aProps.getLength(), "getProperties() gives not all properties" );
+ for( int i = 0; i < 3; i++ )
+ {
+ OSL_ENSHURE( pP[i].Name == getPropertyTable3()[i].Name , "Name not correct" );
+ OSL_ENSHURE( pP[i].Handle == getPropertyTable3()[i].Handle, "Handle not correct" );
+ OSL_ENSHURE( pP[i].Attributes == getPropertyTable3()[i].Attributes, "Attributes not correct" );
+ OSL_ENSHURE( pP[i].Type == getPropertyTable3()[i].Type, "Type not correct" );
+ }
+ }
+
+ // Test getPropertyByName and hasPropertyByName
+ {
+ OPropertyArrayHelper a1( getPropertyTable1(), 6 );
+ for( int i = 0; i < 6; i++ )
+ {
+ OSL_ENSHURE( a1.hasPropertyByName( getPropertyTable1()[i].Name ), "hasPropertyByName not correct" );
+ Property aP = a1.getPropertyByName( getPropertyTable1()[i].Name );
+ OSL_ENSHURE( aP.Name == getPropertyTable1()[i].Name , "Name not correct" );
+ OSL_ENSHURE( aP.Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
+ OSL_ENSHURE( aP.Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" );
+ OSL_ENSHURE( aP.Type == getPropertyTable1()[i].Type, "Type not correct" );
+ }
+
+ OSL_ENSHURE( !a1.hasPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) ), "hasPropertyByName not correct" );
+ try
+ {
+ a1.getPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) );
+ OSL_ENSHURE( sal_False, "exeption not thrown" );
+ }
+ catch( UnknownPropertyException & )
+ {
+ }
+ }
+
+ // Test getHandleByName
+ {
+ OPropertyArrayHelper a1( getPropertyTable1(), 6 );
+ for( int i = 0; i < 6; i++ )
+ {
+ sal_Int32 Handle = a1.getHandleByName( getPropertyTable1()[i].Name );
+ OSL_ENSHURE( Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
+ }
+ sal_Int32 Handle = a1.getHandleByName( OUString( RTL_CONSTASCII_USTRINGPARAM("asdaf") ) );
+ OSL_ENSHURE( Handle == -1, "Handle not correct" );
+ }
+
+ // Test fillPropertyMembersByHandle
+ {
+ OPropertyArrayHelper a1( getPropertyTable1(), 6 );
+ int i;
+ for( i = 0; i < 6; i++ )
+ {
+ sal_Int16 nAttributes;
+ OUString aPropName;
+ sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable1()[i].Handle );
+ OSL_ENSHURE( b, "fillPropertyMembersByHandle: handle not found" );
+ OSL_ENSHURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" );
+ OSL_ENSHURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" );
+ }
+ OSL_ENSHURE( !a1.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" );
+ // optimized table
+ OPropertyArrayHelper a4( getPropertyTable4(), 3 );
+ for( i = 0; i < 3; i++ )
+ {
+ sal_Int16 nAttributes;
+ OUString aPropName;
+ sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable4()[i].Handle );
+ OSL_ENSHURE( b, "fillPropertyMembersByHandle: handle not found" );
+ OSL_ENSHURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" );
+ OSL_ENSHURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" );
+ }
+ OSL_ENSHURE( !a4.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" );
+ }
+
+ // Test fillHandles
+ {
+ OPropertyArrayHelper a1( getPropertyTable1(), 6 );
+ Sequence< OUString > aS( 4 );
+ sal_Int32 Handles[4];
+ // muss sortiert sein
+ aS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("a") );
+ aS.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("d") );
+ aS.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("f") );
+ aS.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("t") );
+ sal_Int32 nHitCount = a1.fillHandles( Handles, aS );
+ OSL_ENSHURE( nHitCount == 3, "wrong number of hits " );
+ OSL_ENSHURE( Handles[0] == getPropertyTable1()[0].Handle, "Handle not correct" );
+ OSL_ENSHURE( Handles[1] == getPropertyTable1()[3].Handle, "Handle not correct" );
+ OSL_ENSHURE( Handles[2] == getPropertyTable1()[5].Handle, "Handle not correct" );
+ OSL_ENSHURE( Handles[3] == -1, "Handle not correct" );
+ }
+}
+
+
+
+
+//----------------------------------------------------
+// test_OPropertySetHelper
+//----------------------------------------------------
+struct MutexContainer
+{
+ Mutex aMutex;
+};
+class test_OPropertySetHelper :
+ public MutexContainer,
+ public OBroadcastHelper ,
+ public OPropertySetHelper,
+ public OWeakObject
+{
+public:
+
+ test_OPropertySetHelper( Property * p, sal_Int32 n )
+ : MutexContainer()
+ , OBroadcastHelper( ((MutexContainer *)this)->aMutex )
+// , OPropertySetHelper( *SAL_STATIC_CAST(OBroadcastHelper *,this))
+ // MSCI 4 bug ! :
+ // OBroadcastHelper == OBroadcastHelperVar<OMultiTypeInterfaceContainerHelper>
+ , OPropertySetHelper(
+ *SAL_STATIC_CAST(OBroadcastHelperVar<OMultiTypeInterfaceContainerHelper> *,this))
+ , bBOOL( sal_False )
+ , nINT16( 0 )
+ , nINT32( 0 )
+ , pBasicProps( p )
+ , nPropCount( n )
+ {
+ }
+
+
+ ~test_OPropertySetHelper()
+ {
+ }
+
+ void dispose()
+ {
+ // see comphlp.cxx
+ sal_Bool bDoDispose = sal_False;
+ {
+ MutexGuard aGuard( rBHelper.rMutex );
+ if( !rBHelper.bDisposed && !rBHelper.bInDispose )
+ {
+ rBHelper.bInDispose = sal_True;
+ bDoDispose = sal_True;
+ }
+ }
+ if( bDoDispose )
+ {
+ disposing();
+ EventObject aEvt;
+ aEvt.Source = Reference < XInterface > ( SAL_STATIC_CAST( OWeakObject * ,this) );
+
+ rBHelper.aLC.disposeAndClear( aEvt );
+ rBHelper.bDisposed = sal_True;
+ rBHelper.bInDispose = sal_False;
+ }
+ }
+
+ // XInterface
+ Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
+ {
+ Any aRet( OPropertySetHelper::queryInterface( rType ) );
+ return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
+ }
+ void SAL_CALL acquire()
+ { OWeakObject::acquire(); }
+ void SAL_CALL release()
+ { OWeakObject::release(); }
+
+ // XPropertySet
+ Reference < XPropertySetInfo > SAL_CALL getPropertySetInfo();
+
+ sal_Bool bBOOL;
+ sal_Int16 nINT16;
+ sal_Int32 nINT32;
+ Property * pBasicProps;
+ sal_Int32 nPropCount;
+protected:
+ IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ sal_Bool SAL_CALL convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue,
+ sal_Int32 nHandle, const Any& rValue );
+ void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue );
+ void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const;
+};
+
+//----------------------------------------------------------------------
+//------ The Properties of this implementation -------------------------
+//----------------------------------------------------------------------
+// Id must be the index into the array
+#define PROPERTY_BOOL 0
+#define PROPERTY_INT16 1
+#define PROPERTY_INT32 2
+
+// Max number of properties
+#define PROPERTY_COUNT 4
+// Names of Properties
+/**
+ * All Properties of this implementation. Must be sorted by name.
+ */
+Property * getBasicProps()
+{
+ static Property *pTable = 0;
+
+ if( ! pTable ) {
+ MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if( ! pTable ) {
+
+ static Property aBasicProps[PROPERTY_COUNT] =
+ {
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) , PROPERTY_BOOL , getCppuBooleanType(), PropertyAttribute::READONLY ),
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , PROPERTY_INT16,
+ getCppuType( (sal_Int16*)0 ), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ),
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) , PROPERTY_INT32, getCppuType( (sal_Int32*)0 ), PropertyAttribute::BOUND ),
+ Property( OUString( RTL_CONSTASCII_USTRINGPARAM("TEST") ) , 55 , getCppuType( (sal_Int32*)0), PropertyAttribute::BOUND )
+ };
+ pTable = aBasicProps;
+ }
+ }
+ return pTable;
+}
+
+
+//----------------------------------------------------
+// test_OPropertySetHelper_Listener
+//----------------------------------------------------
+class test_OPropertySetHelper_Listener
+ : public WeakImplHelper3< XPropertyChangeListener, XPropertiesChangeListener, XVetoableChangeListener >
+{
+public:
+ sal_Int32 nDisposing;
+ Mutex aMutex;
+ Any * pExceptedListenerValues;
+ sal_Int32 nCount;
+ sal_Int32 nCurrent;
+
+ test_OPropertySetHelper_Listener( Any * p = 0, sal_Int32 n = 0 )
+ : nDisposing( 0 )
+ , pExceptedListenerValues( p )
+ , nCount( n )
+ , nCurrent( 0 )
+ {
+ }
+ ~test_OPropertySetHelper_Listener()
+ {
+ }
+
+ sal_Int32 getRefCount()
+ { return m_refCount; }
+
+ // XEventListener
+ void SAL_CALL disposing(const EventObject& evt) throw ( RuntimeException)
+ {
+ MutexGuard aGuard( aMutex );
+ nDisposing++;
+ }
+
+ // XPropertyChangeListener
+ void SAL_CALL propertyChange(const PropertyChangeEvent& evt) throw (RuntimeException)
+ {
+ if( !pExceptedListenerValues )
+ return;
+ MutexGuard aGuard( aMutex );
+ OSL_ENSHURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
+
+ switch( evt.PropertyHandle )
+ {
+ case PROPERTY_BOOL:
+ {
+ OSL_ENSHURE( sal_False , "PropertySetHelper: BOOL cannot change" );
+ OSL_ENSHURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
+ }
+ break;
+
+ case PROPERTY_INT16:
+ {
+ OSL_ENSHURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
+
+ OSL_ENSHURE( pExceptedListenerValues[nCurrent].getValueType().getTypeClass() == TypeClass_SHORT ,
+ "PropertySetHelper: wrong data type" );
+
+ sal_Int16 nInt16, nOldInt16;
+ pExceptedListenerValues[nCurrent] >>= nInt16;
+ evt.OldValue >>= nOldInt16;
+ OSL_ENSHURE( nInt16 == nOldInt16, "PropertySetHelper: wrong old value" );
+
+
+ pExceptedListenerValues[nCurrent+1] >>= nInt16;
+ evt.NewValue >>= nOldInt16;
+ OSL_ENSHURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
+ }
+ break;
+
+ case PROPERTY_INT32:
+ {
+ OSL_ENSHURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
+
+ sal_Int32 nInt32,nOldInt32;
+
+ pExceptedListenerValues[nCurrent] >>= nInt32;
+ evt.OldValue >>= nOldInt32;
+ OSL_ENSHURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
+
+ pExceptedListenerValues[nCurrent+1] >>= nInt32;
+ evt.NewValue >>= nOldInt32;
+ OSL_ENSHURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
+ }
+ break;
+
+ default:
+ OSL_ENSHURE( sal_False, "XPropeSetHelper: invalid property handle" );
+ }
+ nCurrent += 2;
+ }
+
+ // XVetoableChangeListener
+ void SAL_CALL vetoableChange(const PropertyChangeEvent& evt) throw (PropertyVetoException, RuntimeException)
+ {
+ if( !pExceptedListenerValues )
+ return;
+ MutexGuard aGuard( aMutex );
+ OSL_ENSHURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
+
+ switch( evt.PropertyHandle )
+ {
+ case PROPERTY_BOOL:
+ {
+ OSL_ENSHURE( sal_False , "PropertySetHelper: BOOL cannot change" );
+ OSL_ENSHURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
+ }
+ break;
+
+ case PROPERTY_INT16:
+ {
+ OSL_ENSHURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
+
+ sal_Int16 nInt16, nOldInt16;
+ pExceptedListenerValues[nCurrent] >>= nInt16;
+ evt.OldValue >>= nOldInt16;
+
+ OSL_ENSHURE( nInt16 == nOldInt16,"PropertySetHelper: wrong old value" );
+
+ pExceptedListenerValues[nCurrent+1] >>= nInt16;
+ evt.NewValue >>= nOldInt16;
+ OSL_ENSHURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
+
+ if( nOldInt16 == 100 )
+ {
+ nCurrent += 2;
+ throw PropertyVetoException();
+ }
+ }
+ break;
+
+ case PROPERTY_INT32:
+ {
+ OSL_ENSHURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
+
+ sal_Int32 nInt32,nOldInt32;
+ pExceptedListenerValues[nCurrent] >>= nInt32;
+ evt.OldValue >>= nOldInt32;
+ OSL_ENSHURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
+
+ pExceptedListenerValues[nCurrent+1] >>= nInt32;
+ evt.NewValue >>= nOldInt32;
+ OSL_ENSHURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
+ }
+ break;
+
+ default:
+ OSL_ENSHURE( sal_False, "XPropeSetHelper: invalid property handle" );
+ }
+ nCurrent += 2;
+ }
+
+ // XPropertiesChangeListener
+ void SAL_CALL propertiesChange(const Sequence< PropertyChangeEvent >& evtSeq) throw (RuntimeException)
+ {
+ if( !pExceptedListenerValues )
+ return;
+ MutexGuard aGuard( aMutex );
+ for( sal_Int32 i = 0; i < evtSeq.getLength(); i++ )
+ {
+ const PropertyChangeEvent & evt = evtSeq.getConstArray()[i];
+ OSL_ENSHURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
+
+ switch( evt.PropertyHandle )
+ {
+ case PROPERTY_BOOL:
+ {
+ OSL_ENSHURE( sal_False, "PropertySetHelper: BOOL cannot change" );
+ OSL_ENSHURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
+ }
+ break;
+
+ case PROPERTY_INT16:
+ {
+ OSL_ENSHURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
+
+ sal_Int16 nInt16, nOldInt16;
+ pExceptedListenerValues[nCurrent] >>= nInt16;
+ evt.OldValue >>= nOldInt16;
+ OSL_ENSHURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong old value" );
+
+
+ pExceptedListenerValues[nCurrent+1] >>= nInt16;
+ evt.NewValue >>= nOldInt16;
+ OSL_ENSHURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
+ }
+ break;
+
+ case PROPERTY_INT32:
+ {
+ OSL_ENSHURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
+
+
+ sal_Int32 nInt32,nOldInt32;
+ pExceptedListenerValues[nCurrent] >>= nInt32;
+ evt.OldValue >>= nOldInt32;
+ OSL_ENSHURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
+
+ pExceptedListenerValues[nCurrent+1] >>= nInt32;
+ evt.NewValue >>= nOldInt32;
+ OSL_ENSHURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
+ }
+ break;
+
+ default:
+ OSL_ENSHURE( sal_False, "XPropeSetHelper: invalid property handle" );
+ }
+ nCurrent += 2;
+ }
+ }
+};
+
+/**
+ * Create a table that map names to index values.
+ */
+IPropertyArrayHelper & test_OPropertySetHelper::getInfoHelper()
+{
+ // no multi thread protection
+ static OPropertyArrayHelper aInfo( pBasicProps, nPropCount );
+ return aInfo;
+}
+
+// XPropertySet
+Reference < XPropertySetInfo > test_OPropertySetHelper::getPropertySetInfo()
+{
+ // no multi thread protection
+ static Reference < XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+// Return sal_True, value changed
+sal_Bool test_OPropertySetHelper::convertFastPropertyValue
+(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue
+)
+{
+ switch( nHandle )
+ {
+ case PROPERTY_BOOL:
+ {
+ sal_Bool b;
+ convertPropertyValue( b , rValue );
+ if( b != bBOOL )
+ {
+
+ rConvertedValue.setValue( &b , ::getCppuBooleanType() );
+ rOldValue.setValue( & bBOOL , ::getCppuBooleanType() );
+ return sal_True;
+ }
+ else
+ return sal_False;
+ }
+ break;
+
+ case PROPERTY_INT16:
+ {
+ sal_Int16 n16;
+ convertPropertyValue( n16 , rValue );
+
+ if( n16 != nINT16 )
+ {
+ rConvertedValue <<= n16;
+ rOldValue <<= nINT16;
+ return sal_True;
+ }
+ else
+ return sal_False;
+ }
+ break;
+
+ case PROPERTY_INT32:
+ {
+ sal_Int32 n32;
+ convertPropertyValue( n32 , rValue );
+ if( n32 != nINT32 )
+ {
+ rConvertedValue <<= n32;
+ rOldValue <<= nINT32;
+ return sal_True;
+ }
+ else
+ return sal_False;
+ }
+ break;
+
+ default:
+ OSL_ENSHURE( nHandle == -1, "invalid property handle" );
+ return sal_False;
+ }
+}
+
+/**
+ * only set the value.
+ */
+void test_OPropertySetHelper::setFastPropertyValue_NoBroadcast
+(
+ sal_Int32 nHandle,
+ const Any& rValue
+)
+{
+ switch( nHandle )
+ {
+ case PROPERTY_BOOL:
+ OSL_ENSHURE( rValue.getValueType().getTypeClass() == TypeClass_BOOLEAN, "invalid type" );
+ bBOOL = *((sal_Bool*)rValue.getValue());
+ break;
+
+ case PROPERTY_INT16:
+ OSL_ENSHURE( rValue.getValueType().getTypeClass() == TypeClass_SHORT, "invalid type" );
+ rValue >>= nINT16;
+ break;
+
+ case PROPERTY_INT32:
+ OSL_ENSHURE( rValue.getValueType().getTypeClass() == TypeClass_LONG, "invalid type" );
+ rValue >>= nINT32;
+ break;
+
+ default:
+ OSL_ENSHURE( nHandle == -1, "invalid property handle" );
+ }
+}
+
+//--------------------------
+void test_OPropertySetHelper::getFastPropertyValue( Any & rRet, sal_Int32 nHandle ) const
+{
+ switch( nHandle )
+ {
+ case PROPERTY_BOOL:
+ rRet.setValue( &bBOOL , getCppuBooleanType() );
+ break;
+
+ case PROPERTY_INT16:
+ rRet <<= nINT16;
+ break;
+
+ case PROPERTY_INT32:
+ rRet <<= nINT32;
+ break;
+
+ default:
+ OSL_ENSHURE( nHandle == -1, "invalid property handle" );
+ }
+}
+
+
+void test_PropertySetHelper()
+{
+ test_PropertyArrayHelper();
+
+ test_OPropertySetHelper * pPS;
+
+ Reference < XPropertySet > xPS;
+ Reference < XPropertyChangeListener > xPS_L;
+ test_OPropertySetHelper_Listener * pPS_L;
+
+ Reference < XInterface > x;
+
+ for( int z = 0; z < 2; z++ )
+ {
+ // first test aBasicProps Handles are { 0, 1, 2, 55 }
+ // first test getBasicProps() Handles are { 0, 1, 2 }
+ xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z );
+ xPS_L = static_cast< XPropertyChangeListener * >( pPS_L = new test_OPropertySetHelper_Listener() );
+
+ // Test queryInterface
+ Reference < XPropertySet > rProp( xPS , UNO_QUERY );
+ OSL_ENSHURE( rProp.is() , "PropertySetHelper: XPropertySet nor supported" );
+
+ Reference < XMultiPropertySet > rMulti( xPS , UNO_QUERY );
+ OSL_ENSHURE( rMulti.is() , "PropertySetHelper: XMultiPropertySet nor supported" );
+
+ Reference < XFastPropertySet > rFast( xPS , UNO_QUERY );
+ OSL_ENSHURE( rFast.is() , "PropertySetHelper: XFastPropertySet nor supported" );
+
+ x = Reference < XInterface > ();
+
+ // Test add-remove listener
+ {
+ Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
+ Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
+
+ xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
+ Sequence<OUString> szPN( 3 );
+ szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
+ szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
+ szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method
+ pPS->addPropertiesChangeListener( szPN, x1 );
+
+ szPN = Sequence<OUString>();
+ pPS->addPropertiesChangeListener( szPN, x1 );
+ pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
+
+ xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
+ pPS->removePropertiesChangeListener( x1 );
+ pPS->removePropertiesChangeListener( x1 );
+ pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
+
+ // this exception must thrown
+ try
+ {
+ xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), xPS_L );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( UnknownPropertyException & e )
+ {
+
+ }
+
+ try
+ {
+ xPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), x2 );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( UnknownPropertyException & e )
+ {
+
+ }
+
+ }
+ OSL_ENSHURE( pPS_L->getRefCount() == 1, "PropertySetHelper: wrong reference count" );
+
+ // Test disposing
+ {
+ Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
+ Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
+
+ xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
+ Sequence<OUString> szPN( 2 );
+ szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
+ szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
+ pPS->addPropertiesChangeListener( szPN, x1 );
+ szPN = Sequence<OUString>();
+ pPS->addPropertiesChangeListener( szPN, x1 );
+ pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
+ pPS->dispose();
+ }
+ OSL_ENSHURE( pPS_L->nDisposing == 4 , "PropertySetHelper: wrong disposing count" );
+ OSL_ENSHURE( pPS_L->getRefCount() == 1 , "PropertySetHelper: wrong reference count" );
+ pPS_L->nDisposing = 0;
+ xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z );
+
+ // Test set- and get- (Fast) propertyValue
+ {
+ // set read only property
+ try
+ {
+ // Readonly raises a vetoable exception
+ sal_Bool b = sal_True;
+ Any aBool;
+ aBool.setValue( &b , getCppuBooleanType() );
+ xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), aBool );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( PropertyVetoException & e )
+ {
+ }
+
+ try
+ {
+ // Readonly raises a vetoable exception
+ sal_Bool b = sal_True;
+ Any aBool;
+ aBool.setValue( &b , getCppuBooleanType() );
+ // BOOL i s0
+ pPS->setFastPropertyValue( PROPERTY_BOOL, aBool );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( PropertyVetoException & e )
+ {
+ }
+
+ // set unknown property
+ try
+ {
+ sal_Bool b = sal_True;
+ Any aBool;
+ aBool.setValue( &b , getCppuBooleanType() );
+ xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), aBool );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( UnknownPropertyException & e )
+ {
+ }
+
+ try
+ {
+ sal_Bool b = sal_True;
+ Any aBool;
+ aBool.setValue( &b , getCppuBooleanType() );
+ pPS->setFastPropertyValue( 3, aBool );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( UnknownPropertyException & e )
+ {
+ }
+
+ // get unknown property
+ try
+ {
+ Any aBool;
+ aBool = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ) );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( UnknownPropertyException & e )
+ {
+ }
+
+ try
+ {
+ Any aBool;
+ aBool = ((XFastPropertySet *)pPS)->getFastPropertyValue( 3 );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( UnknownPropertyException & e )
+ {
+ }
+
+ // set property with invalid type
+ try
+ {
+ Any aBool;
+ xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aBool );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( IllegalArgumentException & e )
+ {
+ }
+
+ try
+ {
+ Any aBool;
+ pPS->setFastPropertyValue( PROPERTY_INT32, aBool );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( IllegalArgumentException & e )
+ {
+ }
+
+ // narrowing conversion is not allowed!
+ try
+ {
+ Any aINT32;
+ aINT32 <<= (sal_Int32 ) 16;
+ xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aINT32 );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( IllegalArgumentException & e )
+ {
+ }
+
+
+ try
+ {
+ Any aINT32;
+ aINT32 <<= (sal_Int32) 16;
+ pPS->setFastPropertyValue( PROPERTY_INT16, aINT32 );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( IllegalArgumentException & e )
+ {
+ }
+
+
+ Any aValue;
+ aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) );
+ sal_Bool b = *( (sal_Bool*)aValue.getValue());
+ OSL_ENSHURE( ! b, "PropertySetHelper: wrong BOOL value" );
+ aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_BOOL );
+
+ b = *((sal_Bool*)aValue.getValue());
+ OSL_ENSHURE( !b, "PropertySetHelper: wrong BOOL value" );
+
+ sal_Int16 n16;
+ aValue <<=(sal_Int16)22;
+ xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue );
+ aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) );
+ aValue >>= n16;
+ OSL_ENSHURE( 22 == n16 , "PropertySetHelper: wrong INT16 value" );
+ aValue <<= (sal_Int16)44;
+ ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
+
+ aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT16 );
+ aValue >>= n16;
+ OSL_ENSHURE( 44 == n16, "PropertySetHelper: wrong INT16 value" );
+
+ // widening conversion
+ aValue <<= (sal_Int16)55;
+ xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aValue );
+ aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) );
+ sal_Int32 n32;
+ aValue >>= n32;
+ OSL_ENSHURE( 55 == n32 , "PropertySetHelper: wrong INT32 value" );
+ aValue <<= (sal_Int16)66;
+ ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT32, aValue );
+ aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT32 );
+ aValue >>= n32;
+ OSL_ENSHURE( 66 == n32, "PropertySetHelper: wrong INT32 value" );
+
+ Sequence< OUString >valueNames = Sequence<OUString>( 3 );
+ valueNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
+ valueNames.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
+ valueNames.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
+ Sequence< Any > aValues = pPS->getPropertyValues( valueNames );
+
+ b = *((sal_Bool*)aValues.getConstArray()[0].getValue());
+ aValues.getConstArray()[1] >>= n16;
+ aValues.getConstArray()[2] >>= n32;
+
+ OSL_ENSHURE( !b, "PropertySetHelper: wrong BOOL value" );
+ OSL_ENSHURE( 44 == n16, "PropertySetHelper: wrong INT16 value" );
+ OSL_ENSHURE( 66 == n32, "PropertySetHelper: wrong INT32 value" );
+ }
+ pPS->nINT32 = 0;
+ pPS->nINT16 = 0;
+
+ // Test add-remove listener
+ {
+ Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
+
+ xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
+ pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
+
+ pPS_L->nCount = 10;
+ Sequence< Any > aSeq( pPS_L->nCount );
+ pPS_L->nCurrent = 0;
+
+ pPS_L->pExceptedListenerValues = aSeq.getArray();
+
+ pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
+ pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 22; // new value vetoable
+ pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound
+ pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound
+ pPS_L->pExceptedListenerValues[4] <<= (sal_Int16) 22; // old value vetoable
+ pPS_L->pExceptedListenerValues[5] <<= (sal_Int16) 44; // new value vetoable
+ pPS_L->pExceptedListenerValues[6] <<= (sal_Int16) 22; // old value bound
+ pPS_L->pExceptedListenerValues[7] <<= (sal_Int16) 44; // new value bound
+ pPS_L->pExceptedListenerValues[8] <<= (sal_Int16) 44; // old value vetoable
+ pPS_L->pExceptedListenerValues[9] <<= (sal_Int16) 100; // new value vetoable exception
+
+ Any aValue;
+ aValue <<= (sal_Int16)22;
+ xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue );
+ aValue <<= (sal_Int16) 44;
+ ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
+ aValue <<= (sal_Int16)100;// exception
+
+ try
+ {
+ ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch( PropertyVetoException & e )
+ {
+ }
+
+ OSL_ENSHURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
+ pPS->nINT32 = 0;
+ pPS->nINT16 = 0;
+ pPS_L->nCount = 0;
+ pPS_L->nCurrent = 0;
+ pPS_L->pExceptedListenerValues = NULL;
+ xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
+ pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
+ }
+
+ // Test multi property set listener
+ {
+ Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
+ Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
+
+ pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , x2 );
+ Sequence<OUString> szPN( 4 );
+ szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
+ szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
+ szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method
+ szPN.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
+ pPS->addPropertiesChangeListener( szPN, x1 );
+
+ pPS_L->nCount = 6;
+ Sequence< Any > aSeq( pPS_L->nCount );
+ pPS_L->nCurrent = 0;
+ pPS_L->pExceptedListenerValues = aSeq.getArray();
+ pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
+ pPS_L->pExceptedListenerValues[1] <<= (sal_Int16 ) 22; // new value vetoable
+ // INT32 is not constrained
+ pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound
+ pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound
+ pPS_L->pExceptedListenerValues[4] <<= (sal_Int32) 0; // old value bound
+ pPS_L->pExceptedListenerValues[5] <<= (sal_Int32) 44; // new value bound
+
+ szPN = Sequence<OUString>( 2 );
+ szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
+ szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
+ Sequence< Any > aValues( 2 );
+ aValues.getArray()[0] <<= (sal_Int16) 22;
+ aValues.getArray()[1] <<= (sal_Int16) 44;
+ pPS->setPropertyValues( szPN, aValues );
+ OSL_ENSHURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
+
+ //firePropertiesChangeEvent
+ pPS->nINT16 = 8;
+ pPS->nINT32 = 5;
+ pPS_L->nCount = 4;
+ pPS_L->nCurrent = 0;
+ pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 8; // old value
+ pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 8; // new value
+ pPS_L->pExceptedListenerValues[2] <<= (sal_Int32) 5; // old value
+ pPS_L->pExceptedListenerValues[3] <<= (sal_Int32) 5; // new value
+ pPS->firePropertiesChangeEvent( szPN, pPS_L );
+ OSL_ENSHURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
+
+
+ //vetoable exception with multible
+ szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
+ szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
+ pPS->nINT32 = 0;
+ pPS->nINT16 = 0;
+ pPS_L->nCount = 4;
+ pPS_L->nCurrent = 0;
+ pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
+ pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 44; // new value vetoable
+ pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value vetoable
+ pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 100; // new value vetoable
+
+ try
+ {
+ aValues.getArray()[0] <<= (sal_Int16)44;
+ aValues.getArray()[1] <<= (sal_Int16)100;
+ pPS->setPropertyValues( szPN, aValues );
+ OSL_ENSHURE( sal_False, "PropertySetHelper: exeption not thrown" );
+ }
+ catch ( PropertyVetoException & e )
+ {
+ }
+
+ OSL_ENSHURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
+ pPS->removePropertiesChangeListener( x1 );
+ pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
+ }
+ }
+}
diff --git a/cppuhelper/test/testproptyphlp.cxx b/cppuhelper/test/testproptyphlp.cxx
new file mode 100644
index 000000000000..236d3686841a
--- /dev/null
+++ b/cppuhelper/test/testproptyphlp.cxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * $RCSfile: testproptyphlp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:26:11 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <cppuhelper/proptypehlp.hxx>
+
+#include <com/sun/star/beans/Property.hpp>
+#include <assert.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::cppu;
+
+void testPropertyTypeHelper()
+{
+ Any a;
+
+ a <<= ( sal_Int8 ) 25;
+
+ sal_Int32 i;
+ convertPropertyValue( i , a );
+ assert( 25 == i );
+
+ sal_Int16 i16;
+ convertPropertyValue( i16 , a );
+ assert( 25 == i16 );
+
+ sal_Int8 i8;
+ convertPropertyValue( i8 , a );
+ assert( 25 == i8 );
+
+ sal_uInt32 i32;
+ convertPropertyValue( i32 , a );
+ assert( 25 == i32 );
+
+ double d;
+ convertPropertyValue( d , a );
+ assert( 25. == d );
+
+ float f;
+ convertPropertyValue( f , a );
+ assert( 25. == f );
+
+ ::com::sun::star::beans::Property prop;
+
+ prop.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Huhu") );
+ prop.Handle = 5;
+ prop.Attributes = 3;
+
+ a <<= prop;
+
+ ::com::sun::star::beans::Property prop2;
+ convertPropertyValue( prop2 , a );
+ assert( prop.Handle == prop2.Handle && prop.Name == prop2.Name && prop.Attributes == prop2.Attributes );
+
+
+ ::rtl::OUString ow;
+ a <<= prop.Name;
+ convertPropertyValue( ow , a );
+ assert( ow == prop.Name );
+}
diff --git a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java
new file mode 100644
index 000000000000..154b3f2be2fa
--- /dev/null
+++ b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java
@@ -0,0 +1,216 @@
+/*************************************************************************
+ *
+ * $RCSfile: BridgeFactory.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.bridgefactory;
+
+
+import java.util.Enumeration;
+
+
+import com.sun.star.bridge.BridgeExistsException;
+import com.sun.star.bridge.XBridge;
+import com.sun.star.bridge.XBridgeFactory;
+import com.sun.star.bridge.XInstanceProvider;
+
+import com.sun.star.comp.loader.FactoryHelper;
+
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.lib.util.WeakTable;
+
+import com.sun.star.registry.XRegistryKey;
+
+import com.sun.star.uno.IBridge;
+import com.sun.star.uno.MappingException;
+import com.sun.star.uno.UnoRuntime;
+
+
+/**
+ * The BridgeFactory class implements the <code>XBridgeFactory</code> Interface.
+ * It wrapps the <code>UnoRuntime#getBridgeByName</code>method and delivers a
+ * XBridge component.
+ * <p>
+ * This component is only usable for remote bridges.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Kay Ramme
+ * @see com.sun.star.uno.UnoRuntime
+ * @since UDK1.0
+ */
+public class BridgeFactory implements XBridgeFactory {
+ static private final boolean DEBUG = false;
+
+ /**
+ * The name of the service, the <code>JavaLoader</code> acceses this through reflection.
+ */
+ public final static String __serviceName = "com.sun.star.bridge.BridgeFactory";
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be uses if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(BridgeFactory.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(BridgeFactory.class,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(BridgeFactory.class.getName(), __serviceName, regKey);
+ }
+
+
+ static protected WeakTable _bridges = new WeakTable();
+
+ /**
+ * Creates a remote bridge and memorizes it under <code>sName</code>.
+ * <p>
+ * @return the bridge
+ * @param sName the name to memorize the bridge
+ * @param sProtocol the protocol the bridge should use
+ * @param anInstanceProvider the instance provider
+ * @see com.sun.star.bridge.XBridgeFactory
+ */
+ public XBridge createBridge(String sName, String sProtocol, XConnection aConnection, XInstanceProvider anInstanceProvider) throws
+ BridgeExistsException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.uno.RuntimeException
+ {
+ if(sName == null || sName.length() == 0)
+ sName = sProtocol + ":" + aConnection.getDescription();
+
+ XBridge xBridge = (XBridge)_bridges.get(sName, XBridge.class);
+
+ if(xBridge != null)
+ throw new BridgeExistsException(sName + " already exists");
+
+ try {
+ IBridge iBridge = UnoRuntime.getBridgeByName("java", null, "remote", sName, new Object[]{sProtocol, aConnection, anInstanceProvider});
+
+ xBridge = (XBridge)_bridges.put(sName, iBridge, XBridge.class);
+ }
+ catch(Exception exception) {
+ throw new com.sun.star.lang.IllegalArgumentException(exception.getMessage());
+ }
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".createBridge:" + sName + " " + sProtocol + " " + aConnection + " " + anInstanceProvider + " " + xBridge);
+
+ return xBridge;
+ }
+
+ /**
+ * Gets a remote bridge which must already exist.
+ * <p>
+ * @return the bridge
+ * @param sName the name of the bridge
+ * @see com.sun.star.bridge.XBridgeFactory
+ */
+ public XBridge getBridge(String sName) throws com.sun.star.uno.RuntimeException {
+ XBridge xBridge = (XBridge)_bridges.get(sName, XBridge.class);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".getBridge:" + sName + " " + xBridge);
+
+ return xBridge;
+ }
+
+ /**
+ * Gives all created bridges
+ * <p>
+ * @return the bridges
+ * @see com.sun.star.bridge.XBridgeFactory
+ */
+ public synchronized XBridge[] getExistingBridges() throws com.sun.star.uno.RuntimeException {
+ XBridge bridges[] = new XBridge[_bridges.size()];
+
+ Enumeration keys = _bridges.keys();
+ for(int i = 0; i < bridges.length; ++ i) {
+ bridges[i] = (XBridge)_bridges.get((String)keys.nextElement(), XBridge.class);
+ }
+
+ return bridges;
+ }
+}
+
diff --git a/jurt/com/sun/star/comp/bridgefactory/makefile.mk b/jurt/com/sun/star/comp/bridgefactory/makefile.mk
new file mode 100644
index 000000000000..f732b534b2fb
--- /dev/null
+++ b/jurt/com/sun/star/comp/bridgefactory/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/comp$/bridgefactory
+TARGET = com_sun_star_comp_bridgefactory
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+GENJAVAFILES = \
+ $(MISC)$/java$/com$/sun$/star$/uno$/XInterface.java \
+ $(MISC)$/java$/com$/sun$/star$/bridge$/BridgeExistsException.java \
+ $(MISC)$/java$/com$/sun$/star$/bridge$/XBridgeFactory.java \
+ $(MISC)$/java$/com$/sun$/star$/bridge$/XBridge.java \
+ $(MISC)$/java$/com$/sun$/star$/bridge$/XInstanceProvider.java \
+ $(MISC)$/java$/com$/sun$/star$/container$/NoSuchElementException.java \
+ $(MISC)$/java$/com$/sun$/star$/uno$/Exception.java \
+ $(MISC)$/java$/com$/sun$/star$/io$/IOException.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/XConnection.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/BridgeFactory.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/jurt/com/sun/star/comp/connections/Acceptor.java b/jurt/com/sun/star/comp/connections/Acceptor.java
new file mode 100644
index 000000000000..f316e227fb32
--- /dev/null
+++ b/jurt/com/sun/star/comp/connections/Acceptor.java
@@ -0,0 +1,244 @@
+/*************************************************************************
+ *
+ * $RCSfile: Acceptor.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.connections;
+
+
+import java.io.IOException;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+
+
+import com.sun.star.comp.loader.FactoryHelper;
+
+import com.sun.star.connection.XAcceptor;
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.registry.XRegistryKey;
+
+/**
+ * The Acceptor class is a component,
+ * that implements the <code>XAcceptor</code> Interface.
+ * <p>
+ * The Acceptor is a general component, which uses less
+ * general components (like <code>SocketAcceptor</code>) to
+ * implement its functionality.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Kay Ramme
+ * @see com.sun.star.connections.XAcceptor
+ * @see com.sun.star.connections.XConnector
+ * @see com.sun.star.connections.XConnection
+ * @see com.sun.star.loader.JavaLoader
+ * @since UDK1.0
+ */
+public class Acceptor implements XAcceptor {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ /**
+ * The name of the service, the <code>JavaLoader</code> acceses this through reflection.
+ */
+ static private final String __serviceName = "com.sun.star.connection.Acceptor";
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be uses if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(Acceptor.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(Acceptor.class,
+ __serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(Acceptor.class.getName(), __serviceName, regKey);
+ }
+
+
+
+ protected XMultiServiceFactory _xMultiServiceFactory;
+ protected XAcceptor _acceptor;
+ protected String _acceptor_description;
+ protected String _mech;
+
+ /**
+ * Constructs a new <code>Acceptor</code> which uses the
+ * given service factory for creating the concrete listener.
+ * <p>
+ * @param xMultiServiceFactory the service manager to use
+ */
+ public Acceptor(XMultiServiceFactory xMultiServiceFactory) {
+ _xMultiServiceFactory = xMultiServiceFactory;
+ }
+
+ /**
+ * Accepts a connect request through the described mechanism.
+ * This call blocks until a connection has been established.
+ * <p>
+ * The description has the following format:
+ * &lt;interface_type&gt;[,attribute_name=attribute_value]
+ * The interface type is instantiated through the service manager as
+ * <code>com.sun.star.connections.&lt;interface_type&gt;Acceptor</code>
+ * <p>
+ * @return an <code>XConnection</code> to the client
+ * @param description the description of the network interface
+ * @see com.sun.star.connections.XConnector
+ * @see com.sun.star.connections.XConnection
+ */
+ public XConnection accept(String description)
+ throws com.sun.star.connection.AlreadyAcceptingException,
+ com.sun.star.connection.ConnectionSetupException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.uno.RuntimeException
+ {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".accept - description:" + description);
+
+ String mech = null;
+ description = description.trim().toLowerCase();
+
+ // find mechanism - try old style (e.g.: socket:localhost:6001) first
+ int index = description.indexOf(':');
+ if(index >= 0) {
+ mech = description.substring(0, index).trim();
+ description = description.substring(index + 1).trim();
+ }
+ else { // must be new style (e.g.: socket, name=sdfas, ...)
+ index = description.indexOf(',');
+ if(index >= 0) { // there are parameters
+ mech = description.substring(0, index).trim();
+ description = description.substring(index + 1).trim();
+ }
+ else {
+ mech = description.trim();
+ description = "";
+ }
+ }
+
+ if(_acceptor == null) {// this is the first time accept is called
+ try {
+ // at first we try to find the delegatee via service name
+ _acceptor = (XAcceptor)UnoRuntime.queryInterface(XAcceptor.class, _xMultiServiceFactory.createInstance("com.sun.star.connection.Acceptor" + mech));
+ }
+ catch(com.sun.star.uno.Exception exception) {
+ try {
+ // try to find the class in out package structure
+ Class acceptorClass = Class.forName("com.sun.star.lib.connections." + mech + "." + mech + "Acceptor");
+
+ _acceptor = (XAcceptor)acceptorClass.newInstance();
+ }
+ catch(Exception e) {
+ }
+ }
+
+ if(_acceptor == null)
+ throw new com.sun.star.connection.ConnectionSetupException(getClass().getName() + ".accept - can not find delegatee:" + mech);
+
+ _mech = mech;
+ }
+ else // this is not the first time, so the mechanics must be the same
+ if(!_mech.equals(mech)) throw new com.sun.star.connection.AlreadyAcceptingException(getClass().getName() + ".accept");
+
+
+ return _acceptor.accept(description);
+ }
+
+ /**
+ * Unblocks the <code>accept</code> call.
+ * Delegates to the concretes mechanism.
+ */
+ public void stopAccepting() throws com.sun.star.uno.RuntimeException {
+ _acceptor.stopAccepting();
+ }
+}
+
diff --git a/jurt/com/sun/star/comp/connections/Connector.java b/jurt/com/sun/star/comp/connections/Connector.java
new file mode 100644
index 000000000000..0bd96086855a
--- /dev/null
+++ b/jurt/com/sun/star/comp/connections/Connector.java
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * $RCSfile: Connector.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.connections;
+
+
+import com.sun.star.comp.loader.FactoryHelper;
+
+import com.sun.star.connection.XConnection;
+import com.sun.star.connection.XConnector;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.registry.XRegistryKey;
+
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * The Connector class is a component that implements the <code>XConnector</code> Interface.
+ * <p>
+ * The Connector is a general component, which uses less
+ * general components (like <code>SocketConnector</code>) to
+ * implement its functionality.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Kay Ramme
+ * @see com.sun.star.connections.XAcceptor
+ * @see com.sun.star.connections.XConnector
+ * @see com.sun.star.connections.XConnection
+ * @see com.sun.star.loader.JavaLoader
+ * @since UDK1.0
+ */
+public class Connector implements XConnector {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ /**
+ * The name of the service, the <code>JavaLoader</code> acceses this through reflection.
+ */
+ static private final String __serviceName = "com.sun.star.connection.Connector";
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be uses if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(Connector.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(Connector.class,
+ __serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(Connector.class.getName(), __serviceName, regKey);
+ }
+
+
+ protected XMultiServiceFactory _xMultiServiceFactory;
+ protected String _description;
+ protected String _mech;
+ protected XConnector _connector;
+
+
+ /**
+ * Constructs a new <code>SocketConnector</code>,
+ * which uses the given <code>XMultiServiceFactory</code>
+ * as its service manager.
+ * <p>
+ * @param xMultiServiceFactory the service manager
+ */
+ public Connector(XMultiServiceFactory xMultiServiceFactory) {
+ _xMultiServiceFactory = xMultiServiceFactory;
+ }
+
+ /**
+ * Connect through the described mechanism to a waiting server.
+ * <p>
+ * The description has the following format:
+ * &lt;interface_type&gt;[,attribute_name=attribute_value]
+ * The interface type is searched for in <code>com.sun.star.lib.connections</code>
+ * <p>
+ * @return an <code>XConnection</code> to the client
+ * @param description the description of the network interface
+ * @see com.sun.star.connections.XAcceptor
+ * @see com.sun.star.connections.XConnection
+ */
+ public synchronized XConnection connect(String description)
+ throws com.sun.star.connection.NoConnectException,
+ com.sun.star.connection.ConnectionSetupException,
+ com.sun.star.uno.RuntimeException
+ {
+ if (DEBUG) System.err.println("##### " + getClass().getName() + ".connect:" + description);
+
+ if(_description != null)
+ throw new com.sun.star.connection.ConnectionSetupException(getClass().getName() + ".connect - alread connected");
+
+ _description = description.trim();
+
+ // find mechanism - try old style (e.g.: socket:localhost:6001) first
+ int index = _description.indexOf(':');
+ if(index >= 0) {
+ _mech = _description.substring(0, index);
+ _description = _description.substring(index + 1).trim();
+ }
+ else { // must be new style (e.g.: socket, name=sdfas, ...)
+ index = _description.indexOf(',');
+ if(index >= 0) { // there are parameters
+ _mech = _description.substring(0, index);
+ _description = _description.substring(index + 1).trim();
+ }
+ else {
+ _mech = description;
+ _description = "";
+ }
+ }
+ _mech = _mech.trim().toLowerCase();
+
+ try {
+ // try to get a service to which we can delegate
+ _connector = (XConnector)UnoRuntime.queryInterface(XConnector.class, _xMultiServiceFactory.createInstance("com.sun.star.connection.Connector." + _mech));
+ }
+ catch(com.sun.star.uno.Exception exception) {
+ // if this does not work, we a fall back (this is also old style)
+
+ try { // try to find the class in out package structure
+ Class connectorClass = Class.forName("com.sun.star.lib.connections." + _mech + "." + _mech + "Connector");
+ _connector = (XConnector)connectorClass.newInstance();
+ }
+ catch(Exception e) {
+ }
+ }
+
+ if(_connector == null)
+ throw new com.sun.star.connection.ConnectionSetupException(getClass().getName() + ".connect - can not find delegatee:" + _mech);
+
+ return _connector.connect(_description);
+ }
+}
+
diff --git a/jurt/com/sun/star/comp/connections/ConstantInstanceProvider.java b/jurt/com/sun/star/comp/connections/ConstantInstanceProvider.java
new file mode 100644
index 000000000000..296349ddc4d4
--- /dev/null
+++ b/jurt/com/sun/star/comp/connections/ConstantInstanceProvider.java
@@ -0,0 +1,174 @@
+/*************************************************************************
+ *
+ * $RCSfile: ConstantInstanceProvider.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.connections;
+
+import com.sun.star.bridge.XInstanceProvider;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.registry.XRegistryKey;
+
+import com.sun.star.comp.loader.FactoryHelper;
+
+
+/**
+ * The <code>ConstantInstanceProvider</code> is a component
+ * that implements the <code>XInstanceProvider</code> Interface.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Kay Ramme
+ * @see com.sun.star.bridge.XBridge
+ * @see com.sun.star.bridge.XBridgeFactory
+ * @see com.sun.star.bridge.XInstanceProvider
+ * @see com.sun.star.loader.JavaLoader
+ * @since UDK1.0
+ */
+public class ConstantInstanceProvider implements XInstanceProvider {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ /**
+ * The name of the service, the <code>JavaLoader</code> acceses this through reflection.
+ */
+ static private final String __serviceName = "com.sun.star.comp.connection.InstanceProvider";
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be uses if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(ConstantInstanceProvider.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(ConstantInstanceProvider.class,
+ __serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(ConstantInstanceProvider.class.getName(), __serviceName, regKey);
+ }
+
+
+
+ protected XMultiServiceFactory _serviceManager;
+ protected String _serviceName;
+ protected Object _instance;
+
+
+ public void setInstance(String serviceName) throws com.sun.star.uno.Exception {
+ _instance = _serviceManager.createInstance(serviceName);
+ _serviceName = serviceName;
+ }
+
+ /**
+ * Constructs a new <code>ConstantInstanceProvider</code>.
+ * Uses the provided ServiceManager as the provided instance.
+ * <p>
+ * @param serviceName the provided service manager
+ */
+ public ConstantInstanceProvider(XMultiServiceFactory serviceManager) {
+ _serviceManager = serviceManager;
+
+ _serviceName = "SERVICEMANAGER";
+ _instance = serviceManager;
+ }
+
+ /**
+ * Gives an object for the passed instance name.
+ * <p>
+ * @return the desired instance
+ * @param sInstanceName the name of the desired instance
+ */
+ public Object getInstance(String sInstanceName) throws com.sun.star.container.NoSuchElementException, com.sun.star.uno.RuntimeException {
+ Object result = sInstanceName.equals(_serviceName) ? _instance : null;
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".getInstance(" + sInstanceName + "):" + result);
+
+ return result;
+ }
+}
+
diff --git a/jurt/com/sun/star/comp/connections/PipedConnection.java b/jurt/com/sun/star/comp/connections/PipedConnection.java
new file mode 100644
index 000000000000..22bad135e689
--- /dev/null
+++ b/jurt/com/sun/star/comp/connections/PipedConnection.java
@@ -0,0 +1,318 @@
+/*************************************************************************
+ *
+ * $RCSfile: PipedConnection.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.connections;
+
+
+import com.sun.star.comp.loader.FactoryHelper;
+
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.registry.XRegistryKey;
+
+/**
+ * The PipedConnection is a component that implements the
+ * <code>XConnection</code> Interface.
+ * It is useful for <code>Thread</code> communication
+ * in one Process.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Kay Ramme
+ * @see com.sun.star.connections.XConnection
+ * @see com.sun.star.loader.JavaLoader
+ * @since UDK1.0
+ */
+public class PipedConnection implements XConnection {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ public static final boolean DEBUG = false;
+
+ /**
+ * The name of the service, the <code>JavaLoader</code> acceses this through reflection.
+ */
+ static private final String __serviceName = "com.sun.star.connection.PipedConnection";
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be uses if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(PipedConnection.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(PipedConnection.class,
+ __serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(PipedConnection.class.getName(), __serviceName, regKey);
+ }
+
+
+ /**
+ * The amount of time in milliseconds, to wait to
+ * see check the buffers.
+ */
+ protected static final int __waitTime = 10000;
+
+ protected byte _buffer[] = new byte[4096];
+ protected int _in,
+ _out;
+ protected boolean _closed;
+ protected PipedConnection _otherSide;
+
+ /**
+ * Constructs a new <code>PipedConnection</code>, sees if there
+ * is an other side, which it should be connected to.
+ * <p>
+ * @param args Another side could be in index 0.
+ */
+ public PipedConnection(Object args[]) throws com.sun.star.uno.RuntimeException {
+ if (DEBUG) System.err.println("##### " + getClass().getName() + " - instantiated");
+
+ _otherSide = (args.length == 1) ? (PipedConnection)args[0] : null;
+ if(_otherSide != null) {
+ if(_otherSide == this)
+ throw new RuntimeException("can not connect to myself");
+
+ _otherSide._otherSide = this;
+ }
+ }
+
+ /**
+ * This is a private method, used to cummunicate
+ * internal in the pipe.
+ */
+ private synchronized void receive(byte aData[]) throws com.sun.star.io.IOException {
+ int bytesWritten = 0;
+
+ if(DEBUG) System.err.println("##### PipedConnection.receive - bytes:" + aData.length + " at:" + _out);
+
+ while(bytesWritten < aData.length) {
+ // wait until it is not full anymore
+ while(_out == (_in - 1) || (_in == 0 && _out == _buffer.length - 1)) {
+ try {
+ notify(); // the buffer is full, signal it
+
+ wait(__waitTime);
+ }
+ catch(InterruptedException interruptedException) {
+ throw new com.sun.star.io.IOException(interruptedException.toString());
+ }
+ }
+
+ if(_closed) throw new com.sun.star.io.IOException("connection has been closed");
+
+ int bytes = 0;
+
+ if(_out < _in) {
+ bytes = Math.min(aData.length - bytesWritten, _in - _out - 1);
+
+ System.arraycopy(aData, bytesWritten, _buffer, _out, bytes);
+ }
+ else {
+ if(_in > 0){
+ bytes = Math.min(aData.length - bytesWritten, _buffer.length - _out);
+ }
+ else {
+ bytes = Math.min(aData.length - bytesWritten, _buffer.length - _out - 1);
+ }
+
+ System.arraycopy(aData, bytesWritten, _buffer, _out, bytes);
+ }
+
+ bytesWritten += bytes;
+ _out += bytes;
+ if(_out >= _buffer.length)
+ _out = 0;
+ }
+ }
+
+ /**
+ * Read the required number of bytes.
+ * <p>
+ * @return the number of bytes read
+ * @param aReadBytes the outparameter, where the bytes have to be placed
+ * @param nBytesToRead the number of bytes to read
+ * @see com.sun.star.connections.XConnection#read
+ */
+ public synchronized int read(/*OUT*/byte[][] aReadBytes, int nBytesToRead) throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ aReadBytes[0] = new byte[nBytesToRead];
+
+ if(DEBUG) System.err.println("##### PipedConnection.read - bytes:" + nBytesToRead + " at:" + _in);
+
+ // loop while not all bytes read or when closed but there is still data
+ while(nBytesToRead > 0 && (_in != _out || !_closed)) {
+ while(_in == _out && !_closed) {
+ try {
+ notify(); // the buffer is empty, signal it
+
+ wait(__waitTime); // we wait for data or for the pipe to be closed
+ }
+ catch(InterruptedException interruptedException) {
+ throw new com.sun.star.io.IOException(interruptedException.toString());
+ }
+ }
+
+ if(_in < _out) {
+ int bytes = Math.min(nBytesToRead, _out - _in);
+
+ System.arraycopy(_buffer, _in, aReadBytes[0], aReadBytes[0].length - nBytesToRead, bytes);
+
+ nBytesToRead -= bytes;
+ _in += bytes;
+ }
+ else if(_in > _out) {
+ int bytes = Math.min(nBytesToRead, _buffer.length - _in);
+
+ System.arraycopy(_buffer, _in, aReadBytes[0], aReadBytes[0].length - nBytesToRead, bytes);
+
+ nBytesToRead -= bytes;
+ _in += bytes;
+ if(_in >= _buffer.length)
+ _in = 0;
+ }
+ }
+
+ if(nBytesToRead > 0) { // not all bytes read
+ byte tmp[] = new byte[aReadBytes[0].length - nBytesToRead];
+ System.arraycopy(aReadBytes[0], 0, tmp, 0, tmp.length);
+
+ aReadBytes[0] = tmp;
+ }
+
+ return aReadBytes[0].length;
+ }
+
+ /**
+ * Write bytes.
+ * <p>
+ * @param aData the bytes to write
+ * @see com.sun.star.connections.XConnection#write
+ */
+ public void write(byte aData[]) throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ _otherSide.receive(aData);
+ }
+
+ /**
+ * Flushes the buffer, notifies if necessary the other side that new data has arrived.
+ * <p>
+ * @see com.sun.star.connections.XConnection#flush
+ */
+ public void flush() throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ synchronized(_otherSide) {
+ _otherSide.notify();
+ }
+ }
+
+ /**
+ * Closes the pipe.
+ * <p>
+ * @see com.sun.star.connections.XConnection#closed
+ */
+ public synchronized void close() throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ if(!_closed) {
+ _closed = true;
+
+ _otherSide.close();
+
+ notify();
+ }
+ }
+
+ /**
+ * Gives a description of this pipe.
+ * <p>
+ * @return the description
+ * @see com.sun.star.connections.XConnection#getDescription
+ */
+ public String getDescription() throws com.sun.star.uno.RuntimeException {
+ return getClass().getName();
+ }
+
+}
+
diff --git a/jurt/com/sun/star/comp/connections/makefile.mk b/jurt/com/sun/star/comp/connections/makefile.mk
new file mode 100644
index 000000000000..82a243718b5c
--- /dev/null
+++ b/jurt/com/sun/star/comp/connections/makefile.mk
@@ -0,0 +1,91 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/comp$/connections
+TARGET = com_sun_star_comp_connections
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+GENJAVAFILES= \
+ $(MISC)$/java$/com$/sun$/star$/connection$/AlreadyAcceptingException.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/ConnectionSetupException.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/NoConnectException.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/XAcceptor.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/XConnection.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/XConnector.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/Acceptor.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Connector.class \
+ $(CLASSDIR)$/$(PACKAGE)$/PipedConnection.class \
+ $(CLASSDIR)$/$(PACKAGE)$/ConstantInstanceProvider.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/com/sun/star/comp/loader/FactoryHelper.java b/jurt/com/sun/star/comp/loader/FactoryHelper.java
new file mode 100644
index 000000000000..cdfa09d871de
--- /dev/null
+++ b/jurt/com/sun/star/comp/loader/FactoryHelper.java
@@ -0,0 +1,360 @@
+/*************************************************************************
+ *
+ * $RCSfile: FactoryHelper.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.loader;
+
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.registry.XRegistryKey;
+
+
+/**
+ * The purpose of this class to help component implementation.
+ * This class has default implementations for <code>getServiceFactory</code>
+ * and <code>writeRegistryServiceInfo</code>.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Kay Ramme
+ * @see com.sun.star.lang.XMultiServiceFactory
+ * @see com.sun.star.lang.XServiceInfo
+ * @see com.sun.star.lang.XSingleServiceFactory
+ * @see com.sun.star.registry.XRegistryKey
+ * @since UDK1.0
+ */
+public class FactoryHelper {
+ // the factory
+ static protected class Factory implements XSingleServiceFactory, XServiceInfo {
+ protected static Class __objectArray;
+
+ static {
+ try {
+ __objectArray = Class.forName("[Ljava.lang.Object;");
+ }
+ catch(ClassNotFoundException classNotFoundException) {
+ System.err.println(FactoryHelper.class.getName() + " exception occurred - " + classNotFoundException);
+ }
+ }
+
+
+ protected XMultiServiceFactory _xMultiServiceFactory;
+ protected XRegistryKey _xRegistryKey;
+ protected Object _parameters[];
+ protected boolean _bArgs;
+ protected Constructor _constructor;
+ protected String _implName;
+ protected String _serviceName;
+
+ protected Factory(Class implClass,
+ String serviceName,
+ XMultiServiceFactory xMultiServiceFactory,
+ XRegistryKey xRegistryKey)
+ {
+ _xMultiServiceFactory = xMultiServiceFactory;
+ _xRegistryKey = xRegistryKey;
+ _implName = implClass.getName();
+ _serviceName = serviceName;
+
+ Constructor constructors[] = implClass.getConstructors();
+ for(int i = 0; i < constructors.length && _parameters == null; ++i) {
+ Class parameters[] = constructors[i].getParameterTypes();
+
+ if(parameters.length == 4
+ && parameters[0].equals(XMultiServiceFactory.class)
+ && parameters[1].equals(XRegistryKey.class)
+ && parameters[0].equals(__objectArray)) {
+ _bArgs = true;
+ _parameters = new Object[]{xMultiServiceFactory, xRegistryKey, new Object[]{}};
+ _constructor = constructors[i];
+ }
+ else if(parameters.length == 3
+ && parameters[0].equals(XMultiServiceFactory.class)
+ && parameters[1].equals(XRegistryKey.class)) {
+ _parameters = new Object[]{xMultiServiceFactory, xRegistryKey};
+ _constructor = constructors[i];
+ }
+ else if(parameters.length == 2
+ && parameters[0].equals(XMultiServiceFactory.class)
+ && parameters[0].equals(__objectArray)) {
+ _bArgs = true;
+ _parameters = new Object[]{xMultiServiceFactory, new Object[]{}};
+ _constructor = constructors[i];
+ }
+ else if(parameters.length == 1
+ && parameters[0].equals(XMultiServiceFactory.class)) {
+ _parameters = new Object[]{xMultiServiceFactory};
+ _constructor = constructors[i];
+ }
+ else if(parameters.length == 1
+ && parameters[0].equals(__objectArray)) {
+ _bArgs = true;
+ _parameters = new Object[]{new Object[]{}};
+ _constructor = constructors[i];
+ }
+ else if(parameters.length == 0) {
+ _parameters = new Object[]{};
+ _constructor = constructors[i];
+ }
+ }
+ }
+
+ /**
+ * Creates an instance of the desired service.
+ * <p>
+ * @return returns an instance of the desired service
+ * @see com.sun.star.lang.XSingleServiceFactory
+ */
+ public Object createInstance()
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ Object instance = null;
+
+ try {
+ instance = _constructor.newInstance(_parameters);
+ }
+ catch(InvocationTargetException invocationTargetException) {
+ System.err.println("##### " + getClass().getName() + ".createInstance:" + invocationTargetException);
+ invocationTargetException.printStackTrace();
+
+ Throwable throwable = invocationTargetException.getTargetException();
+ System.err.println("##### " + getClass().getName() + ".createInstance:" + throwable);
+ throwable.printStackTrace();
+
+ throw new com.sun.star.uno.Exception(invocationTargetException.toString());
+ }
+ catch(IllegalAccessException illegalAccessException) {
+ throw new com.sun.star.uno.Exception(illegalAccessException.toString());
+ }
+ catch(InstantiationException instantiationException) {
+ throw new com.sun.star.uno.Exception(instantiationException.toString());
+ }
+
+ return instance;
+ }
+
+ /**
+ * Creates an instance of the desired service.
+ * <p>
+ * @return returns an instance of the desired service
+ * @param args the args given to the constructor of the service
+ * @see com.sun.star.lang.XSingleServiceFactory
+ */
+ public Object createInstanceWithArguments(Object[] args)
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ Object instance = null;
+ if(_bArgs) {
+ _parameters[_parameters.length - 1] = args;
+
+ try {
+ instance = _constructor.newInstance(_parameters);
+ }
+ catch(InvocationTargetException invocationTargetException) {
+ throw new com.sun.star.uno.Exception(invocationTargetException.toString());
+ }
+ catch(IllegalAccessException illegalAccessException) {
+ throw new com.sun.star.uno.Exception(illegalAccessException.toString());
+ }
+ catch(InstantiationException instantiationException) {
+ throw new com.sun.star.uno.Exception(instantiationException.toString());
+ }
+
+ finally {
+ _parameters[_parameters.length - 1] = null;
+ }
+ }
+ else
+ instance = createInstance();
+
+ return instance;
+ }
+
+ /**
+ * Gives the supported services
+ * <p>
+ * @return returns an array of supported services
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String[] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException {
+ return new String[]{_serviceName};
+ }
+
+ /**
+ * Gives the implementation name
+ * <p>
+ * @return returns the implementation name
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String getImplementationName() throws com.sun.star.uno.RuntimeException {
+ return _implName;
+ }
+
+ /**
+ * Indicates if the given service is supported.
+ * <p>
+ * @return returns true if the given service is supported
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public boolean supportsService(String serviceName) throws com.sun.star.uno.RuntimeException {
+ String services[] = getSupportedServiceNames();
+
+ boolean found = false;
+
+ for(int i = 0; i < services.length && !found; ++i)
+ found = services[i].equals(serviceName);
+
+ return found;
+ }
+
+ }
+
+ /**
+ * Creates a factory for the given class.
+ * <p>
+ * @deprecated as of UDK 1.0
+ * <p>
+ * @return returns a factory
+ * @param implClass the implementing class
+ * @param multiFactory the given multi service factory (service manager)
+ * @param regKey the given registry key
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ static public XSingleServiceFactory getServiceFactory(Class implClass,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ try {
+ Field serviceName = null;
+
+ try {
+ serviceName = implClass.getField("__serviceName");
+ }
+ catch(NoSuchFieldException noSuchFieldExceptio) {
+ serviceName = implClass.getField("serviceName"); // old style
+ }
+
+ xSingleServiceFactory = new Factory(implClass, (String)serviceName.get(null), multiFactory, regKey);
+ }
+ catch(NoSuchFieldException noSuchFieldException) {
+ System.err.println("##### FactoryHelper.getServiceFactory - exception:" + noSuchFieldException);
+ }
+ catch(IllegalAccessException illegalAccessException) {
+ System.err.println("##### FactoryHelper.getServiceFactory - exception:" + illegalAccessException);
+ }
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Creates a factory for the given class.
+ * <p>
+ * @return returns a factory
+ * @param implClass the implementing class
+ * @param serviceName the service name of the implementing class
+ * @param multiFactory the given multi service factory (service manager)
+ * @param regKey the given registry key
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ static public XSingleServiceFactory getServiceFactory(Class implClass,
+ String serviceName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ return new Factory(implClass, serviceName, multiFactory, regKey);
+ }
+
+ /**
+ * Writes the registration data into the registry key
+ * <p>
+ * @return returns a factory
+ * @param implName the name of the implementing class
+ * @param serviceName the service name
+ * @param regKey the given registry key
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ static public boolean writeRegistryServiceInfo(String implName, String serviceName, XRegistryKey regKey) {
+ boolean result = false;
+
+ try {
+ XRegistryKey newKey = regKey.createKey("/" + implName + "/UNO/SERVICES");
+
+ newKey.createKey(serviceName);
+
+ result = true;
+ }
+ catch (Exception ex) {
+ System.err.println(">>>Connection_Impl.writeRegistryServiceInfo " + ex);
+ }
+
+ return result;
+ }
+}
+
diff --git a/jurt/com/sun/star/comp/loader/JavaLoader.java b/jurt/com/sun/star/comp/loader/JavaLoader.java
new file mode 100644
index 000000000000..bdb5b5552bba
--- /dev/null
+++ b/jurt/com/sun/star/comp/loader/JavaLoader.java
@@ -0,0 +1,914 @@
+/*************************************************************************
+ *
+ * $RCSfile: JavaLoader.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.loader;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+
+import java.lang.reflect.InvocationTargetException;
+
+import com.sun.star.loader.CannotActivateFactoryException;
+import com.sun.star.loader.XImplementationLoader;
+
+import com.sun.star.registry.CannotRegisterImplementationException;
+import com.sun.star.registry.RegistryKeyType;
+import com.sun.star.registry.RegistryValueType;
+import com.sun.star.registry.InvalidRegistryException;
+import com.sun.star.registry.InvalidValueException;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.registry.XSimpleRegistry;
+
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.ServiceNotRegisteredException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XInitialization;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+/**
+ * The <code>JavaLoader</code> class provides the functionality of the <code>com.sun.star.loader.Java</code>
+ * service. Therefor the <code>JavaLoader</code> activates external UNO components which are implemented in Java.
+ * The loader is used by the <code>ServiceManger</code>.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Markus Herzog
+ * @see com.sun.star.loader.XImplementationLoader
+ * @see com.sun.star.loader.Java
+ * @see com.sun.star.comp.servicemanager.ServiceManager
+ * @see com.sun.star.lang.ServiceManager
+ * @since UDK1.0
+ */
+public class JavaLoader implements XImplementationLoader,
+ XServiceInfo,
+ XInitialization
+{
+ private static final boolean DEBUG = false;
+
+ private static final void DEBUG(String dbg) {
+ if (DEBUG) System.err.println( dbg );
+ }
+
+ private static String[] supportedServices = {
+ "com.sun.star.loader.Java"
+ };
+
+ protected XMultiServiceFactory multiServiceFactory = null;
+
+ /** default constructor
+ */
+
+ /**
+ * Creates a new instance of the <code>JavaLoader</code> class.
+ * <p>
+ * @return new instance
+ */
+ public JavaLoader() {}
+
+ /**
+ * Creates a new <code>JavaLoader</code> object. The specified <code>com.sun.star.lang.XMultiServiceFactory</code>
+ * is the <code>ServiceManager</code> service which can be deliviert to all components the <code>JavaLoader</code> is
+ * loading.
+ * To set the <code>MultiServiceFactory</code> you can use the <code>com.sun.star.lang.XInitialization</code> interface, either.
+ * <p>
+ * @return new instance
+ * @param factory the <code>ServiceManager</code>
+ * @see com.sun.star.lang.ServiceManager
+ * @see com.sun.star.lang.ServiceManager
+ * @see com.sun.star.lang.XInitialization
+ */
+ public JavaLoader(XMultiServiceFactory factory) {
+ multiServiceFactory = factory;
+ }
+
+ /**
+ * Unlike the original intention, the method could be called every time a new
+ * <code>com.sun.star.lang.XMultiServiceFactory</code> should be set at the loader.
+ * <p>
+ * @param args - the first parameter (args[0]) specifices the <code>ServiceManager</code>
+ * @see com.sun.star.lang.XInitialization
+ * @see com.sun.star.lang.ServiceManager
+ */
+ public void initialize( java.lang.Object[] args )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ if (args.length == 0) throw new com.sun.star.lang.IllegalArgumentException("No arguments specified");
+
+ try {
+ multiServiceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, args[0]);
+ }
+ catch (ClassCastException castEx) {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "The argument must be an instance of XMultiServiceFactory");
+ }
+ }
+
+ /**
+ * Supplies the implementation name of the component.
+ * <p>
+ * @return the implementation name - here the class name
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String getImplementationName()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return getClass().getName();
+ }
+
+ /**
+ * Verifies if a given service is supported by the component.
+ * <p>
+ * @return true,if service is suported - otherwise false
+ * @param serviceName the name of the service that should be checked
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public boolean supportsService(String serviceName)
+ throws com.sun.star.uno.RuntimeException
+ {
+ for ( int i = 0; i < supportedServices.length; i++ ) {
+ if ( supportedServices[i].equals(serviceName) )
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Supplies a list of all service names supported by the component
+ * <p>
+ * @return a String array with all supported services
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String[] getSupportedServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return supportedServices;
+ }
+
+ /**
+ * Provides a components factory.
+ * The <code>JavaLoader</code> tries to load the class first. If a loacation URL is given the
+ * RegistrationClassFinder is used to load the class. Otherwise the class is loaded thru the Class.forName
+ * method.
+ * To get the factory the inspects the class for the optional static member functions __getServiceFactory resp.
+ * getServiceFactory (DEPRECATED).
+ * If the function can not be found a default factory @see ComponentFactoryWrapper will be created.
+ * <p>
+ * @return the factory for the component (@see com.sun.star.lang.XSingleServiceFactory)
+ * @param implementationName the implementation (class) name of the component
+ * @param implementationLoaderUrl the URL of the implementation loader. Not used.
+ * @param locationUrl points to an archive (JAR file) which contains a component
+ * @param xKey
+ * @see com.sun.star.lang.XImplementationLoader
+ * @see com.sun.star.com.loader.RegistrationClassFinder
+ */
+ public java.lang.Object activate( String implementationName,
+ String implementationLoaderUrl,
+ String locationUrl,
+ XRegistryKey xKey )
+ throws CannotActivateFactoryException,
+ com.sun.star.uno.RuntimeException
+ {
+ boolean needFactoryWrapper = false;
+ Object returnObject = null;
+ Class clazz = null;
+
+ DEBUG("try to get factory for " + implementationName);
+
+ // first we must get the class of the implementation
+ // 1. If a location URL is given it is assumed that this points to a JAR file.
+ // The components class name is stored in the manifest file.
+ // 2. If only the implementation name is given, the class is loaded with the Class.forName() method
+ try {
+ if ( locationUrl != null ) {
+ RegistrationClassFinder classFinder = new RegistrationClassFinder( locationUrl );
+ // 1.
+ clazz = classFinder.getRegistrationClass();
+ }
+ else {
+ // 2.
+ clazz = Class.forName( implementationName );
+ }
+ }
+ catch (java.net.MalformedURLException e) {
+ CannotActivateFactoryException cae = new CannotActivateFactoryException(
+ "Can not activate factory because " + e.toString() );
+ cae.fillInStackTrace();
+ throw cae;
+ }
+ catch (java.io.IOException e) {
+ CannotActivateFactoryException cae = new CannotActivateFactoryException(
+ "Can not activate factory because " + e.toString() );
+ cae.fillInStackTrace();
+ throw cae;
+ }
+ catch (java.lang.ClassNotFoundException e) {
+ CannotActivateFactoryException cae = new CannotActivateFactoryException(
+ "Can not activate factory because " + e.toString() );
+ cae.fillInStackTrace();
+ throw cae;
+ }
+
+ Class[] paramTypes = {String.class, XMultiServiceFactory.class, XRegistryKey.class};
+ Object[] params = { implementationName, multiServiceFactory, xKey };
+
+ // try to get factory from implemetation class
+ // - new style: use the public static method __getServiceFactory
+ // - old style: use the public static method getServiceFactory ( DEPRECATED )
+ Method method = null;
+ try {
+ method = clazz.getMethod("__getServiceFactory", paramTypes);
+ }
+ catch ( NoSuchMethodException noSuchMethodEx) {
+ method = null;
+ }
+ catch ( SecurityException secEx) {
+ method = null;
+ }
+
+ try {
+ if ( method == null ) {
+ method = clazz.getMethod("getServiceFactory", paramTypes);
+ }
+
+ Object oRet = method.invoke(clazz, params);
+
+ if ( (oRet != null) && (oRet instanceof XSingleServiceFactory) ) {
+ returnObject = (XSingleServiceFactory) oRet;
+ }
+ }
+ catch ( NoSuchMethodException noSuchMethodEx) {
+ needFactoryWrapper = true;
+ }
+ catch ( SecurityException secEx) {
+ needFactoryWrapper = true;
+ }
+ catch ( IllegalAccessException e ) {
+ throw new CannotActivateFactoryException("Can not activate the factory for "
+ + implementationName + " because " + e.toString() );
+ }
+ catch ( IllegalArgumentException e ) {
+ throw new CannotActivateFactoryException("Can not activate the factory for "
+ + implementationName + " because " + e.toString() );
+ }
+ catch ( InvocationTargetException e ) {
+ throw new CannotActivateFactoryException("Can not activate the factory for "
+ + implementationName + " because " + e.toString() );
+ }
+ // if no method is found make a factory wrapper for the implementation and return it
+ if ( needFactoryWrapper ) {
+ DEBUG ("create factory wrapper for " + implementationName);
+ ComponentFactoryWrapper wrapp = new ComponentFactoryWrapper( implementationName, locationUrl );
+ returnObject = wrapp.getServiceFactory(implementationName,
+ multiServiceFactory,
+ xKey);
+ }
+
+ return returnObject;
+ }
+
+ /**
+ * Registers the component in a registry under a given root key. If the component supports the optional
+ * methods __writeRegistryServiceInfo, writeRegistryServiceInfo (DEPRECATED), the call is delegated to that
+ * method. Otherwise a default registration will be accomplished.
+ * <p>
+ * @return true if registration is successfully - otherwise false
+ * @param regKey the root key under that the component should be registred.
+ * @param implementationLoaderUrl specifies the loader, the component is loaded by.
+ * @param locationUrl points to an archive (JAR file) which contains a component
+ * @see ComponentFactoryWrapper
+ */
+ public boolean writeRegistryInfo( XRegistryKey regKey,
+ String implementationLoaderUrl,
+ String locationUrl )
+ throws CannotRegisterImplementationException,
+ com.sun.star.uno.RuntimeException
+ {
+ boolean success = false;
+
+ try {
+
+ RegistrationClassFinder classFinder = new RegistrationClassFinder(locationUrl);
+ Class clazz = classFinder.getRegistrationClass();
+
+ Class[] paramTypes = { XRegistryKey.class };
+ Object[] params = { regKey };
+
+ Method method = clazz.getMethod("__writeRegistryServiceInfo", paramTypes);
+ Object oRet = method.invoke(clazz, params);
+
+ if ( (oRet != null) && (oRet instanceof Boolean) )
+ success = ((Boolean) oRet).booleanValue();
+ }
+ catch (Exception e) {
+ // default registration
+ ComponentFactoryWrapper wrapp = new ComponentFactoryWrapper(null, locationUrl);
+ success = wrapp.writeRegistryServiceInfo(regKey);
+ }
+
+ return success;
+ }
+
+ /**
+ * Supplies the factory for the <code>JavaLoader</code>
+ * <p>
+ * @return the factory for the <code>JavaLoader</code>
+ * @param implName the name of the desired component
+ * @param multiFactory the <code>ServiceManager</code> is delivered to the factory
+ * @param regKey not used - can be null
+ */
+ public static XSingleServiceFactory getServiceFactory( String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ if ( implName.equals(JavaLoader.class.getName()) )
+ return new JavaLoaderFactory( multiFactory );
+
+ return null;
+ }
+
+ /**
+ * Registers the <code>JavaLoader</code> at the registry.
+ * <p>
+ * @return true if registration succseeded - otherwise false
+ * @param regKey root key under which the <code>JavaLoader</code> should be regidstered
+ */
+ public static boolean writeRegistryServiceInfo(XRegistryKey regKey) {
+ boolean result = false;
+
+ try {
+ XRegistryKey newKey = regKey.createKey("/" + JavaLoader.class.getName() + "/UNO/SERVICE");
+
+ for (int i=0; i<supportedServices.length; i++)
+ newKey.createKey(supportedServices[i]);
+
+ result = true;
+ }
+ catch (Exception ex) {
+ if (DEBUG) System.err.println(">>>JavaLoader.writeRegistryServiceInfo " + ex);
+ }
+
+ return result;
+ }
+}
+
+//**********************************************************************************************************
+//**********************************************************************************************************
+
+/**
+ * The <code>ComponentFactoryWrapper</code> class provides methods to create a factory for a component and
+ * the registration at a registry in a default manner. The class is used by the <code>JavaLoader</code> if the
+ * a component does not comes with its own methods for creating a factory or for the registration.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Markus Herzog
+ * @since UDK1.0
+ */
+class ComponentFactoryWrapper
+ implements XServiceInfo,
+ XSingleServiceFactory
+{
+ private static final boolean DEBUG = false;
+ private String serviceName = null;
+ private String implName = null;
+ private String locationUrl = null;
+ private Class serviceClass = null;
+ private XMultiServiceFactory aServiceManager = null;
+ private boolean bServiceManagerAlreadySet = false;
+
+ /**
+ * Constructor for a <code>ComponentFactoryWrapper</code> object.
+ * <p>
+ * @param name specifies the name of the implementation. If no loaction URL is given
+ * the implementation name must be the class name of the component.
+ * @param lUrl points to an archive (JAR file) which contains a component.
+ */
+ public ComponentFactoryWrapper( String name, String lUrl ) {
+ implName = name;
+ locationUrl = lUrl;
+ }
+
+ private static final void DEBUG( String dbg ) {
+ if (DEBUG) System.err.println(">>>ComponentFactoryWrapper - " + dbg);
+ }
+
+ /**
+ * Registers the component at the registry. First it is verified if component includes the optional
+ * method __writeRegistryServiceInfo ( writeRegistryServiceInfo - DEPRECATED ). If so the call is delegated
+ * to this method. Otherwise the component will be registered under its implementation name.
+ * <p>
+ * @return true if registration succseeded - otherwise false
+ * @param regKey root key under which the <code>JavaLoader</code> should be regidstered
+ */
+ public boolean writeRegistryServiceInfo( XRegistryKey regKey )
+ throws CannotRegisterImplementationException,
+ com.sun.star.uno.RuntimeException
+ {
+ boolean success = false;
+ boolean defaultRegistration = false;
+
+ Class clazz = getServiceClass();
+ if ( clazz != null ) {
+ try {
+ Class[] paramTypes = { XRegistryKey.class };
+ Object[] params = { regKey };
+
+ Method method = null;
+
+ try {
+ method = clazz.getMethod("__writeRegistryServiceInfo", paramTypes);
+ }
+ catch (NoSuchMethodException noSuchMethodEx) {
+ method = null;
+ }
+ catch (SecurityException securityEx) {
+ method = null;
+ }
+
+ if (method == null) {
+ method = clazz.getMethod("writeRegistryServiceInfo", paramTypes);
+ }
+
+ Object oRet = method.invoke(clazz, params);
+
+ if ( (oRet != null) && (oRet instanceof Boolean) )
+ success = ((Boolean) oRet).booleanValue();
+ }
+ catch (NoSuchMethodException noSuchMethodEx) {
+ defaultRegistration = true;
+ }
+ catch (SecurityException securityEx) {
+ defaultRegistration = true;
+ }
+ catch (IllegalAccessException e) {
+ throw new CannotRegisterImplementationException("Can not register " + implName + " because " + e.toString() );
+ }
+ catch (IllegalArgumentException e) {
+ throw new CannotRegisterImplementationException("Can not register " + implName + " because " + e.toString() );
+ }
+ catch (InvocationTargetException e) {
+ throw new CannotRegisterImplementationException("Can not register " + implName + " because " + e.toString() );
+ }
+
+
+ if (defaultRegistration) {
+ try {
+ XRegistryKey newKey = regKey.createKey("/" + implName + "/UNO/SERVICES");
+ String names[] = getServiceNames();
+
+ for (int i=0; i<names.length; i++)
+ newKey.createKey( names[i] );
+
+ success = true;
+ }
+ catch (com.sun.star.registry.InvalidRegistryException e) {
+ throw new CannotRegisterImplementationException("Can not register " + implName + " because " + e.toString() );
+ }
+
+ }
+ }
+ return success;
+ }
+
+ /**
+ * Supplies the factory for the component. First it is verified if component includes the optional
+ * method __getServiceFactory ( getServiceFactory - DEPRECATED ). If so the call is delegated
+ * to this method. Otherwise the ComponentFactoryWrapper is returned.
+ * <p>
+ * @return the factory for the component
+ * @param impName the components implementation name
+ * @param multiFac specifices the ServiceManager
+ * @param regKey only used if the call is delegated
+ */
+ public Object getServiceFactory( String impName,
+ XMultiServiceFactory multiFac,
+ XRegistryKey regKey)
+ {
+ aServiceManager = multiFac;
+
+ try {
+ Class clazz = getServiceClass();
+ Class[] paramTypes = { String.class, XMultiServiceFactory.class, XRegistryKey.class};
+ Object[] params = { impName, multiFac, regKey };
+
+ // try to get factory form implemetation class
+ Method method = null;
+
+ try {
+ method = clazz.getMethod("__getServiceFactory", paramTypes);
+ }
+ catch (NoSuchMethodException noSuchMethodEx) {
+ method = null;
+ }
+ catch (SecurityException securityEx) {
+ method = null;
+ }
+
+ if (method == null) {
+ method = clazz.getMethod("getServiceFactory", paramTypes);
+ }
+
+ return UnoRuntime.queryInterface( XSingleServiceFactory.class,method.invoke(clazz, params) );
+
+ }
+ catch (NoSuchMethodException noSuchMethodEx) {
+ }
+ catch (SecurityException securityEx) {
+ }
+ catch (IllegalAccessException e) {
+ }
+ catch (IllegalArgumentException e) {
+ }
+ catch (InvocationTargetException e) {
+ }
+
+ // if any execption occurred this will be returned
+ return this;
+ }
+
+ /**
+ * set the ServiceManager at the component,
+ * if the method __setSericeFactory( XMultiServiceFactor ) is found
+ */
+ /**
+ * Set the <code>ServiceManager</code> at the component. For that the component must support
+ * the <code>__setServiceManager</code> methode. The method is called after a new instance of the
+ * component is created.
+ * <p>
+ * @param obj the newly created component
+ * @see createInstanceWithArguments
+ * @see createInstance
+ */
+ private void setServiceManager( Object obj ) {
+ Class clazz = getServiceClass();
+ Class paramTypes[] = { XMultiServiceFactory.class };
+ Object[] args = { aServiceManager };
+ try {
+ clazz.getDeclaredMethod( "__setServiceManager", paramTypes).invoke(obj, args);
+ }
+ catch (NoSuchMethodException e) {}
+ catch (SecurityException e) {}
+ catch (IllegalAccessException e) {}
+ catch (IllegalArgumentException e) {}
+ catch (InvocationTargetException e) {}
+ }
+
+ /**
+ * Tries to instantiate a component by its implementation name. For it the Beans.instantiate
+ * method is called. If any exception occured a com.sun.star.uno.Exception will be thrown.
+ * <p>
+ * @return
+ * @see java.beans.Beans
+ */
+ private Object createInstanceWithDefaultConstructor()
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ Object resObj = null;
+ try {
+ DEBUG ("try to instantiate " + implName );
+
+ resObj = java.beans.Beans.instantiate(getClass().getClassLoader(), implName);
+ }
+ catch (IOException e) {
+ if (DEBUG) e.printStackTrace();
+ throw new com.sun.star.uno.Exception("Can not create an instance of " + implName + "\n" +
+ e.toString());
+ }
+ catch (ClassNotFoundException e) {
+ if (DEBUG) e.printStackTrace();
+ throw new com.sun.star.uno.Exception("Can not create an instance of " + implName + "\n" +
+ e.toString());
+ }
+ catch (NoSuchMethodError e) {
+ if (DEBUG) e.printStackTrace();
+ throw new com.sun.star.uno.Exception("Can not create an instance of " + implName + "\n" +
+ e.toString());
+ }
+
+ return resObj;
+ }
+
+
+ /**
+ * Creates a new instance of the component.
+ * <p>
+ * @return newly instanciated component
+ * @see com.sun.star.lang.XSimpleServiceFactory
+ */
+ public Object createInstance()
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ Object resObj = createInstanceWithDefaultConstructor();
+
+ setServiceManager( resObj );
+
+ return resObj;
+ }
+
+ /**
+ * Creates a new component with arguments. How the arguments are commited depends on the component.
+ * For that the following order is used:
+ * 1. The component supports the XInitialization interface: An object is created using Beans.instantiate.
+ * The arguments are set with the <code>initialize</code> method.
+ * 2. The component has a constructor with an array of objects as a argument.
+ * 3. The component has any other constructor which can take the arguments.
+ * <p>
+ * @return newly created component
+ * @param args the arguments which should be used
+ */
+ public Object createInstanceWithArguments( Object[] args )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ java.lang.Object resObj = null;
+
+ boolean useDefaultCtor = false;
+ // first we try if the component supports the XInitialization interface
+ Class clazz = getServiceClass();
+
+ if ( clazz.isAssignableFrom( XInitialization.class ) )
+ useDefaultCtor = true;
+ else {
+ try {
+ Class parameterTypes[] = { Class.class, Object.class };
+ Method queryMeth = clazz.getMethod("queryInterface", parameterTypes );
+ useDefaultCtor = true;
+ }
+ catch (NoSuchMethodException e) {}
+ catch (SecurityException e) {}
+ }
+
+ if (useDefaultCtor) {
+ resObj = createInstanceWithDefaultConstructor();
+ XInitialization iniObj = (XInitialization) UnoRuntime.queryInterface( XInitialization.class, resObj );
+ iniObj.initialize( args );
+ }
+ else {
+ // try the constructor A(java.lang.Object[])
+ Class[] clazzParams = { Object[].class };
+ java.lang.reflect.Constructor ctor = null;
+
+ try {
+ ctor = clazz.getConstructor( clazzParams );
+ }
+ catch (NoSuchMethodException noSuchMethodEx) {
+ ctor = null;
+ }
+ catch (SecurityException securityEx) {
+ ctor = null;
+ }
+
+ if (ctor == null) {
+ // look for the first matching constructor
+ java.lang.reflect.Constructor ctors[] = clazz.getDeclaredConstructors();
+
+ int i=0;
+ while ( (i<ctors.length) && (resObj==null) ) {
+ try {
+ resObj = ctors[i++].newInstance( args );
+ }
+ catch (InstantiationException instantiationEx) {}
+ catch (IllegalAccessException illegalAccessEx) {}
+ catch (IllegalArgumentException illegalArgumentEx) {}
+ catch (InvocationTargetException invocationTargetEx) {}
+ }
+
+ if (resObj == null)
+ throw new com.sun.star.uno.Exception( "Can not create instance with arguments for " + implName );
+ }
+ else
+ {
+ try {
+ resObj = ctor.newInstance( args );
+ }
+ catch (InstantiationException e) {
+ throw new com.sun.star.uno.Exception("Can not create instance with arguments for "
+ + implName + " because " + e.toString() );
+ }
+ catch (IllegalAccessException e) {
+ throw new com.sun.star.uno.Exception("Can not create instance with arguments for "
+ + implName + " because " + e.toString() );
+ }
+ catch (IllegalArgumentException e) {
+ throw new com.sun.star.uno.Exception("Can not create instance with arguments for "
+ + implName + " because " + e.toString() );
+ }
+ catch (InvocationTargetException e) {
+ throw new com.sun.star.uno.Exception("Can not create instance with arguments for "
+ + implName + " because " + e.toString() );
+ }
+ }
+
+ setServiceManager( resObj );
+
+ }
+
+ return resObj;
+ }
+
+ /**
+ * Supplies the implementation name of the component.
+ * <p>
+ * @return the name of the implementation
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String getImplementationName()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return implName;
+ }
+
+ /**
+ * Verifies whether or not a service is supportet by the component.
+ * <p>
+ * @return true if the service is supported - otherwise false
+ * @param requestedService name of the requested service
+ */
+ public boolean supportsService(String requestedService)
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean found = false;
+ int i = 0;
+
+ if (requestedService == null)
+ throw new com.sun.star.uno.RuntimeException("no service requested");
+
+ String names[] = getServiceNames();
+
+ if (names.length == 0)
+ throw new com.sun.star.uno.RuntimeException("no service name found");
+
+ while (i<names.length && !found)
+ found = names[i++].equals(requestedService);
+
+ return found;
+ }
+
+ /**
+ * Provides a list of all supported services by the component.
+ * <p>
+ * @return list of the service names which are supported by the component
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String[] getSupportedServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return getServiceNames();
+ }
+
+ /**
+ * Supplies the class of the component. If the location URL is specified the
+ * <code>com.sun.star.comp.loader.RegistrationClassFinder</code> is used to obtain the class.
+ * Otherwise the <code>java.lang.Class.forName</code> is called with implementation name.
+ * <p>
+ * @return the class of the component
+ * @see com.sun.star.comp.loader.RegistrationClassFinder
+ */
+ Class getServiceClass()
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (serviceClass == null) {
+ try {
+ if ( locationUrl != null ) {
+ RegistrationClassFinder classFinder = new RegistrationClassFinder( locationUrl );
+ serviceClass = classFinder.getRegistrationClass();
+ }
+ else {
+ serviceClass = Class.forName( implName );
+ }
+ }
+ catch ( java.net.MalformedURLException e ) {
+ throw new com.sun.star.uno.RuntimeException( "can't get the class " + implName + ".\n" + e );
+ }
+ catch ( java.io.IOException e ) {
+ throw new com.sun.star.uno.RuntimeException( "can't get the class " + implName + ".\n" + e );
+ }
+ catch ( java.lang.ClassNotFoundException e ) {
+ throw new com.sun.star.uno.RuntimeException( "can't get the class " + implName + ".\n" + e );
+ }
+ }
+
+ return serviceClass;
+ }
+
+ /**
+ * Extract the service names supported by the component. The optional static member
+ * <code>__serviceName</code> ( <code>serviceName</code> DEPRECATED ) is used to specify the supported
+ * service names. If no member can be found the implementation name is return.
+ * <p>
+ * @return a list with the supported service names
+ */
+ public String[] getServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ String result[] = null;
+ try {
+ Class clazz = getServiceClass();
+ Object attrib = null;
+ try {
+ attrib = clazz.getDeclaredField("__serviceName").get(clazz);
+ } catch (NoSuchFieldException e) {
+//********************* DEPRECATED ******************************************
+ attrib = clazz.getDeclaredField("serviceName").get(clazz);
+//***************************************************************************
+ }
+
+ if ( attrib instanceof String ) {
+ String str = (String) attrib;
+ result = new String[1];
+ result[0] = str;
+ } else
+ result = (String[]) attrib; // expecting an array of Strings - otherwise an exception will be thrown
+ }
+ catch (NoSuchFieldException e) {}
+ catch (SecurityException e) {}
+ catch (IllegalAccessException e) {}
+
+ if (result == null) {
+ result = new String[1];
+ result[0] = implName;
+ }
+
+ return result;
+ }
+
+ public String toString() {
+ String result = super.toString();
+ result += " implementation name: " +getImplementationName();
+ result += " supported services:";
+
+ String[] services = getSupportedServiceNames();
+ for (int i=0; i<services.length; i++)
+ result += " " + services[i];
+
+ return result;
+ }
+}
+
diff --git a/jurt/com/sun/star/comp/loader/JavaLoaderFactory.java b/jurt/com/sun/star/comp/loader/JavaLoaderFactory.java
new file mode 100644
index 000000000000..c08834a37eae
--- /dev/null
+++ b/jurt/com/sun/star/comp/loader/JavaLoaderFactory.java
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * $RCSfile: JavaLoaderFactory.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.loader;
+
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.ServiceNotRegisteredException;
+import com.sun.star.lang.WrappedTargetException;
+
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.uno.Exception;
+
+public class JavaLoaderFactory implements XSingleServiceFactory, XServiceInfo {
+
+ private static String[] supportedServices = {
+ "com.sun.star.loader.Java"
+ };
+
+ private static final boolean DEBUG = false;
+
+ private static final void DEBUG(String dbg) {
+ if (DEBUG)
+ System.err.println(" >>> JavaLoaderFactory - " + dbg);
+ }
+
+ protected XMultiServiceFactory multiServiceFactory = null;
+
+ /** default constructor
+ */
+// public JavaLoaderFactory() {}
+
+ public JavaLoaderFactory(XMultiServiceFactory factory) {
+ multiServiceFactory = factory;
+ }
+
+ public java.lang.Object createInstance()
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ return new JavaLoader(multiServiceFactory);
+ }
+
+ public java.lang.Object createInstanceWithArguments( java.lang.Object[] args )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ JavaLoader loader = new JavaLoader();
+ loader.initialize(args);
+
+ return loader;
+ }
+
+ /** implements the XServiceInfo interface
+ */
+ public String getImplementationName()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return JavaLoader.class.getName();
+ }
+
+ /** implements the XServiceInfo interface
+ */
+ public boolean supportsService(String serviceName)
+ throws com.sun.star.uno.RuntimeException
+ {
+ for ( int i = 0; i < supportedServices.length; i++ ) {
+ if ( supportedServices[i].equals(serviceName) )
+ return true;
+ }
+ return false;
+ }
+
+ /** implements the XServiceInfo interface
+ */
+ public String[] getSupportedServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return supportedServices;
+ }
+}
+
diff --git a/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java b/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java
new file mode 100644
index 000000000000..12ebf6bc626e
--- /dev/null
+++ b/jurt/com/sun/star/comp/loader/RegistrationClassFinder.java
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * $RCSfile: RegistrationClassFinder.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+package com.sun.star.comp.loader;
+
+import com.sun.star.lib.sandbox.ClassContext;
+import com.sun.star.lib.sandbox.ClassContextProxy;
+import com.sun.star.lib.sandbox.Resource;
+import com.sun.star.lib.sandbox.ResourceProxy;
+
+public class RegistrationClassFinder {
+ final static boolean DEBUG = false;
+
+ protected ClassContext m_context = null;
+ protected String m_locationUrl = null;
+ protected String m_manifest = null;
+ protected String m_className = null;
+
+ public RegistrationClassFinder( String locationUrl )
+ throws java.io.IOException,
+ java.net.MalformedURLException
+ {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".<init>:" + locationUrl);
+
+ m_locationUrl = locationUrl;
+
+ if(locationUrl.endsWith(".jar")) {
+ m_context = ClassContextProxy.create(new java.net.URL(m_locationUrl), null, null);
+ m_manifest = locationUrl.substring(0, locationUrl.lastIndexOf('/') + 1) + "META-INF/MANIFEST.MF";
+ }
+ }
+
+ public Class getRegistrationClass()
+ throws java.io.IOException,
+ java.lang.ClassNotFoundException,
+ java.net.MalformedURLException
+ {
+ Class ret = null;
+
+ if (m_context != null) {
+ String className = null;
+
+ java.net.URL url = new java.net.URL(m_locationUrl);
+ Resource resource = ResourceProxy.load(url, null);
+ resource.loadJar(url);
+
+ java.io.InputStream inManifest = ResourceProxy.load(new java.net.URL(m_manifest), null).getInputStream();
+ java.io.BufferedReader manifestReader = new java.io.BufferedReader(new java.io.InputStreamReader(inManifest));
+
+ String line;
+ while ((line = manifestReader.readLine()) != null) {
+ if (line.startsWith("RegistrationClassName: ")) {
+ className = line.substring("RegistrationClassName: ".length() );
+ break;
+ }
+ }
+
+ if (className != null) {
+ ret = m_context.loadClass( className );
+ }
+ }
+ else
+ ret = Class.forName(m_locationUrl);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".getRegistrationClass:" + ret);
+
+ return ret;
+ }
+
+ public Class loadClass( String className )
+ throws java.lang.ClassNotFoundException,
+ java.io.IOException,
+ java.net.MalformedURLException
+ {
+ Class ret = null;
+
+ if (m_context != null) {
+ java.net.URL url = new java.net.URL( m_locationUrl );
+ Resource resource = ResourceProxy.load(url, null);
+ resource.loadJar(url);
+
+ ret = m_context.loadClass(className);
+ } else {
+ ret = Class.forName(className);
+ }
+
+ return ret;
+ }
+}
diff --git a/jurt/com/sun/star/comp/loader/makefile.mk b/jurt/com/sun/star/comp/loader/makefile.mk
new file mode 100644
index 000000000000..8d9d29036715
--- /dev/null
+++ b/jurt/com/sun/star/comp/loader/makefile.mk
@@ -0,0 +1,103 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/comp$/loader
+TARGET = com_sun_star_comp_loader
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+GENJAVAFILES = \
+ $(MISC)$/java$/com$/sun$/star$/lang$/IllegalArgumentException.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/ServiceNotRegisteredException.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/WrappedTargetException.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/XInitialization.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/XMultiServiceFactory.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/XServiceInfo.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/XSingleServiceFactory.java \
+ $(MISC)$/java$/com$/sun$/star$/loader$/CannotActivateFactoryException.java \
+ $(MISC)$/java$/com$/sun$/star$/loader$/XImplementationLoader.java \
+ $(MISC)$/java$/com$/sun$/star$/registry$/XRegistryKey.java \
+ $(MISC)$/java$/com$/sun$/star$/registry$/RegistryValueType.java \
+ $(MISC)$/java$/com$/sun$/star$/registry$/RegistryKeyType.java \
+ $(MISC)$/java$/com$/sun$/star$/registry$/XSimpleRegistry.java \
+ $(MISC)$/java$/com$/sun$/star$/registry$/InvalidRegistryException.java \
+ $(MISC)$/java$/com$/sun$/star$/registry$/InvalidValueException.java \
+ $(MISC)$/java$/com$/sun$/star$/registry$/MergeConflictException.java \
+ $(MISC)$/java$/com$/sun$/star$/registry$/CannotRegisterImplementationException.java \
+ $(MISC)$/java$/com$/sun$/star$/uno$/Exception.java \
+ $(MISC)$/java$/com$/sun$/star$/uno$/RuntimeException.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/FactoryHelper.class \
+ $(CLASSDIR)$/$(PACKAGE)$/JavaLoader.class \
+ $(CLASSDIR)$/$(PACKAGE)$/JavaLoaderFactory.class \
+ $(CLASSDIR)$/$(PACKAGE)$/RegistrationClassFinder.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java
new file mode 100644
index 000000000000..f319ff95918b
--- /dev/null
+++ b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java
@@ -0,0 +1,866 @@
+/*************************************************************************
+ *
+ * $RCSfile: ServiceManager.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.servicemanager;
+
+import com.sun.star.uno.IQueryInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Uik;
+
+import com.sun.star.container.XSet;
+import com.sun.star.container.XContentEnumerationAccess;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.container.XElementAccess;
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.registry.XSimpleRegistry;
+
+import com.sun.star.loader.CannotActivateFactoryException;
+import com.sun.star.loader.XImplementationLoader;
+
+import com.sun.star.comp.loader.RegistrationClassFinder;
+
+import com.sun.star.lang.XEventListener;
+//import com.sun.star.lang.EventObject;
+
+import com.sun.star.comp.loader.JavaLoader;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * The <code>ServiceManager</code> class is an implmentation of the <code>ServiceManager</code>the central class needed for
+ * implementing or using UNO components in Java.
+ * <p>
+ * The Methods <code>queryInterface</code> and <code>isSame</code> delegate
+ * calls to the implementing objects and are used instead of casts
+ * and identity comparisons.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Markus Herzog
+ * @see com.sun.star.lang.XMultiServiceFactory
+ * @see com.sun.star.container.XSet
+ * @see com.sun.star.container.XContentEnumerationAccess
+ * @see com.sun.star.lang.XComponent
+ * @see com.sun.star.lang.XServiceInfo
+ * @see com.sun.star.lang.XInitialization
+ * @since UDK1.0
+ */
+public class ServiceManager implements XMultiServiceFactory,
+ XSet,
+ XContentEnumerationAccess,
+ XComponent,
+ XServiceInfo,
+ XInitialization
+{
+ private static final boolean DEBUG = false;
+
+ private static final void DEBUG (String dbg) {
+ if (DEBUG) System.err.println( dbg );
+ }
+
+ private static com.sun.star.uno.Type UNO_TYPE = null;
+
+ XImplementationLoader loader = null;
+
+ static String[] supportedServiceNames = {
+ "com.sun.star.lang.MultiServiceFactory",
+ "com.sun.star.lang.ServiceManager"
+ };
+
+ java.util.Vector eventListener;
+ java.util.Hashtable factoriesByImplNames;
+ java.util.Hashtable factoriesByServiceNames; // keys:
+
+ /**
+ * Creates a new instance of the <code>ServiceManager</code>.
+ */
+ public ServiceManager() {
+ eventListener = new java.util.Vector();
+ factoriesByImplNames = new java.util.Hashtable();
+ factoriesByServiceNames = new java.util.Hashtable();
+ }
+
+ /**
+ * Returns the service factory for the <code>ServiceManager</code>. If the given implementation name
+ * does not equal to the <code>ServiceManagers</code> class name null will be returned.
+ * <p>
+ * @return the factory for the <code>ServiceManager</code>.
+ * @param implName the implementation name of the of the service.
+ * Must be equal to <code>com.sun.star.comp.servicemanager.ServicManager</code>
+ * @param multiFactory refernce of the <code>MultiServiceFactory</code>. This parameter will be ignored.
+ * @param regKey the root key of the registry. This parameter will be ignored.
+ */
+ public static XSingleServiceFactory getServiceFactory( String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ if ( implName.equals(ServiceManager.class.getName()) )
+ return new ServiceManagerFactory();
+
+ return null;
+ }
+
+
+ /**
+ * Supplies a Java component loader. The loader component must be enlisted at the <code>ServiceManager</code> before.
+ * <p>
+ * @return a new instance of the Java component loader
+ * @see com.sun.star.loader.Java
+ */
+ private XImplementationLoader getLoader()
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ Object[] param = { this };
+ DEBUG("make loader");
+ Object loaderObj = createInstanceWithArguments( "com.sun.star.loader.Java", param );
+
+ if (loaderObj == null)
+ throw new com.sun.star.uno.Exception("Can get an instance of com.sun.star.loader.Java");
+
+ return (XImplementationLoader) UnoRuntime.queryInterface( XImplementationLoader.class, loaderObj );
+ }
+
+ /**
+ * Registers a list of components given by their class names.
+ * <p>
+ * @param newImpls list of the components that should be registered, given by their class names.
+ * If any exception occured during the registration, the process will be canceled.
+ * @see com.sun.star.container.XSet
+ */
+ public void addFactories( String[] newImpls )
+ throws com.sun.star.uno.Exception
+ {
+ for (int i=0; i<newImpls.length; i++) {
+ DEBUG ("try to add " + newImpls[i] );
+ Object newFactory = null;
+
+ try {
+ if (loader == null)
+ loader = getLoader();
+
+ newFactory = loader.activate( newImpls[i], null, null, null );
+ }
+ catch (com.sun.star.uno.Exception e) {
+
+//****************************** BEGIN DEPRECATED ******************************************
+
+ try {
+ // try to get the class of the implementation
+ Class clazz = Class.forName( newImpls[i] );
+
+ Class[] methodClassParam = { String.class, XMultiServiceFactory.class, XRegistryKey.class };
+ java.lang.reflect.Method getFactoryMeth = null;
+ try {
+ getFactoryMeth = clazz.getMethod("__getServiceFactory", methodClassParam);
+ }
+ catch (NoSuchMethodException noSuchMethodEx) {
+ getFactoryMeth = null;
+ }
+ catch (SecurityException securityExc) {
+ getFactoryMeth = null;
+ }
+
+ if (getFactoryMeth == null)
+ getFactoryMeth = clazz.getMethod("getServiceFactory", methodClassParam);
+
+ Object[] methodParams = { newImpls[i], this, null };
+ newFactory = getFactoryMeth.invoke( clazz, methodParams );
+ }
+ catch (NoSuchMethodException ex) {}
+ catch (SecurityException ex) {}
+ catch (ClassNotFoundException ex) {}
+ catch (IllegalAccessException ex) {}
+ catch (IllegalArgumentException ex) {}
+ catch (InvocationTargetException ex) {}
+
+//****************************** END DEPRECATED ******************************************
+ }
+
+ if ( newFactory == null )
+ throw new com.sun.star.loader.CannotActivateFactoryException("Can not get factory for " + newImpls[i]);
+
+ insert( newFactory );
+ } // end of for ...
+ }
+
+ /**
+ * The method is used to add components to the <code>ServiceManager</code>. The first argument indicates a <code>SimpleRegistry</code>.
+ * The components which should be added will be searched under the <i>Implementations</i> key in the registry.
+ * <p>
+ * @param args the first argument ( args[0] ) specifices the SimpleRegistry object
+ * @see com.sun.star.lang.XInitialization
+ * @see com.sun.star.lang.RegistryServiceManager
+ * @see com.sun.star.lang.XSimpleRegistry
+ */
+ public void initialize( Object args[] )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException {
+ XSimpleRegistry xSimpleRegistry = null;
+ try {
+ xSimpleRegistry = (XSimpleRegistry) args[0];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ throw new com.sun.star.lang.IllegalArgumentException("Argument must not be null.");
+ }
+
+ XRegistryKey rootkey = xSimpleRegistry.getRootKey();
+
+ XRegistryKey implkey_xRegistryKey = rootkey.openKey("Implementations");
+ if(implkey_xRegistryKey != null) {
+ XRegistryKey xRegistryKeys[] = implkey_xRegistryKey.openKeys();
+
+ for(int i = 0; i < xRegistryKeys.length; ++ i) {
+ addFactories(new String[]{xRegistryKeys[i].getStringValue()});
+ }
+ }
+ }
+
+ /**
+ * Creates a new instance of a specified service. Therefor the associated factory of the service is
+ * looked up and used to instanciate a new component.
+ * <p>
+ * @return newly created component
+ * @param serviceSpecifier indicates the service or component name
+ * @see com.sun.star.lang.XMultiServiceFactory
+ */
+ public java.lang.Object createInstance( String serviceSpecifier )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ return queryServiceFactory(serviceSpecifier).createInstance();
+ }
+
+ /**
+ * Creates a new instance of a specified service with the given parameters.
+ * Therefor the associated factory of the service is looked up and used to instanciate a new component.
+ * <p>
+ * @return newly created component
+ * @param serviceSpecifier indicates the service or component name
+ * @see com.sun.star.lang.XMultiServiceFactory
+ */
+ public java.lang.Object createInstanceWithArguments ( String serviceSpecifier,
+ Object[] args )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ if (DEBUG) {
+ System.err.println("createInstanceWithArguments:" );
+
+ for (int i=0; i<args.length; i++)
+ System.err.print(" "+ args[i]);
+
+ System.err.println();
+ }
+
+ return queryServiceFactory(serviceSpecifier).createInstanceWithArguments( args );
+ }
+
+ /**
+ * Look up the factory for a given service or implementation name.
+ * First the requested service name is search in the list of avaible services. If it can not be found
+ * the name is looked up in the the implementation list.
+ * <p>
+ * @return the factory of the service / implementation
+ * @param serviceSpecifier indicates the service or implementation name
+ * @see com.sun.star.lang.XMultiServiceFactory
+ */
+ private XSingleServiceFactory queryServiceFactory(String serviceName)
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ DEBUG("queryServiceFactory for name " + serviceName );
+ Object factory = null;
+
+ if ( factoriesByServiceNames.containsKey( serviceName ) ) {
+ java.util.Vector aviableFact = (java.util.Vector) factoriesByServiceNames.get( serviceName );
+
+ DEBUG("");
+ DEBUG("aviable factories for " + serviceName +" "+ aviableFact);
+ DEBUG("");
+
+ if ( !aviableFact.isEmpty() )
+ factory = aviableFact.firstElement();
+
+ } else // not found in list of services - now try the implementations
+ factory = factoriesByImplNames.get( serviceName ); // return null if none is aviable
+
+ if (DEBUG) {
+ if (factory == null) System.err.println("service not registered");
+ else
+ System.err.println("service found:" + factory + " " + UnoRuntime.queryInterface(XSingleServiceFactory.class, factory));
+ }
+
+ if (factory == null)
+ throw new com.sun.star.uno.Exception("Query for service factory for " + serviceName + " failed.");
+
+ return (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, factory);
+ }
+
+ /**
+ * Supplies a list of all avialable services names.
+ * <p>
+ * @return list of Strings of all service names
+ * @see com.sun.star.container.XContentEnumerationAccess
+ */
+ public String[] getAvailableServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ int i = 0;
+ String[] availableServiceNames = new String[factoriesByServiceNames.size()];
+
+ java.util.Enumeration keys = factoriesByServiceNames.keys();
+
+ while (keys.hasMoreElements())
+ availableServiceNames[i++] = (String) keys.nextElement();
+
+ return availableServiceNames;
+ }
+
+ /**
+ * Removes all listeners from the <code>ServiceManager</code> and clears the list of the services.
+ * <p>
+ * @see com.sun.star.lang.XComponent
+ */
+ public void dispose()
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (eventListener != null) {
+ java.util.Enumeration enum = eventListener.elements();
+
+ while (enum.hasMoreElements()) {
+ XEventListener listener = (XEventListener) enum.nextElement();
+ listener.disposing(new com.sun.star.lang.EventObject(this));
+ }
+ }
+
+ eventListener.removeAllElements();
+ factoriesByServiceNames.clear();
+ factoriesByImplNames.clear();
+ }
+
+ /**
+ * Adds a new <code>EventListener</code>. The listener is notified when a
+ * service is added (removed) to (from) the <code>ServiceManager</code>.
+ * If the listener is already registred a
+ * <code>com.sun.star.uno.RuntimeException</code> will be thrown.
+ * <p>
+ * @param xListener the new listener which should been added.
+ * @see com.sun.star.lang.XComponent
+ */
+ public void addEventListener( XEventListener xListener )
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (xListener == null)
+ throw new com.sun.star.uno.RuntimeException("Listener must not be null");
+
+ if ( eventListener.contains(xListener) )
+ throw new com.sun.star.uno.RuntimeException("Listener already registred.");
+
+ eventListener.addElement(xListener);
+ }
+
+ /**
+ * Removes a <code>EventListener</code> from the <code>ServiceManager</code>.
+ * If the listener is not registered a <code>com.sun.star.uno.RuntimeException</code>
+ * will be thrown.
+ * <p>
+ * @param xListener the new listener which should been removed.
+ * @see com.sun.star.lang.XComponent
+ */
+ public void removeEventListener( XEventListener xListener )
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (xListener == null)
+ throw new com.sun.star.uno.RuntimeException("Listener must not be null");
+
+ if ( !eventListener.contains(xListener) )
+ throw new com.sun.star.uno.RuntimeException("Listener is not registered.");
+
+ eventListener.removeElement(xListener);
+ }
+
+ /**
+ * Checks if a component is registered at the <code>ServiceManager</code>. The given object argument must
+ * provide a <code>XServiceInfo</code> interface.
+ * <p>
+ * @return true if the component is registred otherwise false.
+ * @param object object which provides a <code>XServiceInfo</code> interface.
+ * @see com.sun.star.container.XSet
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public boolean has( Object object )
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (object == null)
+ throw new com.sun.star.uno.RuntimeException("The parameter must not been null");
+
+ XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, object);
+
+ if (xServiceInfo != null) {
+ return UnoRuntime.areSame(factoriesByImplNames.get(xServiceInfo.getImplementationName()), object);
+ }
+
+ return false;
+ }
+
+ /**
+ * Adds a <code>SingleServiceFactory</code> to the <code>ServiceManager</code>.
+ * <p>
+ * @param object factory which should be added.
+ * @see com.sun.star.container.XSet
+ * @see com.sun.star.lang.XSingleServiceFactory
+ */
+ public void insert( Object object )
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.container.ElementExistException,
+ com.sun.star.uno.RuntimeException
+ {
+ if (object == null) throw new com.sun.star.lang.IllegalArgumentException();
+
+ XSingleServiceFactory newFactory =
+ (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, object);
+
+ if ( newFactory == null )
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "The given object does not implement the XSingleServiceFactory interface."
+ );
+
+ XServiceInfo xServiceInfo =
+ (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, object);
+
+ if (xServiceInfo == null)
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "The given object does not implement the XServiceInfo interface."
+ );
+
+ if ( factoriesByImplNames.containsKey( xServiceInfo.getImplementationName() ) ) {
+ throw new com.sun.star.container.ElementExistException(
+ xServiceInfo.getImplementationName() + " already registred"
+ );
+ }
+
+ DEBUG("add factory " + object.toString() + " for " + xServiceInfo.getImplementationName());
+ factoriesByImplNames.put( xServiceInfo.getImplementationName(), object );
+
+
+ String[] serviceNames = xServiceInfo.getSupportedServiceNames();
+ java.util.Vector vec = null;
+
+ for (int i=0; i<serviceNames.length; i++) {
+ if ( !factoriesByServiceNames.containsKey( serviceNames[i] ) ) {
+ DEBUG("no registered services found under " + serviceNames[i] );
+ factoriesByServiceNames.put(serviceNames[i], new java.util.Vector());
+ }
+
+ vec = (java.util.Vector) factoriesByServiceNames.get( serviceNames[i] );
+
+ if ( vec.contains( object ) )
+ System.err.println("The implementation " + xServiceInfo.getImplementationName() +
+ " already registered for the service " + serviceNames[i] + " - ignoring!");
+ else
+ vec.addElement(object);
+ }
+ }
+
+ /**
+ * Removes a <code>SingleServiceFactory</code> from the <code>ServiceManager</code>.
+ * <p>
+ * @param object factory which should be removed.
+ * @see com.sun.star.container.XSet
+ * @see com.sun.star.lang.XSingleServiceFactory
+ */
+ public void remove( Object object )
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.uno.RuntimeException
+ {
+ if (object == null)
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "The given object must not be null."
+ );
+
+ XServiceInfo xServiceInfo =
+ (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, object);
+
+ if (xServiceInfo == null)
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "The given object does not implement the XServiceInfo interface."
+ );
+
+ XSingleServiceFactory xSingleServiceFactory =
+ (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, object);
+
+ if (xSingleServiceFactory == null)
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "The given object does not implement the XSingleServiceFactory interface."
+ );
+
+ if ( factoriesByImplNames.remove( xServiceInfo.getImplementationName() ) == null )
+ throw new com.sun.star.container.NoSuchElementException(
+ xServiceInfo.getImplementationName() +
+ " is not registered as an implementation."
+ );
+
+ String[] serviceNames = xServiceInfo.getSupportedServiceNames();
+
+ for ( int i=0; i<serviceNames.length; i++ ) {
+ if ( factoriesByServiceNames.containsKey( serviceNames[i] ) ) {
+ java.util.Vector vec = (java.util.Vector) factoriesByServiceNames.get(serviceNames[i]);
+
+ if ( !vec.removeElement(object) )
+ System.err.println("The implementation " + xServiceInfo.getImplementationName() +
+ " is not registered for the service " + serviceNames[i] + " - ignoring!");
+
+ if ( vec.isEmpty() ) // remove the vector if no implementations aviable for the service
+ factoriesByServiceNames.remove( serviceNames[i] );
+ }
+ }
+ }
+
+ /**
+ * Provides an enumeration of all registred services.
+ * <p>
+ * @return an enumeration of all avialable services.
+ * @see com.sun.star.conatiner.XEnumerationAccess
+ */
+ public XEnumeration createEnumeration()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return new ServiceEnumerationImpl( factoriesByImplNames.elements() );
+ }
+
+ /**
+ * Provides the UNO type of the <code>ServiceManager</code>
+ * <p>
+ * @return the UNO type of the <code>ServiceManager</code>.
+ * @see com.sun.star.container.XElementAccess
+ * @see com.sun.star.uno.TypeClass
+ */
+ public com.sun.star.uno.Type getElementType()
+ throws com.sun.star.uno.RuntimeException
+ {
+ if ( UNO_TYPE == null )
+ try {
+ UNO_TYPE = new com.sun.star.uno.Type( com.sun.star.uno.TypeClass.SERVICE,
+ ServiceManager.class.getName(),
+ ServiceManager[].class.getName(),
+ ServiceManager.class );
+ }
+ catch (com.sun.star.uno.Exception e) {
+ com.sun.star.uno.RuntimeException rte = new com.sun.star.uno.RuntimeException();
+ rte.fillInStackTrace();
+ throw rte;
+ }
+
+ return UNO_TYPE;
+ }
+
+ /**
+ * Checks if the any componets are registered.
+ * <p>
+ * @return true - if the list of the registred components is not empty - otherwise false.
+ * @see com.sun.star.container.XElementAccess
+ */
+ public boolean hasElements() {
+ return ! factoriesByImplNames.isEmpty();
+ }
+
+ /**
+ * Provides an enumeration of of all factorys for a specified service.
+ * <p>
+ * @return an enumeration for service name.
+ * @param serviceName name of the requested service
+ * @see com.sun.star.container.XContentEnumerationAccess
+ */
+ public XEnumeration createContentEnumeration( String serviceName )
+ throws com.sun.star.uno.RuntimeException
+ {
+ XEnumeration enum = null;
+
+ java.util.Vector serviceList = (java.util.Vector) factoriesByServiceNames.get(serviceName);
+
+ if (serviceList != null)
+ enum = new ServiceEnumerationImpl( serviceList.elements() );
+ else
+ enum = new ServiceEnumerationImpl();
+
+ return enum;
+ }
+
+ /**
+ * Returns the implementation name of the <code>ServiceManager</code> component.
+ * <p>
+ * @return the class name of the <code>ServiceManager</code>.
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String getImplementationName()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return getClass().getName();
+ }
+
+ /**
+ * Checks if the <code>ServiceManager</code> supports a service.
+ * <p>
+ * @return true if the service is supported - otherwise false.
+ * @param serviceName service name which should be checked.
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public boolean supportsService( String serviceName )
+ throws com.sun.star.uno.RuntimeException
+ {
+ for (int i=0; i<supportedServiceNames.length; i++)
+ if (supportedServiceNames[i].equals( serviceName )) return true;
+
+ if (getImplementationName().equals( serviceName )) return true;
+
+ return false;
+ }
+
+ /**
+ * Supplies list of all supported services.
+ * <p>
+ * @return a list of all supported service names.
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String[] getSupportedServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return supportedServiceNames;
+ }
+
+ /**
+ * The <code>ServiceEnumerationImpl</code> class provides an
+ * implementation of the @see com.sun.star.container.XEnumeration interface.
+ * It is a inner wrapper for a java.util.Enumeration object.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Markus Herzog
+ * @see com.sun.star.lang.XSingleServiceFactory
+ * @see com.sun.star.lang.XServiceInfo
+ * @since UDK1.0
+ */
+ class ServiceEnumerationImpl implements XEnumeration {
+ java.util.Enumeration enumeration = null;
+
+ /**
+ * Constructs a new empty instance.
+ */
+ public ServiceEnumerationImpl() {
+ }
+
+ /**
+ * Constructs a new instance with a given enumeration.
+ * <p>
+ * @param enum is the enumeration which should been wrapped.
+ * @see com.sun.star.container.XEnumeration
+ */
+ public ServiceEnumerationImpl(java.util.Enumeration enum) {
+ enumeration = enum;
+ }
+
+ /**
+ * Checks if the enumeration contains more elements.
+ * <p>
+ * @return true if more elements are available - otherwise false.
+ * @see com.sun.star.container.XEnumeration
+ */
+ public boolean hasMoreElements()
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (enumeration != null)
+ return enumeration.hasMoreElements();
+
+ return false;
+ }
+
+ /**
+ * Returns the next element of the enumeration. If no further elements
+ * available a com.sun.star.container.NoSuchElementException exception will be thrown.
+ * <p>
+ * @return the next element.
+ * @see com.sun.star.container.XEnumeration
+ */
+ public Object nextElement()
+ throws com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException,
+ com.sun.star.uno.RuntimeException
+ {
+ if (enumeration == null)
+ throw new com.sun.star.container.NoSuchElementException();
+
+ try {
+ return enumeration.nextElement();
+ } catch (java.util.NoSuchElementException e) {
+ com.sun.star.container.NoSuchElementException ex =
+ new com.sun.star.container.NoSuchElementException();
+ ex.fillInStackTrace();
+
+ throw ex;
+ }
+ }
+ }
+}
+/**
+ * The <code>ServiceManagerFactory</code> is the factory class for the
+ * <code>ServiceManager</code>. As all factories it implments the
+ * com.sun.star.lang.XSingleServiceFactory and the com.sun.star.lang.XServiceInfo
+ * interfaces.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:51 $
+ * @author Markus Herzog
+ * @see com.sun.star.lang.XSingleServiceFactory
+ * @see com.sun.star.lang.XServiceInfo
+ * @since UDK1.0
+*/
+class ServiceManagerFactory
+ implements XServiceInfo,
+ XSingleServiceFactory
+{
+ /**
+ * Creates a new instance of the <code>ServiceManagerFactory</code>.
+ */
+ public ServiceManagerFactory() {
+ }
+
+ /**
+ * Supplies the implementation name of the <code>ServiceManager</code>.
+ * <p>
+ * @return <code>ServiceManager</code> class name.
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String getImplementationName()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return ServiceManager.class.getName();
+ }
+
+ /**
+ * Checks wether or not a service is supported.
+ * <p>
+ * @return true - if the service is supported, otherwise false.
+ * @param serviceName the name of the service that should be checked.
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public boolean supportsService( String serviceName )
+ throws com.sun.star.uno.RuntimeException
+ {
+ for ( int i=0; i<ServiceManager.supportedServiceNames.length; i++ )
+ if ( ServiceManager.supportedServiceNames[i].equals(serviceName) ) return true;
+
+ if ( getImplementationName().equals(serviceName) ) return true;
+
+ return false;
+ }
+
+ /**
+ * Returns all service names which are supported by <code>ServiceManager</code>.
+ * <p>
+ * @return a list aof all supported service names.
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String[] getSupportedServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return ServiceManager.supportedServiceNames;
+ }
+
+ /**
+ * Creates a new instance of the <code>ServiceManager</code>.
+ * <p>
+ * @return newly created <code>ServiceManager</code> object.
+ * @see com.sun.star.lang.XSingleServiceFactory
+ */
+ public java.lang.Object createInstance()
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ return new ServiceManager();
+ }
+
+ /**
+ * Creates a new instance of the <code>ServiceManager</code> with arguments.
+ * At this time it always throws a com.sun.star.lang.NoSuchMethodException
+ * because there is no the <code>ServiceManager</code> has no constructor with
+ * arguments.
+ * <p>
+ * @return null - allways throws an exception
+ * @param aArguments arguments for new instance.
+ * @see com.sun.star.lang.XSingleServiceFactory
+ */
+ public java.lang.Object createInstanceWithArguments( java.lang.Object[] aArguments )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ throw new com.sun.star.lang.NoSuchMethodException("Constructor with arguments is not supported.");
+ }
+}
+
+
diff --git a/jurt/com/sun/star/comp/servicemanager/makefile.mk b/jurt/com/sun/star/comp/servicemanager/makefile.mk
new file mode 100644
index 000000000000..70a2ea5e0d73
--- /dev/null
+++ b/jurt/com/sun/star/comp/servicemanager/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:51 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/comp$/servicemanager
+TARGET = com_sun_star_comp_servicemanager
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+GENJAVAFILES = \
+ $(MISC)$/java$/com$/sun$/star$/container$/ElementExistException.java \
+ $(MISC)$/java$/com$/sun$/star$/container$/NoSuchElementException.java \
+ $(MISC)$/java$/com$/sun$/star$/container$/XSet.java \
+ $(MISC)$/java$/com$/sun$/star$/container$/XContentEnumerationAccess.java \
+ $(MISC)$/java$/com$/sun$/star$/container$/XEnumeration.java \
+ $(MISC)$/java$/com$/sun$/star$/container$/XEnumerationAccess.java \
+ $(MISC)$/java$/com$/sun$/star$/container$/XElementAccess.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/EventObject.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/XEventListener.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/NoSuchMethodException.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/XComponent.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/ServiceManager.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/jurt/com/sun/star/comp/urlresolver/UrlResolver.java b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java
new file mode 100644
index 000000000000..fde6d3f11df0
--- /dev/null
+++ b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java
@@ -0,0 +1,210 @@
+/*************************************************************************
+ *
+ * $RCSfile: UrlResolver.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.urlresolver;
+
+
+import java.util.Enumeration;
+
+
+import com.sun.star.bridge.BridgeExistsException;
+import com.sun.star.bridge.XBridge;
+import com.sun.star.bridge.XBridgeFactory;
+import com.sun.star.bridge.XInstanceProvider;
+import com.sun.star.bridge.XUnoUrlResolver;
+
+import com.sun.star.comp.loader.FactoryHelper;
+
+import com.sun.star.connection.ConnectionSetupException;
+import com.sun.star.connection.NoConnectException;
+import com.sun.star.connection.XConnection;
+import com.sun.star.connection.XConnector;
+
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.registry.XRegistryKey;
+
+import com.sun.star.uno.MappingException;
+import com.sun.star.uno.UnoRuntime;
+
+
+/**
+ * This component gives a factory for an <code>UnoUrlResolver</code> service.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.brige.XBrideFactory
+ * @see com.sun.star.connection.Connector
+ * @since UDK1.0
+ */
+public class UrlResolver {
+ static private final boolean DEBUG = true;
+
+
+ static public class _UrlResolver implements XUnoUrlResolver {
+ static private final String __serviceName = "com.sun.star.bridge.UnoUrlResolver";
+
+ private XMultiServiceFactory _xMultiServiceFactory;
+
+ public _UrlResolver(XMultiServiceFactory xMultiServiceFactory) {
+ _xMultiServiceFactory = xMultiServiceFactory;
+ }
+
+ public Object resolve(/*IN*/String dcp) throws NoConnectException, ConnectionSetupException, IllegalArgumentException, com.sun.star.uno.RuntimeException {
+ String conDcp = null;
+ String protDcp = null;
+ String rootOid = null;
+
+ if(dcp.indexOf(';') == -1) {// use old style
+ conDcp = dcp;
+ protDcp = "iiop";
+ rootOid = "classic_uno";
+ }
+ else { // new style
+ int index = dcp.indexOf(':');
+ String url = dcp.substring(0, index).trim();
+ dcp = dcp.substring(index + 1).trim();
+
+ index = dcp.indexOf(';');
+ conDcp = dcp.substring(0, index).trim();
+ dcp = dcp.substring(index + 1).trim();
+
+ index = dcp.indexOf(';');
+ protDcp = dcp.substring(0, index).trim();
+ dcp = dcp.substring(index + 1).trim();
+
+ rootOid = dcp.trim().trim();
+ }
+
+ Object rootObject = null;
+
+ try {
+ XBridgeFactory xBridgeFactory = (XBridgeFactory)UnoRuntime.queryInterface(XBridgeFactory.class,
+ _xMultiServiceFactory.createInstance("com.sun.star.bridge.BridgeFactory"));
+
+ XBridge xBridge = xBridgeFactory.getBridge(conDcp + ";" + protDcp);
+
+ if(xBridge == null) {
+ Object connector = _xMultiServiceFactory.createInstance("com.sun.star.connection.Connector");
+
+ XConnector connector_xConnector = (XConnector)UnoRuntime.queryInterface(XConnector.class, connector);
+
+ // connect to the server
+ XConnection xConnection = connector_xConnector.connect(conDcp);
+
+ xBridge = xBridgeFactory.createBridge(conDcp + ";" + protDcp, protDcp, xConnection, null);
+ }
+ rootObject = xBridge.getInstance(rootOid);
+ }
+ catch(Exception exception) {
+ if(DEBUG) {
+ System.err.println("##### " + getClass().getName() + ".resolve - exception occurred:" + exception);
+ exception.printStackTrace();
+ }
+ throw new com.sun.star.uno.RuntimeException(exception.getMessage());
+ }
+
+ return rootObject;
+ }
+ }
+
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be uses if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(UrlResolver.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(_UrlResolver.class,
+ _UrlResolver.__serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(_UrlResolver.class.getName(), _UrlResolver.__serviceName, regKey);
+ }
+
+}
+
diff --git a/jurt/com/sun/star/comp/urlresolver/makefile.mk b/jurt/com/sun/star/comp/urlresolver/makefile.mk
new file mode 100644
index 000000000000..9fa049fdc016
--- /dev/null
+++ b/jurt/com/sun/star/comp/urlresolver/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/comp$/urlresolver
+TARGET = com_sun_star_comp_urlresolver
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# Files --------------------------------------------------------
+
+
+GENJAVAFILES = \
+ $(MISC)$/java$/com$/sun$/star$/bridge$/BridgeExistsException.java \
+ $(MISC)$/java$/com$/sun$/star$/bridge$/XUnoUrlResolver.java
+
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/UrlResolver.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/jurt/com/sun/star/lib/connections/socket/SocketConnection.java b/jurt/com/sun/star/lib/connections/socket/SocketConnection.java
new file mode 100644
index 000000000000..2cd188bae91d
--- /dev/null
+++ b/jurt/com/sun/star/lib/connections/socket/SocketConnection.java
@@ -0,0 +1,275 @@
+/*************************************************************************
+ *
+ * $RCSfile: SocketConnection.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+package com.sun.star.lib.connections.socket;
+
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import java.net.Socket;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+
+import com.sun.star.io.XStreamListener;
+
+import com.sun.star.connection.XConnection;
+import com.sun.star.connection.XConnectionBroadcaster;
+
+/**
+ * The SocketConnection implements the <code>XConnection</code> interface
+ * and is uses by the <code>SocketConnector</code> and the <code>SocketAcceptor</code>.
+ * This class is not part of the provided <code>api</code>.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.comp.connections.SocketAcceptor
+ * @see com.sun.star.comp.connections.SocketConnector
+ * @see com.sun.star.connections.XConnection
+ * @since UDK1.0
+ */
+public class SocketConnection implements XConnection, XConnectionBroadcaster {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ protected String _description;
+ protected Socket _socket;
+ protected InputStream _inputStream;
+ protected OutputStream _outputStream;
+ protected Vector _listeners;
+ protected boolean _firstRead;
+
+ /**
+ * Constructs a new <code>SocketConnection</code>.
+ * <p>
+ * @param description the description of the connection
+ * @param socket the socket of the connection
+ */
+ public SocketConnection(String description, Socket socket) throws IOException {
+ if (DEBUG) System.err.println("##### " + getClass().getName() + " - instantiated " + description + " " + socket);
+
+ _description = description;
+ _socket = socket;
+ _socket.setTcpNoDelay(true);
+ _inputStream = new BufferedInputStream(socket.getInputStream());
+ _outputStream = new BufferedOutputStream(socket.getOutputStream());
+
+ _listeners = new Vector();
+ _firstRead = true;
+ }
+
+
+
+
+ public void addStreamListener(XStreamListener aListener ) throws com.sun.star.uno.RuntimeException {
+ _listeners.addElement(aListener);
+ }
+
+ public void removeStreamListener(XStreamListener aListener ) throws com.sun.star.uno.RuntimeException {
+ _listeners.removeElement(aListener);
+ }
+
+ private void notifyListeners_open() {
+ Enumeration elements = _listeners.elements();
+ while(elements.hasMoreElements()) {
+ XStreamListener xStreamListener = (XStreamListener)elements.nextElement();
+ xStreamListener.started();
+ }
+ }
+
+ private void notifyListeners_close() {
+ Enumeration elements = _listeners.elements();
+ while(elements.hasMoreElements()) {
+ XStreamListener xStreamListener = (XStreamListener)elements.nextElement();
+ xStreamListener.closed();
+ }
+ }
+
+ private void notifyListeners_error(com.sun.star.uno.Exception exception) {
+ Enumeration elements = _listeners.elements();
+ while(elements.hasMoreElements()) {
+ XStreamListener xStreamListener = (XStreamListener)elements.nextElement();
+ xStreamListener.error(exception);
+ }
+ }
+
+
+ /**
+ * Read the required number of bytes.
+ * <p>
+ * @return the number of bytes read
+ * @param aReadBytes the outparameter, where the bytes have to be placed
+ * @param nBytesToRead the number of bytes to read
+ * @see com.sun.star.connections.XConnection#read
+ */
+ public int read(/*OUT*/byte[][] bytes, int nBytesToRead) throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ if(_firstRead) {
+ _firstRead = false;
+
+ notifyListeners_open();
+ }
+
+ int read_bytes = 0;
+
+ bytes[0] = new byte[nBytesToRead];
+
+ try {
+ do {
+ int count = _inputStream.read(bytes[0], read_bytes, nBytesToRead - read_bytes);
+ if(count == -1)
+ throw new com.sun.star.io.IOException("EOF reached - " + getDescription());
+
+ read_bytes += count;
+ }
+ while(read_bytes >= 0 && read_bytes < nBytesToRead);
+ }
+ catch(IOException ioException) {
+ if(DEBUG) {
+ System.err.println("##### " + getClass().getName() + ".read - exception occurred:" + ioException);
+ ioException.printStackTrace();
+ }
+
+ com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException.toString());
+ notifyListeners_error(unoIOException);
+
+ throw unoIOException;
+ }
+
+ if (DEBUG) System.err.println("##### " + getClass().getName() + " - read byte:" + read_bytes + " " + bytes[0]);
+
+ return read_bytes;
+ }
+
+ /**
+ * Write bytes.
+ * <p>
+ * @param aData the bytes to write
+ * @see com.sun.star.connections.XConnection#write
+ */
+ public void write(byte aData[]) throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ try {
+ _outputStream.write(aData);
+ }
+ catch(IOException ioException) {
+ com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException.toString());
+ notifyListeners_error(unoIOException);
+
+ throw unoIOException;
+ }
+
+ if (DEBUG) System.err.println("##### " + getClass().getName() + " - written bytes:" + aData + " " + aData.length);
+ }
+
+ /**
+ * Flushes the buffer.
+ * <p>
+ * @see com.sun.star.connections.XConnection#flush
+ */
+ public void flush() throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ try {
+ _outputStream.flush();
+ }
+ catch(IOException ioException) {
+ com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException.toString());
+ notifyListeners_error(unoIOException);
+
+ throw unoIOException;
+ }
+ }
+
+ /**
+ * Closes the connection.
+ * <p>
+ * @see com.sun.star.connections.XConnection#close
+ */
+ public void close() throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ try {
+ _socket.close();
+ }
+ catch(IOException ioException) {
+ com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException.toString());
+ notifyListeners_error(unoIOException);
+
+ throw unoIOException;
+ }
+ if (DEBUG) System.err.println("##### " + getClass().getName() + " - socket closed");
+
+ notifyListeners_close();
+ }
+
+ /**
+ * Gives a description of the connection.
+ * <p>
+ * @return the description
+ * @see com.sun.star.connections.XConnection#getDescription
+ */
+ public String getDescription() throws com.sun.star.uno.RuntimeException {
+ return _description;
+ }
+
+}
+
diff --git a/jurt/com/sun/star/lib/connections/socket/makefile.mk b/jurt/com/sun/star/lib/connections/socket/makefile.mk
new file mode 100644
index 000000000000..0ff371969ab2
--- /dev/null
+++ b/jurt/com/sun/star/lib/connections/socket/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/lib$/connections$/socket
+TARGET = com_sun_star_connections_socket
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+GENJAVAFILES= \
+ $(MISC)$/java$/com$/sun$/star$/connection$/AlreadyAcceptingException.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/ConnectionSetupException.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/NoConnectException.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/XAcceptor.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/XConnection.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/XConnector.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/XConnectionBroadcaster.java \
+ $(MISC)$/java$/com$/sun$/star$/io$/XStreamListener.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/socketAcceptor.class \
+ $(CLASSDIR)$/$(PACKAGE)$/SocketConnection.class \
+ $(CLASSDIR)$/$(PACKAGE)$/socketConnector.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
new file mode 100644
index 000000000000..e659a8e3ae8f
--- /dev/null
+++ b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
@@ -0,0 +1,262 @@
+/*************************************************************************
+ *
+ * $RCSfile: socketAcceptor.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.connections.socket;
+
+
+import java.io.IOException;
+
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+
+import com.sun.star.comp.loader.FactoryHelper;
+
+import com.sun.star.connection.XAcceptor;
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.registry.XRegistryKey;
+
+/**
+ * The socketAcceptor class is a component,
+ * that implements the <code>XAcceptor</code> Interface.
+ * <p>
+ * The socketAcceptor is a specialized component, which uses
+ * <code>sockets</code> for communication.
+ * The socketAcceptor is in general used by the Acceptor service.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.connections.XAcceptor
+ * @see com.sun.star.connections.XConnector
+ * @see com.sun.star.connections.XConnection
+ * @see com.sun.star.loader.JavaLoader
+ * @since UDK1.0
+ */
+public class socketAcceptor implements XAcceptor {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ /**
+ * The name of the service, the <code>JavaLoader</code> acceses this through reflection.
+ */
+ static public final String __serviceName = "com.sun.star.connection.socketAcceptor";
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be uses if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(socketAcceptor.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(socketAcceptor.class,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(socketAcceptor.class.getName(), __serviceName, regKey);
+ }
+
+
+ protected ServerSocket _serverSocket;
+ protected int _port = 6001;
+ protected String _hostname = "0";
+ protected int _backlog = 50;
+ protected String _description;
+
+
+ /**
+ * Accepts a connect request through the described socket.
+ * This call blocks until a connection has been established.
+ * <p>
+ * The description has the following format:
+ * [,attribute_name=attribute_value]
+ * Supported attributes at the moment are:
+ * <dl>
+ * <li> host - the name of interface (defaults to 0 == all interfaces
+ * <li> port - the port number (default to 6001)
+ * </dl>
+ * <p>
+ * @return an <code>XConnection</code> to the client
+ * @param description the description of the network interface
+ * @see com.sun.star.connections.XConnector
+ * @see com.sun.star.connections.XConnection
+ */
+ public XConnection accept(String sConnectionDescription )
+ throws com.sun.star.connection.AlreadyAcceptingException,
+ com.sun.star.connection.ConnectionSetupException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.uno.RuntimeException
+ {
+ XConnection xConnection = null;
+
+ try {
+ if(_description == null) {
+ _description = sConnectionDescription;
+
+ // find hostname
+ int index = sConnectionDescription.indexOf(':');
+ if(index >= 0) { // old style
+ _hostname = sConnectionDescription.substring(0, index);
+ sConnectionDescription = sConnectionDescription.substring(index + 1);
+
+ // find port
+ index = sConnectionDescription.indexOf(':');
+ if(index > -1) {
+ _port = Integer.parseInt(sConnectionDescription.substring(0, index));
+ sConnectionDescription = sConnectionDescription.substring(index + 1);
+ }
+ else
+ _port = Integer.parseInt(sConnectionDescription);
+ }
+ else { // new style: is comma separated list
+ while(sConnectionDescription.length() > 0) {
+ index = sConnectionDescription.indexOf(',');
+
+ String word = null;
+
+ if(index >= 0) {
+ word = sConnectionDescription.substring(0, index).trim();
+ sConnectionDescription = sConnectionDescription.substring(index + 1).trim();
+ }
+ else {
+ word = sConnectionDescription.trim();
+ sConnectionDescription = "";
+ }
+
+ index = word.indexOf('=');
+ String left = word.substring(0, index).trim();
+ String right = word.substring(index + 1).trim();
+
+ if(left.equals("host")) {
+ _hostname = right;
+ }
+ else if(left.equals("port"))
+ _port = Integer.parseInt(right);
+ else if(left.equals("backlog"))
+ _backlog = Integer.parseInt(right);
+ else
+ System.err.println(getClass().getName() + ".accept - unknown attribute:" + left);
+ }
+ }
+
+ if (DEBUG) System.err.println("##### " + getClass().getName() + " - creating serverSocket:" + _port + " " + _backlog + " " + _hostname);
+
+ _serverSocket = new ServerSocket(_port, _backlog, _hostname.equals("0")? null: InetAddress.getByName(_hostname));
+ }
+ else if(!_description.equals(sConnectionDescription))
+ throw new com.sun.star.lang.IllegalArgumentException(getClass().getName() + ".accept");
+
+ Socket socket = _serverSocket.accept();
+ socket.setTcpNoDelay(true);
+
+ xConnection = new SocketConnection(_description + socket, socket);
+
+ if (DEBUG) System.err.println("##### " + getClass().getName() + " - accepted from " + socket);
+ }
+ catch(IOException ioException) {
+ throw new com.sun.star.connection.ConnectionSetupException(ioException.toString());
+ }
+
+ return xConnection;
+ }
+
+ /**
+ * Unblocks the <code>accept</code> call.
+ */
+ public void stopAccepting( ) throws com.sun.star.uno.RuntimeException {
+ try {
+ _serverSocket.close();
+ }
+ catch(Exception exception) {
+ throw new com.sun.star.uno.RuntimeException(exception.toString());
+ }
+
+ }
+}
+
diff --git a/jurt/com/sun/star/lib/connections/socket/socketConnector.java b/jurt/com/sun/star/lib/connections/socket/socketConnector.java
new file mode 100644
index 000000000000..b45183907db1
--- /dev/null
+++ b/jurt/com/sun/star/lib/connections/socket/socketConnector.java
@@ -0,0 +1,239 @@
+/*************************************************************************
+ *
+ * $RCSfile: socketConnector.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.connections.socket;
+
+
+import java.io.IOException;
+
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+
+import com.sun.star.comp.loader.FactoryHelper;
+
+import com.sun.star.connection.XConnection;
+import com.sun.star.connection.XConnector;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.registry.XRegistryKey;
+
+/**
+ * The socketConnector class is a component,
+ * that implements the <code>XConnector</code> Interface.
+ * <p>
+ * The socketConnector is a specialized component, which uses
+ * <code>sockets</code> for communication.
+ * The socketConnector is in general used by the Connector service.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.connections.XAcceptor
+ * @see com.sun.star.connections.XConnector
+ * @see com.sun.star.connections.XConnection
+ * @see com.sun.star.loader.JavaLoader
+ * @since UDK1.0
+ */
+public class socketConnector implements XConnector {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ /**
+ * The name of the service, the <code>JavaLoader</code> acceses this through reflection.
+ */
+ static public final String __serviceName = "com.sun.star.connection.socketConnector";
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be uses if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(socketConnector.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(socketConnector.class,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(socketConnector.class.getName(), __serviceName, regKey);
+ }
+
+
+
+
+ protected String _description;
+ protected String _hostname = "0";
+ protected int _port = 6001;
+
+ /**
+ * Connect through the described mechanism to a waiting server.
+ * <p>
+ * The description has the following format:
+ * [,attribute_name=attribute_value]
+ * Supported attributes at the moment are:
+ * <dl>
+ * <li> host - the name of interface (defaults to 0 == all interfaces
+ * <li> port - the port number (default to 6001)
+ * </dl>
+ * <p>
+ * @return an <code>XConnection</code> to the client
+ * @param description the description of the network interface
+ * @see com.sun.star.connections.XAcceptor
+ * @see com.sun.star.connections.XConnection
+ */
+ public synchronized XConnection connect(String description)
+ throws com.sun.star.connection.NoConnectException,
+ com.sun.star.connection.ConnectionSetupException,
+ com.sun.star.uno.RuntimeException
+ {
+ if(_description != null)
+ throw new com.sun.star.connection.ConnectionSetupException(getClass().getName() + ".connect - alread connected");
+
+ _description = description.trim();
+
+ // find hostname
+ int index = _description.indexOf(':');
+ if(index >= 0) { // old style
+ _hostname = _description.substring(0, index);
+ _description = _description.substring(index + 1);
+
+ // find port
+ index = _description.indexOf(':');
+ if(index > -1) {
+ _port = Integer.parseInt(_description.substring(0, index));
+ _description = _description.substring(index + 1);
+ }
+ else
+ _port = Integer.parseInt(_description);
+ }
+ else { // new style: is comma separated list
+ while(_description.length() > 0) {
+ index = _description.indexOf(',');
+
+ String word = null;
+
+ if(index >= 0) {
+ word = _description.substring(0, index).trim();
+ _description = _description.substring(index + 1).trim();
+ }
+ else {
+ word = _description.trim();
+ _description = "";
+ }
+
+ index = word.indexOf('=');
+ String left = word.substring(0, index).trim();
+ String right = word.substring(index + 1).trim();
+
+ if(left.equals("host"))
+ _hostname = right;
+ else if(left.equals("port"))
+ _port = Integer.parseInt(right);
+ else
+ System.err.println(getClass().getName() + ".connect - unknown attribute:" + left);
+ }
+ }
+
+ XConnection xConnection = null;
+
+ try {
+ InetAddress inetAddress = InetAddress.getByName(_hostname);
+ Socket socket = new Socket(inetAddress, _port);
+
+ xConnection = new SocketConnection(description + socket, socket);
+ }
+ catch(UnknownHostException unknownHostException) {
+ throw new com.sun.star.connection.ConnectionSetupException(unknownHostException.toString());
+ }
+ catch(IOException ioException) {
+ throw new com.sun.star.connection.NoConnectException(ioException.toString());
+ }
+
+ return xConnection;
+ }
+}
+
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java
new file mode 100644
index 000000000000..9907079bc2f9
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * $RCSfile: XConnectionInputStream_Adapter.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.bridges.java_remote;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import com.sun.star.connection.XConnection;
+
+
+class XConnectionInputStream_Adapter extends InputStream {
+ static private final boolean DEBUG = false;
+
+ protected XConnection _xConnection;
+ protected byte _bytes[][] = new byte[1][];
+
+ XConnectionInputStream_Adapter(XConnection xConnection) {
+ if(xConnection == null) throw new NullPointerException("the XConnection must not be null");
+
+ if(DEBUG) System.err.println("#### " + getClass().getName() + " - instantiated ");
+
+ _xConnection = xConnection;
+ }
+
+ public int read() throws IOException {
+
+ int len = 0;
+
+ try {
+ len = _xConnection.read(_bytes, 1);
+ }
+ catch(com.sun.star.io.IOException ioException) {
+ throw new IOException(ioException.toString());
+ }
+
+ if(DEBUG) System.err.println("#### " + getClass().getName() + " - one byte read:" + _bytes[0][0]);
+
+ return len == 0 ? -1 : _bytes[0][0] & 0xff;
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException {
+ byte bytes[][] = new byte[1][];
+
+ try {
+ len = _xConnection.read(bytes, len - off);
+ }
+ catch(com.sun.star.io.IOException ioException) {
+ throw new IOException(ioException.toString());
+ }
+
+ System.arraycopy(bytes[0], 0, b, off, len);
+
+ return len == 0 ? -1 : len;
+ }
+}
+
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java
new file mode 100644
index 000000000000..f65306ed76c1
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * $RCSfile: XConnectionOutputStream_Adapter.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.bridges.java_remote;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import com.sun.star.connection.XConnection;
+
+
+class XConnectionOutputStream_Adapter extends OutputStream {
+ static private final boolean DEBUG = false;
+
+ protected XConnection _xConnection;
+ protected byte _bytes[] = new byte[1];
+
+ XConnectionOutputStream_Adapter(XConnection xConnection) {
+ if(DEBUG) System.err.println("#### " + this.getClass() + " - instantiated ");
+
+ _xConnection = xConnection;
+ }
+
+ public void write(int b) throws IOException {
+ _bytes[0] = (byte)b;
+
+ try {
+ _xConnection.write(_bytes);
+ }
+ catch(com.sun.star.io.IOException ioException) {
+ throw new IOException(ioException.toString());
+ }
+
+ if(DEBUG) System.err.println("#### " + this.getClass() + " - one byte written:" + _bytes[0]);
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ byte bytes[] = new byte[len];
+
+ System.arraycopy(b, off, bytes, 0, len);
+
+ try {
+ _xConnection.write(bytes);
+ }
+ catch(com.sun.star.io.IOException ioException) {
+ throw new IOException(ioException.toString());
+ }
+ }
+
+ public void flush() throws IOException {
+ try {
+ _xConnection.flush();
+ }
+ catch(com.sun.star.io.IOException ioException) {
+ throw new IOException(ioException.toString());
+ }
+ }
+}
+
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java
new file mode 100644
index 000000000000..e6979b418c22
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java
@@ -0,0 +1,775 @@
+/*************************************************************************
+ *
+ * $RCSfile: java_remote_bridge.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.bridges.java_remote;
+
+
+import java.io.IOException;
+import java.io.DataOutputStream;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+
+import com.sun.star.bridge.XBridge;
+import com.sun.star.bridge.XInstanceProvider;
+
+import com.sun.star.comp.loader.FactoryHelper;
+
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.lib.sandbox.Disposable;
+
+import com.sun.star.lib.uno.environments.java.IRequester;
+import com.sun.star.lib.uno.environments.java.Proxy;
+
+import com.sun.star.lib.uno.environments.remote.IMessage;
+import com.sun.star.lib.uno.environments.remote.IProtocol;
+import com.sun.star.lib.uno.environments.remote.IReceiver;
+import com.sun.star.lib.uno.environments.remote.Job;
+import com.sun.star.lib.uno.environments.remote.ThreadID;
+import com.sun.star.lib.uno.environments.remote.ThreadPool;
+
+import com.sun.star.lib.util.IStableObject;
+import com.sun.star.lib.util.IStableListener;
+
+import com.sun.star.registry.XRegistryKey;
+
+import com.sun.star.uno.IBridge;
+import com.sun.star.uno.IEnvironment;
+import com.sun.star.uno.MappingException;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.IQueryInterface;
+
+/**
+ * This class implements a remote bridge. Therefor
+ * various interfaces are implemented.
+ * <p>
+ * The protocol to used is passed by name, the bridge
+ * then looks for it under <code>com.sun.star.lib.uno.protocols</code>.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.lib.uno.environments.remote.IProtocol
+ * @since UDK1.0
+ */
+public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBridge, Disposable, XComponent, IStableObject {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static private final boolean DEBUG = false;
+
+
+ /**
+ * The name of the service.
+ * <p>
+ * @deprecated as of UDK 1.0
+ */
+ static protected final String __serviceName = "com.sun.star.bridge.Bridge";
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @deprecated as of UDK 1.0
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be uses if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(java_remote_bridge.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(java_remote_bridge.class,
+ __serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @deprecated as of UDK 1.0
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(java_remote_bridge.class.getName(), __serviceName, regKey);
+ }
+
+
+
+ private class MessageDispatcher extends Thread {
+ boolean _quit = false;
+
+ MessageDispatcher() {
+ super("MessageDispatcher");
+ }
+
+ public void run() {
+ try {
+ do {
+ try {
+ // Use the protocol to read a job.
+ IMessage iMessage = _iProtocol.readMessage(_inputStream);
+
+ // Take care of special methods release and acquire
+ if(iMessage.getOperation() != null && iMessage.getOperation().equals("release")) {
+ _java_environment.revokeInterface(iMessage.getOid(), iMessage.getInterface());
+ remRefHolder(iMessage.getInterface(), iMessage.getOid());
+
+ }
+ else if(iMessage.getOperation() != null && iMessage.getOperation().equals("acquire")) {
+ String oid_o[] = new String[]{iMessage.getOid()};
+ _java_environment.registerInterface(null, oid_o, iMessage.getInterface());
+
+ addRefHolder(iMessage.getInterface(), iMessage.getOid());
+ }
+ else {
+ Object object = null;
+
+ if(iMessage.getOperation() != null) { // is it a request
+ object = _java_environment.getRegisteredInterface(iMessage.getOid(), iMessage.getInterface());
+
+ Object xexception = null;
+
+ try {
+ // if we don't have an object we ask the instance provider
+ if(object == null && _xInstanceProvider != null)
+ object = _xInstanceProvider.getInstance(iMessage.getOid());
+
+ if(object == null)
+ xexception = new com.sun.star.uno.RuntimeException("urp: no instance provider set and unknown object:" + iMessage.getOid());
+
+ }
+ catch(com.sun.star.container.NoSuchElementException noSuchElementException) {
+ xexception = noSuchElementException;
+ }
+ catch(com.sun.star.uno.RuntimeException runtimeException) {
+ xexception = runtimeException;
+ }
+
+ if(xexception != null) {
+ // an exception occurred while trying to get an instance.
+ // propagate it.
+ sendReply(true, iMessage.getThreadID(), xexception);
+ iMessage = null;
+ }
+ }
+
+ if(iMessage != null) {
+ // Queue the job for later execution.
+ // Give this bridge as the disposeId, needed in case of disposing this bridge
+ Job job = new Job(object, java_remote_bridge.this, iMessage);
+
+ ThreadPool.putJob(job, java_remote_bridge.this);
+ job = null;
+ }
+ }
+
+ iMessage = null;
+ // this is important to get rid of the job (especially while testing lifecycles)
+ }
+ catch(MappingException mappingException) {
+ System.err.println("MessageDispatcher - exception occurred:" + mappingException);
+ }
+ }
+ while(!_quit);
+ }
+ catch(EOFException eofException) {
+ if(!_quit) {
+ System.err.println(getClass() + " - reading message - exception occurred: \"" + eofException + "\"");
+ System.err.println(getClass() + " - giving up");
+ }
+ }
+ catch(Exception exception) {
+ System.err.println(getClass() + " - reading message - exception occurred: \"" + exception + "\"");
+ System.err.println(getClass() + " - giving up");
+ if(DEBUG);
+ exception.printStackTrace();
+ }
+
+ // dispose this bridge only within an error
+ if(!_quit && !java_remote_bridge.this._disposed)
+ java_remote_bridge.this.dispose();
+ }
+ }
+
+
+ protected XConnection _xConnection;
+ protected InputStream _inputStream; // wraps the connection to be an InputStream
+ protected OutputStream _outputStream; // wraps the connection to be an OutputStream
+
+ protected XInstanceProvider _xInstanceProvider;
+
+ protected IProtocol _iProtocol;
+ protected IEnvironment _java_environment;
+ protected MessageDispatcher _messageDispatcher;
+ protected int _life_count = 0; // determines if this bridge is alife, which is controlled by acquire and release calls
+ protected boolean _disposed = false;
+ protected boolean _disposing = false;
+
+ protected Hashtable _refHolders; // holds descriptions for out mapped objects, so we can release
+ // the outmapped objects when the bridge is to be disposed
+
+ protected Vector _listeners;
+ protected Vector _stableListeners;
+
+ /**
+ * This method is for testing only.
+ */
+ int getLifeCount() {
+ return _life_count;
+ }
+
+ /**
+ * This method is for testing only.
+ */
+ IProtocol getProtocol() {
+ return _iProtocol;
+ }
+
+
+ // use a static class, it is smaller
+ private static class RefHolder {
+ Class _zInterface;
+ String _oid;
+ int _mapCount;
+ }
+
+
+ void addRefHolder(Class zInterface, String oid) {
+ acquire();
+
+ RefHolder refHolder = (RefHolder)_refHolders.get(oid + zInterface);
+
+ if(refHolder == null) {
+ refHolder = new RefHolder();
+ refHolder._zInterface = zInterface;
+ refHolder._oid = oid;
+
+ _refHolders.put(oid + zInterface, refHolder);
+ }
+
+ ++ refHolder._mapCount;
+ }
+
+ void remRefHolder(Class zInterface, String oid) {
+ RefHolder refHolder = (RefHolder)_refHolders.get(oid + zInterface);
+
+ if(refHolder != null) {
+ -- refHolder._mapCount;
+ if(refHolder._mapCount <= 0)
+ _refHolders.remove(oid + zInterface);
+
+ release();
+ }
+ else
+ System.err.println(getClass().getName() + ".remRefHolder - warning - unknown oid:" + oid + " " + zInterface);
+ }
+
+
+ void freeHolders() {
+ if(DEBUG) System.err.println("#### " + getClass().getName() + ".freeHolders:" + _refHolders.size());
+
+ Enumeration elements = _refHolders.elements();
+ while(elements.hasMoreElements()) {
+ RefHolder refHolder = (RefHolder)elements.nextElement();
+
+ while(refHolder._mapCount > 0) {
+ -- refHolder._mapCount;
+
+ _java_environment.revokeInterface(refHolder._oid, refHolder._zInterface);
+ release();
+ }
+ }
+ }
+
+ /**
+ * Constructs a new bridge.
+ * <p>
+ * This method is not part of the provided <code>api</code>
+ * and should only be used by the UNO runtime.
+ * <p>
+ * @param java_remote the source environment
+ * @param remote_environment the remote environement, which is not neede by this bridge
+ * @param args the custom parameters: arg[0] == protocol_name, arg[1] == xConnection, arg[2] == xInstanceProvider
+ */
+ public java_remote_bridge(IEnvironment java_environment, IEnvironment remote_environment, Object args[]) throws Exception {
+ if(DEBUG) System.err.println("#### " + getClass().getName() + " - instantiated:" + args);
+
+ String protocolDescription = (String)args[0];
+
+ Class protocol_class = Class.forName("com.sun.star.lib.uno.protocols." + protocolDescription + "." + protocolDescription);
+ Constructor protocol_constructor = protocol_class.getConstructor(new Class[] {IBridge.class});
+
+ _iProtocol = (IProtocol)protocol_constructor.newInstance(new Object[]{this});
+ _xConnection = (XConnection)args[1];
+ _xInstanceProvider = (XInstanceProvider)args[2];
+ _inputStream = new XConnectionInputStream_Adapter(_xConnection);
+ _outputStream = new XConnectionOutputStream_Adapter(_xConnection);
+
+ _java_environment = java_environment;
+
+
+ // be sure that all neccessary members are set
+ if(_java_environment == null
+ || _xConnection == null
+ || _iProtocol == null
+ || _inputStream == null
+ || _outputStream == null)
+ throw new com.sun.star.lang.IllegalArgumentException(getClass().getName());
+
+ _refHolders = new Hashtable();
+ _listeners = new Vector();
+ _stableListeners = new Vector();
+
+ // create the message dispatcher and start it
+ _messageDispatcher = new MessageDispatcher();
+ _messageDispatcher.start();
+ }
+
+
+ private void notifyListeners() {
+ EventObject eventObject = new EventObject(this);
+
+ Enumeration elements = _listeners.elements();
+ while(elements.hasMoreElements()) {
+ XEventListener xEventListener = (XEventListener)elements.nextElement();
+
+ try {
+ xEventListener.disposing(eventObject);
+ }
+ catch(com.sun.star.uno.RuntimeException runtimeException) {
+ // we are here not interested in any exceptions
+ }
+ }
+ }
+
+ private void notifyStableListeners() {
+ EventObject eventObject = new EventObject(this);
+
+ Enumeration elements = _listeners.elements();
+ while(elements.hasMoreElements()) {
+ IStableListener iStableListener = (IStableListener)elements.nextElement();
+
+ iStableListener.deStable();
+ }
+ }
+
+ /**
+ * Constructs a new bridge.
+ * <p>
+ * This method is not part of the provided <code>api</code>
+ * and should only be used by the UNO runtime.
+ * <p>
+ * @deprecated as of UDK 1.0
+ * <p>
+ * @param args the custom parameters: arg[0] == protocol_name, arg[1] == xConnection, arg[2] == xInstanceProvider
+ */
+ public java_remote_bridge(Object args[]) throws Exception {
+ this(UnoRuntime.getEnvironment("java", null), UnoRuntime.getEnvironment("remote", null), args);
+ }
+
+ /**
+ * Maps an object from the source environment to the destination environment.
+ * <p>
+ * @return the object in the destination environment
+ * @param object the object to map
+ * @param zInterface the interface under which is to be mapped
+ * @see com.sun.star.uno.IBridge#mapInterfaceTo
+ */
+ public Object mapInterfaceTo(Object object, Class zInterface) throws MappingException {
+ if(_disposed) throw new RuntimeException("java_remote_bridge(" + this + ").mapInterfaceTo - is disposed");
+
+ String oid[] = new String[1];
+
+ // if object is a string, than it is already mapped as a virtuell proxy
+ if(object instanceof String)
+ oid[0] = (String)object;
+ else {
+ Object xobject = _java_environment.registerInterface(object, oid, zInterface);
+ if(!(xobject instanceof com.sun.star.lib.uno.environments.java.java_environment.HolderProxy))
+ addRefHolder(zInterface, oid[0]);
+ }
+ if(DEBUG) System.err.println("##### " + getClass() + " - mapInterfaceTo:" + object + " interface:" + zInterface + " " + oid[0]);
+
+ return oid[0];
+ }
+
+ /**
+ * Maps an object from destination environment to the source environment.
+ * <p>
+ * @return the object in the source environment
+ * @param object the object to map
+ * @param zInterface the interface under which is to be mapped
+ * @see com.sun.star.uno.IBridge#mapInterfaceFrom
+ */
+ public Object mapInterfaceFrom(Object oId, Class zInterface) throws MappingException {
+ if(_disposed) throw new RuntimeException("java_remote_bridge(" + this + ").mapInterfaceFrom - is disposed");
+
+ String oid[] = new String[]{(String)oId};
+
+ Object proxy = Proxy.create(this, oid[0], zInterface, false); // this proxy sends a release, when finalized
+ Object object = _java_environment.registerInterface(proxy, oid, zInterface);
+ acquire();
+
+ if(DEBUG) System.err.println("##### " + getClass() + " - mapInterfaceFrom:" + oId + " interface:" + zInterface + " " + object + " " + proxy);
+
+ return object;
+ }
+
+ /**
+ * Gives the source environment.
+ * <p>
+ * @return the source environment of this bridge
+ * @see com.sun.star.uno.IBridge#getSourceEnvironment
+ */
+ public IEnvironment getSourceEnvironment() {
+ return _java_environment;
+ }
+
+ /**
+ * Gives the destination environment.
+ * <p>
+ * @return the destination environment of this bridge
+ * @see com.sun.star.uno.IBridge#getTargetEnvironment
+ */
+ public IEnvironment getTargetEnvironment() {
+ return null;
+ }
+
+ /**
+ * Increases the life count.
+ * <p>
+ * @see com.sun.star.uno.IBridge#acquire
+ */
+ public void acquire() {
+ ++ _life_count;
+ }
+
+ /**
+ * Decreases the life count.
+ * If the life count drops to zero, the bridge disposes itself.
+ * <p>
+ * @see com.sun.star.uno.IBridge#release
+ */
+ public void release() {
+ -- _life_count;
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".release:" + _life_count);
+
+ try {
+ if(_life_count <= 0)
+ dispose();
+ }
+ catch(Exception exception) {
+ System.err.println("######### " + getClass().getName() + ".release - exception:" + exception);
+ }
+ }
+
+ /**
+ * Resets the bridge, sends an procotol "closeConnection"
+ * and ignores the next incoming procotol "closeConnection".
+ * E.g. this is useful for inheriting connections on the server
+ * side from one process to another.
+ * Resets the proxy and stub refs.
+ * <p>
+ * @see com.sun.star.uno.IBridge#reset
+ */
+ public synchronized void reset() throws IOException {
+ // we need to release the outmapped objects here
+ freeHolders();
+
+ // unfortunately we can not set the _life_count to zero
+ // because there can be active proxies
+// _life_count = 0;
+
+ synchronized(_xConnection) {
+ _iProtocol.ignore_next_closeConnection();
+ _iProtocol.send_closeConnection(_outputStream);
+ try {
+ _xConnection.flush();
+ }
+ catch(com.sun.star.io.IOException ioException) {
+ throw new IOException(ioException.toString());
+ }
+ }
+ }
+
+ /**
+ * Disposes the bridge. Sends belonging threads an interrupt exception.
+ * Releases mapped objects.
+ * <p>
+ * @see com.sun.star.uno.IBridge#dispose
+ */
+ public synchronized void dispose() {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".dispose - life count:" + _life_count);
+
+ if(_disposed) throw new RuntimeException("java_remote_bridge(" + this + ").dispose - is disposed");
+
+ if(!_disposing) {
+ _disposing = true;
+
+ notifyListeners();
+ notifyStableListeners();
+
+ try {
+ // stop the dispatcher thread
+ _messageDispatcher._quit = true;
+
+ // close the connection
+ _xConnection.close();
+
+ // interrupt the dispatcher thread, if this thread is not the dispatcher
+ if(Thread.currentThread() != _messageDispatcher && _messageDispatcher.isAlive()) {
+ _messageDispatcher.join(1000); // wait for thread to die
+
+ if(_messageDispatcher.isAlive()) { // has not died yet, interrupt it
+ _messageDispatcher.interrupt();
+ _messageDispatcher.join();
+ }
+ }
+
+ // interrupt all jobs queued by this bridge
+ ThreadPool.dispose(this);
+
+ // release all outmapped objects
+ freeHolders();
+
+ // see if life count is zero, if not give a warning
+ if(_life_count != 0)
+ System.err.println(getClass().getName() + ".dispose - life count (proxies left):" + _life_count);
+
+
+ if(DEBUG)
+ _java_environment.list();
+
+
+ // clear members
+ _xConnection = null;
+ _java_environment = null;
+ _messageDispatcher = null;
+
+ _disposed = true;
+ }
+ catch(InterruptedException interruptedException) {
+ System.err.println(getClass().getName() + ".dispose - InterruptedException:" + interruptedException);
+ }
+ catch(com.sun.star.io.IOException ioException) {
+ System.err.println(getClass().getName() + ".dispose - IOException:" + ioException);
+ }
+ }
+ }
+
+ /**
+ * Asks to map a remote object of name sInstanceName.
+ * <p>
+ * @param sInstanceName the name of the instance
+ * @see com.sun.star.bridge.XBridge#getInstance
+ */
+ public Object getInstance(String sInstanceName) throws com.sun.star.uno.RuntimeException {
+ Object object = null;
+
+ try {
+ object = sendRequest(sInstanceName,
+ new Type(XInterface.class),
+ "queryInterface",
+ new Object[]{new Type(XInterface.class)},
+ null);
+ }
+ catch(Exception exception) {
+ throw new com.sun.star.uno.RuntimeException(exception.getMessage());
+ }
+
+ return object;
+ }
+
+ /**
+ * Gives the name of this bridge
+ * <p>
+ * @return the name of this bridge
+ * @see com.sun.star.bridge.XBridge#getName
+ */
+ public String getName() throws com.sun.star.uno.RuntimeException {
+ return "remote";
+ }
+
+ /**
+ * Gives a description of the connection type and protocol used
+ * <p>
+ * @return connection type and protocol
+ * @see com.sun.star.bridge.XBridge#getDescription
+ */
+ public String getDescription() throws com.sun.star.uno.RuntimeException {
+ return _iProtocol.getName() + "," + _xConnection.getDescription();
+ }
+
+
+ public void sendReply(boolean exception, ThreadID threadId, Object result) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".sendReply:" + exception + " " + result);
+
+ if(_disposed) throw new RuntimeException("java_remote_bridge(" + this + ").sendReply - is disposed");
+
+ synchronized(_xConnection) {
+ _iProtocol.writeReply(exception, threadId, result);
+ _iProtocol.flush(new DataOutputStream(_outputStream));
+
+ _xConnection.flush();
+ }
+ }
+
+ public Object sendRequest(Object object, Type type, String operation, Object params[], Boolean synchron[]) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".sendRequest:" + object + " " + type +" " + operation + " " + synchron);
+ Object result = null;
+
+ if(synchron == null)
+ synchron = new Boolean[1];
+
+ try {
+ if(_disposed) throw new RuntimeException("java_remote_bridge(" + this + ").sendRequest - is disposed");
+
+ if(operation.equals("acquire")) acquire(); // keep this bridge alife
+
+ // is this what we realy want to do, is the writing to the stream realy protected? Not that
+ // an other thread flushes the output and an reply arrives before we have added the thread queue!!!
+ synchronized(_xConnection) {
+ _iProtocol.writeRequest((String)object, type, operation, ThreadPool.getThreadId(), params, synchron);
+
+ if(synchron[0].booleanValue()) // prepare a queue for this thread in the threadpool
+ ThreadPool.addThread(this);
+
+ _iProtocol.flush(new DataOutputStream(_outputStream));
+ _outputStream.flush();
+ }
+ }
+ catch(Exception exception) {
+ if(DEBUG) ;{
+ System.err.println("##### " + getClass().getName() + ".sendRequest - exception occurred:" + exception);
+ exception.printStackTrace();
+ }
+ ThreadPool.removeThread();
+
+ throw exception;
+ }
+
+ _xConnection.flush();
+
+ if(synchron[0].booleanValue()) {
+ result = ThreadPool.enter();
+ }
+
+ if(operation.equals("release"))
+ release(); // kill this bridge, if this was the last proxy
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".sendRequest left:" + result);
+
+ return result;
+ }
+
+
+ // Methods XComponent
+ public void addEventListener(XEventListener xEventListener) throws com.sun.star.uno.RuntimeException {
+ _listeners.addElement(xEventListener);
+ }
+
+ public void removeEventListener(XEventListener xEventListener) throws com.sun.star.uno.RuntimeException {
+ _listeners.removeElement(xEventListener);
+ }
+
+
+ public void addStableListener(IStableListener stableListener) {
+ _stableListeners.addElement(stableListener);
+ }
+
+ public void removeStableListener(IStableListener stableListener) {
+ _stableListeners.removeElement(stableListener);
+ }
+}
+
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/makefile.mk b/jurt/com/sun/star/lib/uno/bridges/java_remote/makefile.mk
new file mode 100644
index 000000000000..64385a946fbf
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/makefile.mk
@@ -0,0 +1,89 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/lib$/uno$/bridges$/java_remote
+TARGET = com_sun_star_lib_uno_bridges_java_remote
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+GENJAVAFILES= \
+ $(MISC)$/java$/com$/sun$/star$/bridge$/XBridge.java \
+ $(MISC)$/java$/com$/sun$/star$/connection$/XConnection.java \
+ $(MISC)$/java$/com$/sun$/star$/lang/XComponent.java \
+ $(MISC)$/java$/com$/sun$/star$/io$/IOException.java \
+ $(MISC)$/java$/com$/sun$/star$/uno$/XInterface.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/XConnectionInputStream_Adapter.class \
+ $(CLASSDIR)$/$(PACKAGE)$/XConnectionOutputStream_Adapter.class \
+ $(CLASSDIR)$/$(PACKAGE)$/java_remote_bridge.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/com/sun/star/lib/uno/environments/java/java_environment.java b/jurt/com/sun/star/lib/uno/environments/java/java_environment.java
new file mode 100644
index 000000000000..85d045961caa
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/java/java_environment.java
@@ -0,0 +1,410 @@
+/*************************************************************************
+ *
+ * $RCSfile: java_environment.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.java;
+
+
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+
+import com.sun.star.lib.sandbox.Disposable;
+
+import com.sun.star.lib.sandbox.generic.Dispatcher;
+import com.sun.star.lib.sandbox.generic.DispatcherAdapterBase;
+import com.sun.star.lib.sandbox.generic.DispatcherAdapterFactory;
+
+import com.sun.star.uno.IEnvironment;
+import com.sun.star.uno.IQueryInterface;
+import com.sun.star.uno.MappingException;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**
+ * The java_environment is the environment where objects and
+ * interfaces are registered, which are mapped out of java or
+ * into java. The java_environment implements the <code>IEnvironment</code>
+ * interface defined in the uno runtime.
+ * <p>
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.uno.UnoRuntime
+ * @see com.sun.star.uno.IEnvironment
+ * @since UDK1.0
+ */
+public class java_environment implements IEnvironment, Disposable {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ /*
+ ** This is the holder proxy, which one gets while trying to get a registered object
+ */
+ static public class HolderProxy extends DispatcherAdapterBase implements Dispatcher, XInterface, IQueryInterface {
+ static private Hashtable __methodss = new Hashtable();
+
+ /**
+ * Gets the methods of a class as a hashtable.
+ * Uses reflection for first time and stores the methods
+ * array in hashtable for later use.
+ * <p>
+ * This method does not belong to the provided <code>api</code>
+ * <p>
+ * @return the methods
+ * @param zClass the class
+ * @see java.lang.Class#getMethods
+ */
+ static public Hashtable __getMethodsAsTable(Class zClass) {
+ Hashtable methods_tab = (Hashtable)__methodss.get(zClass);
+
+ if(methods_tab == null) {
+ methods_tab = new Hashtable();
+
+ Method methods[] = zClass.getMethods();
+
+ for(int i = 0; i < methods.length; ++ i) {
+ methods_tab.put(methods[i].getName(), methods[i]);
+ }
+
+ __methodss.put(zClass, methods_tab);
+ }
+
+ return methods_tab;
+ }
+
+ Holder _holder;
+ Class _zInterface;
+
+ Hashtable _methods;
+
+ void setHolder(Holder holder) {
+ _holder = holder;
+ }
+
+ public Object invoke(Object object, String name, Object params[]) throws Exception {
+ Method method = (Method)_methods.get(name);
+
+ Object result = null;
+
+ if(method == null) {
+ System.err.println(getClass().getName() + ".invoke - method not found:" + object + " " + name + " " + params);
+ }
+ else {
+ try {
+ result = method.invoke(object, params);
+ }
+ // don't hide exceptions
+ catch(InvocationTargetException invocationTargetException) {
+ throw (Exception)invocationTargetException.getTargetException();
+ }
+ }
+
+ return result;
+ }
+
+ public HolderProxy() {
+ super();
+ }
+
+ public void setInterface(Class zInterface) {
+ _zInterface = zInterface;
+ _methods = __getMethodsAsTable(object.getClass());
+ }
+
+ public Class getInterface() {
+ return _zInterface;
+ }
+
+ // IQueryInterface - delegate calls through this proxy
+ public Object queryInterface(Class zInterface) throws MappingException {
+ return UnoRuntime.queryInterface(zInterface, object);
+ }
+
+ public boolean isSame(Object object) throws MappingException {
+ return UnoRuntime.areSame(this.object, object);
+ }
+
+ public String getOid() {
+ return UnoRuntime.generateOid(object);
+ }
+
+ public void finalize() {
+ if(DEBUG) System.err.println("###################### Proxy Proxy is dying");
+ _holder.decRefCount();
+ }
+ }
+
+ /*
+ ** This is the holder class, whichs instances are put into the hashtable
+ */
+ class Holder {
+ int _refCount;
+ String _oId;
+ Object _object;
+
+ Holder(String oId, Object object) {
+ _oId = oId;
+ _object = object;
+ }
+
+ void incRefCount() {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".incRefCount:" + _refCount);
+
+ ++ _refCount;
+ }
+
+ void decRefCount() {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".decRefCount:" + _refCount);
+
+ -- _refCount;
+
+ if(_refCount == 0)
+ _objects.remove(_oId);
+ }
+
+ Object xxgetObject(Class zInterface) {
+ Object result = _object;
+
+ if(_object instanceof Proxy) {
+ if(DEBUG) System.err.println("###################### creating new Proxy Proxy");
+ Class holderProxyClass = DispatcherAdapterFactory.createDispatcherAdapter(zInterface, HolderProxy.class.getName().replace('.', '/'));
+
+ try {
+ HolderProxy holderProxy = (HolderProxy)holderProxyClass.newInstance();
+ holderProxy.setObject(holderProxy, _object);
+ holderProxy.setHolder(this);
+ holderProxy.setInterface(zInterface);
+
+ result = holderProxy;
+ }
+ catch(Exception exception) {
+ System.err.println("##### " + getClass().getName() + ".xxgetObject - exception occurred:" + exception);
+ exception.printStackTrace();
+
+ result = null;
+ }
+ }
+
+ return result;
+ }
+
+ public String toString() {
+ return "holder:" + _refCount + " " + _oId + " " + _object;
+ }
+ }
+
+ protected Hashtable _objects;
+ protected String _name;
+ // free context pointer, that can be used for specific classes of environments,
+ protected Object _context;
+
+ public java_environment(Object context) {
+ _name = "java";
+ _context = context;
+ _objects = new Hashtable();
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + " - instantiated ");
+ }
+
+ /**
+ * the context
+ */
+ public Object getContext() {
+ return _context;
+ }
+
+ /**
+ * a name for this environment
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * Tests if two environments are equal.
+ *<BR>
+ * @param environment one environment
+ */
+ public boolean equals(Object object) {
+ return false;
+ }
+
+ /**
+ * You register internal and external interfaces via this method. Internal interfaces are
+ * proxies that are used in an environment. External interfaces are interfaces that are
+ * exported to another environment, thus providing an object identifier for this task.
+ * This can be called an external reference.
+ * Interfaces are held weakly at an environment; they demand a final revokeInterface()
+ * call for each interface that has been registered.
+ * <p>
+ * @return a proxy to registered interface if necessare, otherwise the registered object itself
+ * @param object the interface to register
+ * @param oId[] inout parameter for the corresponding object id
+ * @param zInterface the type description of the given interface
+ * @see com.sun.star.uno.IEnvironment#registerInterface
+ */
+ public Object registerInterface(Object object, String oId[], Class zInterface) {
+ if(oId[0] == null)
+ oId[0] = UnoRuntime.generateOid(object);
+
+ String keyName = oId[0] + zInterface;
+
+ // get the holder
+ Holder holder = (Holder)_objects.get(keyName);
+
+ if(DEBUG)
+ System.err.println("##### " + getClass().getName() + ".registerInterface:" + object + " " + oId[0] + " " + zInterface);
+
+ if(holder == null) {
+ holder = new Holder(keyName, object);
+
+ _objects.put(keyName, holder);
+ }
+
+ // get the holder again, so we dont have to guard this section and are thread safe
+ holder = (Holder)_objects.get(keyName);
+ holder.incRefCount();
+
+ return holder.xxgetObject(zInterface);
+ }
+
+ /**
+ * You have to revoke ANY interface that has been registered via this method.
+ * <p>
+ * @param oId object id of interface to be revoked
+ * @param zInterface the type description of the interface
+ * @see com.sun.star.uno.IEnvironment#revokeInterface
+ */
+ public void revokeInterface(String oId, Class zInterface) {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".revokeInterface:" + oId + " " + zInterface);
+ Holder holder = (Holder)_objects.get(oId + zInterface);
+ if(holder != null)
+ holder.decRefCount();
+ else
+ System.err.println("java_environment.revokeInterface - unknown oid:" + oId + " " + zInterface);
+ }
+
+ /**
+ * Retrieves an interface identified by its object id and type from this environment.
+ * <p>
+ * @param oId object id of interface to be retrieved
+ * @param zInterface the type description of the interface to be retrieved
+ * @see com.sun.star.uno.IEnvironment#getRegisteredInterface
+ */
+ public Object getRegisteredInterface(String oId, Class zInterface) {
+ Object result = null;
+
+ Holder holder = (Holder)_objects.get(oId + zInterface);
+
+ if(holder != null) {
+ result = holder.xxgetObject(zInterface);
+ }
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".getRegisteredInterface:>" + oId + "< " + zInterface +" " + result);
+
+ return result;
+ }
+
+ /**
+ * Retrieves the object identifier for a registered interface from this environment.
+ * <p>
+ * @param object a registered interface
+ * @see com.sun.star.uno.IEnvironment#getRegisteredObjectIdentifier
+ */
+ public String getRegisteredObjectIdentifier(Object object) {
+ return UnoRuntime.generateOid(object);
+ }
+
+ /**
+ * List the registered interfaces.
+ * <p>
+ * @see com.sun.star.uno.IEnvironment#list
+ */
+ public void list() {
+ System.err.println("##### " + getClass().getName() + ".list(" + getName() + " " + getContext() + "):");
+
+ Enumeration elements = _objects.elements();
+ while(elements.hasMoreElements()) {
+ System.err.println("#### key:" + elements.nextElement());
+ }
+ }
+
+ /**
+ * Dispose this environment
+ * <p>
+ * @see com.sun.star.uno.IEnvironment#dispose
+ */
+ public void dispose() {
+ if(_objects.size() > 0)
+ list();
+
+ _objects = new Hashtable();
+ }
+
+}
+
diff --git a/jurt/com/sun/star/lib/uno/environments/java/makefile.mk b/jurt/com/sun/star/lib/uno/environments/java/makefile.mk
new file mode 100644
index 000000000000..106a12c45fd0
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/java/makefile.mk
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/lib$/uno$/environments$/java
+TARGET = com_sun_star_lib_uno_environments_java
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/IRequester.class \
+ $(CLASSDIR)$/$(PACKAGE)$/java_environment.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Proxy.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/IProtocol.java b/jurt/com/sun/star/lib/uno/environments/remote/IProtocol.java
new file mode 100644
index 000000000000..181e9f42b2d1
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/remote/IProtocol.java
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * $RCSfile: IProtocol.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.remote;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import com.sun.star.uno.IBridge;
+
+
+
+import com.sun.star.uno.Type;
+
+
+/**
+ * This interface provides an abstraction for protocols
+ * for remote bridges.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.lib.uno.environments.remote.IMessage
+ * @see com.sun.star.lib.uno.environments.remote.Job
+ * @since UDK1.0
+ */
+public interface IProtocol {
+ /**
+ * Gets the name of the protocol.
+ * <p>
+ * @result the name of the protocol
+ */
+ String getName();
+
+ /**
+ * Tells the protocol to ignore the next <code>closeConnection</code>
+ * meta request.
+ * <p>
+ */
+ void ignore_next_closeConnection();
+
+ /**
+ * Tells the protocol to send a <code>closeConnection</code>
+ * meta request.
+ * <p>
+ * @param outputStream the output stream
+ */
+ void send_closeConnection(OutputStream outputStream) throws IOException;
+
+
+ /**
+ * Reads a job from the given stream.
+ * <p>
+ * @return thread read job.
+ * @see com.sun.star.lib.uno.environments.remote.Job
+ */
+ IMessage readMessage(InputStream inputStream) throws Exception;
+
+
+ public void writeRequest(String oid, Type zInterface, String operation, ThreadID threadId, Object params[], Boolean synchron[]) throws Exception;
+
+ public void writeReply(boolean exception, ThreadID threadId, Object result) throws Exception;
+
+ public void flush(java.io.DataOutput dataOutput) throws Exception;
+
+
+ /**
+ * for testing and debugging
+ */
+
+ int getRequestsSendCount();
+
+ int getRequestsReceivedCount();
+
+ IMarshal createMarshal();
+ IUnmarshal createUnmarshal(byte bytes[]);
+}
+
+
+
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/IReceiver.java b/jurt/com/sun/star/lib/uno/environments/remote/IReceiver.java
new file mode 100644
index 000000000000..f9feb33d9718
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/remote/IReceiver.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * $RCSfile: IReceiver.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.remote;
+
+
+import java.io.IOException;
+
+import com.sun.star.lib.uno.environments.java.IRequester;
+
+/**
+ * This interface is an abstraction for giving back
+ * a reply for a request.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.uno.IQueryInterface
+ * @since UDK1.0
+ */
+public interface IReceiver {
+ /**
+ * Sends back a reply for the passed request id.
+ * <p>
+ * @param threadId the thread id of the request
+ * @param requestId the request id
+ * @param status the status of the request
+ * @param result the result of the request
+ * @param resultClass the type of the result
+ * @param params the out and in/out parameters passed with the request
+ * @param signature the types of the out and in/out parameters
+ */
+ public void sendReply(boolean exception, ThreadID threadId, Object result) throws Exception;
+}
+
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java b/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java
new file mode 100644
index 000000000000..763b68bf79da
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * $RCSfile: IThreadPool.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.remote;
+
+/**
+ * This interface is an abstraction of the various
+ * threadpool implementations.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Joerg Budischewski
+ * @see com.sun.star.lib.uno.environments.remote.ThreadPool
+ * @since UDK1.0
+ */
+public interface IThreadPool {
+ /**
+ * Retrieves the global threadId for the current thread.
+ * <p>
+ * @return the thread id
+ */
+ public ThreadID getThreadId();
+
+
+ /**
+ * Adds a jobQueue for the current thread to the threadpool.
+ * Requests are now put into this queue.
+ * <p>
+ * @param disposeId the dipose id with which the thread can be interrupted while staying in the queue
+ * @see #enter
+ */
+ public void addThread(Object disposeId) throws InterruptedException;
+
+ /**
+ * Removes the jobQueue for the current thread.
+ */
+ public void removeThread() throws InterruptedException;
+
+ /**
+ * Queues a job into the jobQueue of the thread belonging to the jobs threadId.
+ * <p>
+ * @param job the job
+ * @param disposeId the dispose id
+ */
+ public void putJob(Job job, Object disposeId) throws InterruptedException;
+
+ /**
+ * Lets the current thread enter the ThreadPool.
+ * The thread then dispatches all jobs and leaves
+ * the ThreadPool when it gets a reply job.
+ * <p>
+ */
+ public Object enter() throws java.lang.Exception;
+
+ /**
+ * Interrupts all threads which have associated the dispose id.
+ * <p>
+ * @param disposeId the dispose id
+ */
+ public void dispose(Object disposeId);
+
+
+ public void stopDispose(Object disposeId);
+}
+
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java b/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java
new file mode 100644
index 000000000000..f24d5b663b7e
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java
@@ -0,0 +1,348 @@
+/*************************************************************************
+ *
+ * $RCSfile: JavaThreadPool.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.remote;
+
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * This class implements a java thread pool.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.uno.UnoRuntime
+ * @see com.sun.star.lib.uno.environments.remote.ThreadPool
+ * @see com.sun.star.lib.uno.environments.remote.IThreadPool
+ * @see com.sun.star.lib.uno.environments.remote.Job
+ * @see com.sun.star.lib.uno.environments.remote.JobQueue
+ * @since UDK1.0
+ */
+public class JavaThreadPool implements IThreadPool {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ public static final boolean DEBUG = false;
+
+
+ protected Hashtable _jobQueues = new Hashtable();
+ protected Hashtable _disposeIds = new Hashtable();
+ protected boolean _disposed = false;
+
+ /**
+ * For debugging, lists the jobqueues
+ */
+ synchronized void list() {
+ Enumeration elements = _jobQueues.keys();
+
+ System.err.println("##### ThreadPool.list:");
+ while(elements.hasMoreElements()) {
+ System.err.println(" - " + elements.nextElement());
+ }
+ }
+
+ /**
+ * Gets the <code>ThreadID</code> of the given thread.
+ * <p>
+ * @return the thread id
+ * @param thread the thread
+ * @see com.sun.star.lib.uno.environments.remote.ThreadID
+ */
+ static public ThreadID getThreadId(Thread thread) {
+ ThreadID threadId = null;
+
+ if(thread instanceof JobQueue.JobDispatcher)
+ threadId = ((JobQueue.JobDispatcher)thread).getThreadId();
+ else
+ threadId = new ThreadID(UnoRuntime.generateOid(thread).getBytes());
+
+ if(DEBUG) System.err.println("##### ThreadPool.getThreadId:" + threadId);
+
+ return threadId;
+ }
+
+ /**
+ * Gets the <code>ThreadID</code> of this thread.
+ * Implements the method of <code>IThreadPool</code>
+ * <p>
+ * @return the thread id
+ * @see com.sun.star.lib.uno.environments.remote.IThreadPool#getThreadId
+ */
+ public ThreadID getThreadId() {
+ if(_disposed) throw new RuntimeException("ThreadPool.getThreadId - is disposed");
+
+ return getThreadId(Thread.currentThread());
+ }
+
+ /**
+ * Adds a <code>JobQueue</code> for the given thread under the given <code>ThreadID</code>
+ * with the given disposeId.
+ * <p>
+ * @param createWorkerThread create a JobQueue with or without worker thread
+ * @param threadId the thread id to use
+ * @param disposeId the dispose id
+ */
+ public void addThread(boolean createWorkerThread, ThreadID threadId, Object disposeId) throws InterruptedException {
+ if(_disposed) throw new RuntimeException("ThreadPool.addThread(" + threadId + ") - is disposed");
+
+ if(DEBUG) System.err.println("##### ThreadPool.addThread:" + threadId);
+
+ JobQueue jobQueue = (JobQueue)_jobQueues.get(threadId);
+ if(jobQueue == null) { // see, if we already have a queue for the given threadId
+ synchronized(_jobQueues) {
+ jobQueue = (JobQueue)_jobQueues.get(threadId);
+ if(jobQueue == null) {
+ jobQueue = new JobQueue(threadId, createWorkerThread);
+ _jobQueues.put(threadId, jobQueue);
+ if(disposeId != null)
+ _disposeIds.put(threadId, disposeId);
+ _jobQueues.notifyAll();
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds a jobQueue for the current thread to the threadpool.
+ * Requests are now put into this queue.
+ * Implements the method of <code>IThreadPool</code>
+ * <p>
+ * @param disposeId the dipose id with which the thread can be interrupted while staying in the queue
+ * @see #enter
+ * @see com.sun.star.lib.uno.environments.remote.IThreadPool#addThread
+ */
+ public void addThread(Object disposeId) throws InterruptedException {
+ if(_disposed) throw new RuntimeException("ThreadPool.addThread - is disposed");
+
+ addThread(false, getThreadId(Thread.currentThread()), disposeId);
+ }
+
+ /**
+ * Gives the <code>JobQueue</code> for the given threadId.
+ * <p>
+ * @return the job queue
+ * @param threadId the thread id
+ * @see com.sun.star.lib.uno.environments.remote.ThreadID
+ * @see com.sun.star.lib.uno.environments.remote.JobQueue
+ */
+ public JobQueue getJobQueue(ThreadID threadId) {
+ return (JobQueue)_jobQueues.get(threadId);
+ }
+
+ /**
+ * Removes the <code>JobQueue</code> for the given threadId.
+ * <p>
+ * @param threadId the thread id
+ * @see com.sun.star.lib.uno.environments.remote.ThreadID
+ * @see com.sun.star.lib.uno.environments.remote.JobQueue
+ */
+ public void removeThread(ThreadID threadId) {
+ if(_disposed) throw new RuntimeException("ThreadPool.removeThread - is disposed");
+
+ if(DEBUG) System.err.println("##### ThreadPool.removeThread:" + threadId);
+
+ JobQueue jobQueue = (JobQueue)_jobQueues.get(threadId);
+ if(jobQueue != null && jobQueue._add_count <= 0) {
+ synchronized(_jobQueues) {
+ if(jobQueue._add_count <= 0) {
+ _jobQueues.remove(threadId);
+ _disposeIds.remove(threadId);
+ _jobQueues.notifyAll();
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes the jobQueue for the current thread.
+ * Implements the method of <code>IThreadPool</code>
+ * <p>
+ * @see com.sun.star.lib.uno.environments.remote.IThreadPool#removeThread
+ */
+ public void removeThread() {
+ if(_disposed) throw new RuntimeException("ThreadPool.removeQueue - is disposed");
+
+ removeThread(getThreadId());
+ }
+
+ /**
+ * Queues a job into the jobQueue of the thread belonging to the jobs threadId.
+ * Implements the method of <code>IThreadPool</code>
+ * <p>
+ * @param job the job
+ * @param disposeId the dispose id
+ * @see com.sun.star.lib.uno.environments.remote.IThreadPool#putJob
+ */
+ public void putJob(Job job, Object disposeId) throws InterruptedException {
+ if(_disposed) throw new RuntimeException("ThreadPool.putJob - is disposed");
+
+ JobQueue jobQueue = null;
+
+ ThreadID threadId = job.getThreadId();
+
+ if(DEBUG) System.err.println("#### ThreadPool.putJob:" + threadId + " " + job + " " + _jobQueues);
+
+ jobQueue = (JobQueue)_jobQueues.get(threadId);
+
+
+ if(jobQueue == null) {
+ synchronized(_jobQueues) {
+ jobQueue = (JobQueue)_jobQueues.get(threadId);
+ if(jobQueue == null) {
+ if(jobQueue != null)
+ removeThread(threadId);
+
+ // add a new JobQueue for this job
+ addThread(true, threadId, disposeId);
+ jobQueue = (JobQueue)_jobQueues.get(threadId);
+ }
+ }
+ }
+
+ jobQueue.putJob(job, disposeId);
+ }
+
+ /**
+ * Enters the <code>ThreadPool</code> under the given thread id.
+ * Waits for a reply job or an exception.
+ * <p>
+ * @result the result of final reply
+ * @param threadId the thread id to use
+ */
+ public Object enter(ThreadID threadId) throws java.lang.Exception {
+ if(_disposed) throw new RuntimeException("ThreadPool.enter - is disposed");
+
+ JobQueue jobQueue = (JobQueue)_jobQueues.get(threadId);
+
+ Object object = null;
+
+ try {
+ object = jobQueue.enter(_disposeIds.get(threadId));
+ }
+ finally {
+ removeThread(threadId);
+ }
+
+ return object;
+ }
+
+ /**
+ * Lets the current thread enter the ThreadPool.
+ * The thread then dispatches all jobs and leaves
+ * the ThreadPool when it gets a reply job.
+ * Implements the method of <code>IThreadPool</code>
+ * <p>
+ * @see com.sun.star.lib.uno.environments.remote.IThreadPool#enter
+ */
+ public Object enter() throws java.lang.Exception {
+ return enter(getThreadId());
+ }
+
+ /**
+ * Interrupts all threads which have associated the dispose id.
+ * Implements the method of <code>IThreadPool</code>
+ * <p>
+ * @param disposeId the dispose id
+ * @see com.sun.star.lib.uno.environments.remote.IThreadPool#dispose
+ */
+ public void dispose(Object disposeId) {
+ // clear all jobqueues
+ synchronized(_jobQueues) {
+ Enumeration elements = _jobQueues.elements();
+ while(elements.hasMoreElements())
+ ((JobQueue)elements.nextElement()).interrupt(disposeId);
+ }
+ }
+
+ /**
+ * Stops interrupting all jobs queued by the given bridge.
+ * Implements the method of <IThreadPool>.
+ */
+ public synchronized void stopDispose(Object disposeId) {
+
+ }
+
+ synchronized void dispose() {
+ if(_disposed) throw new RuntimeException("ThreadPool.dispose - is disposed");
+
+ _disposed = true;
+
+ if(_jobQueues.size() > 0)
+ System.err.println("Warning! ThreadPool.dipose - there are active JobQueus:" + _jobQueues.size());
+
+ // clear all jobqueues
+ synchronized(_jobQueues) {
+ Enumeration elements = _jobQueues.elements();
+ while(elements.hasMoreElements())
+ ((JobQueue)elements.nextElement()).clear();
+
+ _jobQueues.clear();
+ _jobQueues.notifyAll();
+
+ _jobQueues = null;
+ }
+ }
+
+}
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/Job.java b/jurt/com/sun/star/lib/uno/environments/remote/Job.java
new file mode 100644
index 000000000000..44f8093b52d0
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/remote/Job.java
@@ -0,0 +1,284 @@
+/*************************************************************************
+ *
+ * $RCSfile: Job.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.remote;
+
+
+import java.io.IOException;
+
+
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import com.sun.star.corba.giop.ReplyStatusType_1_2;
+
+import com.sun.star.lib.uno.typeinfo.ParameterTypeInfo;
+
+import com.sun.star.uno.Any;
+import com.sun.star.uno.MappingException;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+
+
+/**
+ * The Job is an abstraction for tasks which have to be done
+ * remotely because of a method invocation.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:53 $
+ * @author Kay Ramme
+ * @see com.sun.star.lib.uno.environments.remote.ThreadID
+ * @see com.sun.star.lib.uno.environments.remote.IReceiver
+ * @since UDK1.0
+ */
+public class Job {
+ public static final boolean DEBUG = false;
+
+ protected Job _next;
+
+ protected IReceiver _iReceiver;
+ protected IMessage _iMessage;
+ Object _disposeId;
+
+ protected Object _object;
+
+ public Job(Object object, IReceiver iReceiver, IMessage iMessage) {
+ _object = object;
+ _iReceiver = iReceiver;
+ _iMessage = iMessage;
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".<init>:" + _iReceiver + " " + _iMessage);
+ }
+
+ /**
+ * Dispatches a regular method call
+ * <p>
+ * @return the result of the call
+ * @param message the parameter for the call
+ * @param resultClass the result type as an out parameter
+ * @param status the status as an out parameter
+ * @param o_outs the out parameters of the call as out parameters
+ * @param o_out_sig the out signature as an out parameter
+ */
+ protected Object dispatch_MethodCall(Object params[]) throws Exception {
+ Method method = Protocol.__findMethod(_iMessage.getInterface(), _iMessage.getOperation());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".dispatch_MethodCall:" + _object + " " + method.getName() + " " + params);
+
+ return method.invoke(_object, params);
+ }
+
+ /**
+ * Dispatches a <code>queryInterface</code> call
+ * <p>
+ * @return the result of the call (should be an <code>Any</code>)
+ * @param message the parameter for the call
+ * @param resultClass the result type as an out parameter
+ * @param status the status as an out parameter
+ * @param o_outs the out parameters of the call as out parameters
+ * @param o_out_sig the out signature as an out parameter
+ */
+ protected Object dispatch_queryInterface(Type type) throws Exception {
+ Class zInterface = type.getDescription();
+
+ Object result = null;
+
+ Object face = UnoRuntime.queryInterface(zInterface, _object);
+ // the hell knows why, but empty interfaces a given back as void anys
+ if(face != null)
+ result = new com.sun.star.uno.Any(type.getDescription(), face);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".dispatch_queryInterface:" + _object + " " + zInterface + " result:" + result);
+
+ return result;
+ }
+
+ /**
+ * Executes the job.
+ * <p>
+ * @return returns true if the operation is a reply
+ */
+ public Object execute() throws Exception {
+ Object params[][] = new Object[1][];
+
+ Object result = _iMessage.getData(params);
+
+ if(_iMessage.isException())
+ throw (Exception)result;
+
+ try {
+ if(_iMessage.getOperation() != null) { // it is a request
+ Object xresult = null;
+
+ if(_iMessage.getOperation().equals("queryInterface"))
+ xresult = dispatch_queryInterface((Type)params[0][0]);
+ else
+ xresult = dispatch_MethodCall(params[0]);
+
+ if(_iMessage.isSynchron())
+ _iReceiver.sendReply(false, _iMessage.getThreadID(), xresult);
+ }
+ }
+ catch(InvocationTargetException invocationTargetException) {
+ Throwable theException = invocationTargetException;
+
+ do {
+ if(DEBUG) {
+ System.err.println("##### RemoteStub.request - exception occured:" + ((InvocationTargetException)theException).getTargetException());
+ ((InvocationTargetException)theException).getTargetException().printStackTrace();
+ }
+
+ theException = ((InvocationTargetException)theException).getTargetException();
+ }
+ while(theException instanceof InvocationTargetException);
+
+ if(theException instanceof com.sun.star.uno.Exception
+ || theException instanceof com.sun.star.uno.RuntimeException) {
+ if(_iMessage.isSynchron())
+ _iReceiver.sendReply(true, _iMessage.getThreadID(), theException);
+
+ if(DEBUG) System.err.println("#### RemoteStub.request - exception:" + theException);
+ }
+ else
+ throw (Exception)invocationTargetException.getTargetException();
+ }
+
+ return result;
+ }
+
+ /**
+ * Indicates whether the job is synchron or asynchron.
+ * <p>
+ * @return returns <code>true</code> if the operation is synchron
+ */
+ public boolean isSynchron() {
+ return _iMessage.isSynchron(); //_synchron || (_operation == null);
+ }
+
+ /**
+ * Indicates whether the job is a reply but not an exception
+ * <p>
+ * @return returns <code>true</code> is this job is final
+ */
+ public boolean isFinal() {
+ return _iMessage.getOperation() == null; // && !_iMessage.isException();
+ }
+
+ /**
+ * Gives the thread id of the job
+ * <p>
+ * @return returns the thread id
+ */
+ public ThreadID getThreadId() {
+ return _iMessage.getThreadID();
+ }
+
+ /**
+ * Gives the object id of the job
+ * <p>
+ * @return returns the object id
+ */
+ public String getOID() {
+ return null; //_oId;
+ }
+
+ /**
+ * Gives the operation of the job
+ * <p>
+ * @return returns the operation
+ */
+ public String getOperation() {
+ return _iMessage.getOperation();
+ }
+
+ /**
+ * Gives the interface of the object to call on
+ * <p>
+ * @return returns the interface
+ */
+ public Class getInterface() {
+ return _iMessage.getInterface();
+ }
+
+ /**
+ * Gives a descriptive <code>String</code> of the job
+ * <p>
+ * @return returns the description
+ */
+ public String toString() {
+ return "job: "; //+ _operation + " " + _requestId;
+ }
+
+
+ public void dispose() {
+// _oId = null;
+// _iReceiver = null;
+// _threadId = null;
+// _object = null;
+// _operation = null;
+// _param = null;
+// _exception = null;
+// _zInterface = null;
+// _disposeId = null;
+ }
+}
+
+
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java b/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java
new file mode 100644
index 000000000000..6fd065df90b8
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java
@@ -0,0 +1,515 @@
+/*************************************************************************
+ *
+ * $RCSfile: JobQueue.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.remote;
+
+
+import java.util.Hashtable;
+
+import com.sun.star.uno.UnoRuntime;
+
+
+/**
+ * The <code>JobQueue</code> implements a queue for jobs.
+ * For every jobs thread id exists a job queue which is registered
+ * at the <code>ThreadPool</code>.
+ * A JobQueue is splitted in a sync job queue and an async job queue.
+ * The sync job queue is the registerd queue, it delegates async jobs
+ * (put by <code>putjob</code>) into the async queue, which is only
+ * known by the sync queue.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:52 $
+ * @author Kay Ramme
+ * @see com.sun.star.lib.uno.environments.remote.ThreadPool
+ * @see com.sun.star.lib.uno.environments.remote.Job
+ * @see com.sun.star.lib.uno.environments.remote.ThreadID
+ * @since UDK1.0
+ */
+public class JobQueue {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ public static final boolean DEBUG = false;
+
+ static protected int __instances;
+
+ protected Job _head; // the head of the job list
+ protected Job _tail; // the tail of the job list
+ protected Job _current; // the current executing job
+
+// protected int _todo = 0; // jobs to do
+
+ protected ThreadID _threadId; // the thread id of the queue
+ protected int _add_count = 0; // the stack deepness
+ protected boolean _createThread; // create a worker thread, if needed
+ protected boolean _createThread_now; // create a worker thread, if needed
+ protected Thread _worker_thread; // the thread that does the jobs
+
+ protected Hashtable _disposeIds = new Hashtable(); // disposeIds for disposing
+
+ protected JobQueue _async_jobQueue; // chaining job qeueus for asyncs
+ protected JobQueue _sync_jobQueue; // chaining job qeueus for syncs
+
+ protected boolean _active = false;
+
+ // statistics
+ protected int _async_threads_created;
+ protected int _sync_threads_created;
+ protected int _async_jobs_queued;
+ protected int _sync_jobs_queued;
+
+ class MutableInt {
+ int _value;
+ }
+
+ /**
+ * A thread for dispatching jobs
+ */
+ class JobDispatcher extends Thread {
+ JobDispatcher() {
+// super("JobDispatcher - " + _threadId);
+
+ if(DEBUG) System.err.println("JobQueue$JobDispatcher.<init>:" + _threadId);
+
+ if(_sync_jobQueue == null)
+ ++ _sync_threads_created;
+ else
+ ++ _sync_jobQueue._async_threads_created;
+ }
+
+ ThreadID getThreadId() {
+ return _threadId;
+ }
+
+ public void run() {
+ if(DEBUG) System.err.println("ThreadPool$JobDispatcher.run");
+ try {
+ enter(1000, null);
+ }
+ catch(java.lang.Exception exception) {
+ System.err.println(getClass().getName() + " - exception occurred:" + exception);
+ if(DEBUG) ;exception.printStackTrace();
+ }
+
+ // dispose the jobQueue
+// dispose();
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".run - exit:" + _threadId);
+ }
+ }
+
+
+ /**
+ * Constructs a async job queue with the given thread id
+ * which belongs to the given sync job queue.
+ * <p>
+ * @param threadId the thread id
+ * @param sync_jobQueue the sync queue this async queue belongs to
+ * @see com.sun.star.lib.uno.environments.remote.ThreadID
+ */
+ protected JobQueue(ThreadID threadId, JobQueue sync_jobQueue) {
+ ++ __instances;
+
+ // create a new async threadID
+ _threadId = new ThreadID(threadId);
+ _sync_jobQueue = sync_jobQueue;
+ _createThread = true;
+ _createThread_now = true;
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + " - init:" + _threadId);
+ }
+
+ /**
+ * Constructs a sync job queue with the given thread id and the given thread.
+ * <p>
+ * @param threadId the thread id
+ * @param createThread if true, the queue creates a worker thread if needed
+ * @see com.sun.star.lib.uno.environments.remote.ThreadID
+ */
+ JobQueue(ThreadID threadId, boolean createThread){
+ ++ __instances;
+
+ _threadId = threadId;
+ _createThread = createThread;
+ _createThread_now = createThread;
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + " - init:" + _threadId + " " + createThread);
+ }
+
+ /**
+ * Gives the currently dispatched job.
+ * <p>
+ * @return the dispatched job
+ * @see com.sun.star.lib.uno.environments.remote.Job
+ */
+ Job getCurrentJob() {
+ return _current;
+ }
+
+ /**
+ * Gives the thread id of this queue
+ * <p>
+ * @return the thread id
+ * @see com.sun.star.lib.uno.environments.remote.ThreadID
+ */
+ ThreadID getThreadId() {
+ return _threadId;
+ }
+
+ /**
+ * Gives the dispatcher thread
+ * <p>
+ * @return the thread
+ */
+ Thread getThread() {
+ return _worker_thread;
+ }
+
+ /**
+ * Adds a dispose id.
+ * <p>
+ * @return the count of how often the id has already been added
+ * @param disposeId the dispose id
+ */
+ private synchronized MutableInt addDisposeId(Object disposeId) {
+ MutableInt disposeId_count = null;
+
+ if(disposeId != null) {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + " " + this +".addDisposeId:" + disposeId);
+
+ disposeId_count = (MutableInt)_disposeIds.get(disposeId);
+ if(disposeId_count == null) {
+ disposeId_count = new MutableInt();
+ _disposeIds.put(disposeId, disposeId_count);
+ }
+
+ ++ disposeId_count._value;
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".addDisposeId value:" + disposeId_count._value);
+
+ }
+
+ return disposeId_count;
+ }
+
+ /**
+ * Removes a dispose id.
+ * <p>
+ * @param disposeId the dispose id
+ * @param disposeId_count
+ */
+ private synchronized void removeDisposeId(Object disposeId, MutableInt disposeId_count) {
+ if(disposeId != null) {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".removeDisposeId:" + disposeId + " " + disposeId_count);
+
+ if(disposeId_count == null)
+ disposeId_count = (MutableInt)_disposeIds.get(disposeId);
+
+ if(disposeId_count != null) {
+ -- disposeId_count._value;
+ if(disposeId_count._value <= 0)
+ _disposeIds.remove(disposeId);
+ }
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".removeDisposeId value:" + disposeId_count._value);
+
+ }
+
+ }
+
+ /**
+ * Removes a job from the queue.
+ * <p>
+ * @return a job or null if timed out
+ * @param waitTime the maximum amount of time to wait for a job
+ */
+ private synchronized Job removeJob(int waitTime) throws InterruptedException {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".removeJob:" + /*_todo + " " + */_head + " " + _threadId);
+
+ // wait max. waitTime time for a job to enter the queue
+ boolean waited = false;
+ while(_head == null && waitTime >= 0 && !waited) {
+ wait(waitTime);
+
+ // signal that we have already waited once
+ waited = true;
+ }
+
+ // if there is an async queue, wait for jobs to be done
+ if(_async_jobQueue != null) {
+ synchronized(_async_jobQueue) {
+ while(_async_jobQueue._worker_thread != null && _async_jobQueue._active) {
+// while(_async_jobQueue._worker_thread != null || _async_jobQueue._head != null) {
+// while(_async_jobQueue._todo > 0) {
+ if(DEBUG) ;System.err.println("waiting for async:" + _async_jobQueue._head + " " + _async_jobQueue._worker_thread);
+ _async_jobQueue.wait(10);
+ }
+ }
+ }
+
+ Job job = null;
+
+ if(_head != null) {
+ _current = _head;
+ _head = _head._next;
+
+ if(_head == null)
+ _tail = null;
+
+ job = _current;
+ }
+
+ return job;
+ }
+
+ /**
+ * Puts a job into the queue.
+ * <p>
+ * @param job the job
+ * @param disposeId a dispose id
+ */
+ public void putJob(Job job, Object disposeId) {
+ if(job.getOperation() == null || job.isSynchron()) { // if job is a reply or is sync
+ // fill the sync queue (this)
+ _putJob(job, disposeId);
+
+ ++ _sync_jobs_queued;
+ }
+ else {
+ synchronized(this) {
+ // create the async JobQueue ?
+ if(_async_jobQueue == null)
+ _async_jobQueue = new JobQueue(_threadId, this);
+
+ // fill the async queue, async queue are intentionally not disposed
+ _async_jobQueue._putJob(job, null);
+
+ ++ _async_jobs_queued;
+ }
+ }
+ }
+
+ /**
+ * Puts a job into the queue.
+ * <p>
+ * @param job the job
+ * @param disposeId a dispose id
+ */
+ private synchronized void _putJob(Job job, Object disposeId) {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".putJob todoes: " /*+ _todo */ + " job:" + job);
+
+ // Hold the dispose id at the, to be able to remove the dispose id
+ // once the job has been executed.
+ job._disposeId = disposeId;
+ addDisposeId(disposeId);
+
+ if(_tail != null)
+ _tail._next = job;
+ else
+ _head = job;
+
+ _tail = job;
+
+// ++ _todo;
+
+ if(_worker_thread == null && _createThread && _createThread_now) { // if there is no thread, which dispatches and if shall create one, create one
+ _createThread_now = false;
+ new JobDispatcher().start();
+ }
+
+ // always notify possible waiters
+ notify();
+ }
+
+ /**
+ * Enters the job queue.
+ * <p>
+ * @return the result of the final job (reply)
+ * @param disposeId a dispose id
+ */
+ Object enter(Object disposeId) throws Exception {
+ return enter(0, disposeId); // wait infinitly
+ }
+
+ /**
+ * Enters the job queue.
+ * <p>
+ * @return the result of the final job (reply)
+ * @param waitTime the maximum amount of time to wait for a job (0 means wait infinitly)
+ * @param disposeId a dispose id
+ */
+ synchronized Object enter(int waitTime, Object disposeId) throws Exception {
+ if(DEBUG) System.err.println("#####" + getClass().getName() + ".enter: " + _threadId);
+
+ boolean quit = false;
+
+ MutableInt disposeId_count = addDisposeId(disposeId);
+
+ ++ _add_count; // how many times have entered enter?
+
+ Object result = null;
+
+ Thread hold_worker_thread = _worker_thread;
+ _worker_thread = Thread.currentThread();
+
+ while(!quit) {
+ Job job = null;
+ try {
+ job = removeJob(waitTime);
+
+ if(job != null) {
+ try {
+ _active = true;
+ result = job.execute();
+ }
+ finally {
+ _active = false;
+ removeDisposeId(job._disposeId, null);
+ }
+
+ if(job.isFinal()) {
+ job.dispose();
+
+ quit = true;
+ }
+
+ job = null;
+ }
+ else
+ quit = true;
+
+
+ }
+ finally { // ensure that this queue becomes disposed, if necessary
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".enter leaving: " + _threadId + " " + _worker_thread + " " + hold_worker_thread + " " + result);
+
+ synchronized(this) {
+ if(job != null || (quit && _head == null)) {
+ -- _add_count;
+ _worker_thread = hold_worker_thread;
+
+ _createThread_now = true;
+
+ removeDisposeId(disposeId, disposeId_count);
+
+ if(_sync_jobQueue != null)
+ notifyAll(); // notify waiters (e.g. this is an asyncQueue and there is a sync waiting)
+ }
+ else
+ quit = false;
+
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * If the given disposeId is registered,
+ * interrups the worker thread.
+ * <p>
+ * @param disposeId the dispose id
+ */
+ synchronized void interrupt(Object disposeId) {
+ MutableInt disposeId_count = (MutableInt)_disposeIds.get(disposeId);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + " " + this + ".interrupt:" + disposeId + " " + disposeId_count);
+
+ if(disposeId_count != null && _worker_thread != null) { //
+ _worker_thread.interrupt();
+ }
+ }
+
+ /**
+ * The finalizer decreases the instance count
+ */
+ public void finalize() {
+ -- __instances;
+ }
+
+ /**
+ * Prints statistics abourt the queue
+ */
+ void printStats() {
+ System.err.println("threads created all: " + (_sync_threads_created + _async_threads_created)
+ + " asyncs: " + _async_threads_created
+ + " syncs: " + _sync_threads_created);
+ System.err.println("jobs pub - all: " + (_async_jobs_queued + _sync_jobs_queued)
+ + " asyncs: " + _async_jobs_queued
+ + " syncs: " + _sync_jobs_queued);
+ }
+
+ /**
+ * Clears the queue
+ */
+ synchronized void clear() {
+ if(_head != null)
+ System.err.println("JobQueue.dispose - jobs left");
+
+ _head = _tail = _current = null;
+ _worker_thread = null;
+
+// _threadId = null;
+// _async_jobQueue = null;
+
+// notify(); // wakes up all threads, which are waiting for jobs
+ }
+}
+
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/makefile.mk b/jurt/com/sun/star/lib/uno/environments/remote/makefile.mk
new file mode 100644
index 000000000000..2063e4575540
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/remote/makefile.mk
@@ -0,0 +1,102 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/lib$/uno$/environments$/remote
+TARGET = com_sun_star_lib_uno_environments_remote
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+GENJAVAFILES= \
+ $(MISC)$/java$/com$/sun$/star$/bridge$/XInstanceProvider.java \
+ $(MISC)$/java$/com$/sun$/star$/container$/NoSuchElementException.java \
+ $(MISC)$/java$/com$/sun$/star$/corba$/giop$/ReplyStatusType_1_2.java \
+ $(MISC)$/java$/com$/sun$/star$/uno$/Exception.java \
+ $(MISC)$/java$/com$/sun$/star$/uno$/RuntimeException.java \
+ $(MISC)$/java$/com$/sun$/star$/uno$/XInterface.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/IMarshal.class \
+ $(CLASSDIR)$/$(PACKAGE)$/IMessage.class \
+ $(CLASSDIR)$/$(PACKAGE)$/IUnmarshal.class \
+ $(CLASSDIR)$/$(PACKAGE)$/IProtocol.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Job.class \
+ $(CLASSDIR)$/$(PACKAGE)$/JobQueue.class \
+ $(CLASSDIR)$/$(PACKAGE)$/IReceiver.class \
+ $(CLASSDIR)$/$(PACKAGE)$/ThreadID.class \
+ $(CLASSDIR)$/$(PACKAGE)$/IThreadPool.class \
+ $(CLASSDIR)$/$(PACKAGE)$/JavaThreadPool.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Protocol.class \
+ $(CLASSDIR)$/$(PACKAGE)$/ThreadPool.class \
+ $(CLASSDIR)$/$(PACKAGE)$/remote_environment.class \
+ $(CLASSDIR)$/$(PACKAGE)$/INativeCallback.class \
+ $(CLASSDIR)$/$(PACKAGE)$/NativeThreadPoolWrapper.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/remote_environment.java b/jurt/com/sun/star/lib/uno/environments/remote/remote_environment.java
new file mode 100644
index 000000000000..d6069daa4080
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/environments/remote/remote_environment.java
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * $RCSfile: remote_environment.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.remote;
+
+
+import java.util.Enumeration;
+
+
+import com.sun.star.lib.util.WeakTable;
+
+import com.sun.star.uno.IEnvironment;
+import com.sun.star.uno.UnoRuntime;
+
+
+public class remote_environment implements IEnvironment {
+ public static final boolean DEBUG = false;
+
+ protected String _name;
+ protected WeakTable _objects = new WeakTable();
+ protected Object _context; // free context pointer, that can be used for specific classes of environments,
+
+ protected remote_environment(String name, Object context) {
+ if(DEBUG) System.err.println("#### AbstractEnvironment.<init>");
+
+ _name = name;
+ _context = context;
+ }
+
+ public remote_environment(Object context) {
+ this("remote", context);
+ }
+
+ /**
+ * the context
+ */
+ public Object getContext() {
+ return _context;
+ }
+
+ /**
+ * a name for this environment
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * Tests if two environments are equal.
+ *<BR>
+ * @param environment one environment
+ */
+ public boolean equals(Object object) {
+ return false;
+ }
+
+ /**
+ * You register internal and external interfaces via this method. Internal interfaces are
+ * proxies that are used in an environment. External interfaces are interfaces that are
+ * exported to another environment, thus providing an object identifier for this task.
+ * This can be called an external reference.
+ * Interfaces are held weakly at an environment; they demand a final revokeInterface()
+ * call for each interface that has been registered.
+ *<BR>
+ * @param object inout parameter for the registered object
+ * @param oId[] inout parameter for the corresponding object id
+ * @param xtypeDescr type description of interface
+ */
+ public Object registerInterface(Object object, String oId[], Class zInterface) {
+ if(oId[0] == null)
+ oId[0] = UnoRuntime.generateOid(object);
+
+ Object p_object = (Object)_objects.get(oId[0] + zInterface, zInterface);
+
+ if(DEBUG)
+ System.err.println("#### AbstractEnvironment.registerInterface:" + object + " " + UnoRuntime.generateOid(object) + " " + p_object);
+
+ if(p_object == null)
+ object = _objects.put(oId[0] + zInterface, object, zInterface);
+ else
+ object = p_object;
+
+ return object;
+ }
+
+ /**
+ * You have to revoke ANY interface that has been registered via this method.
+ *<BR>
+ * @param oId object id of interface to be revoked
+ * @param xtypeDescr type description of interface to be revoked
+ */
+ public void revokeInterface(String oId, Class zInterface) {
+ _objects.remove(oId);
+ }
+
+ /**
+ * Retrieves an interface identified by its object id and type from this environment.
+ *<BR>
+ * @param oId object id of interface to be retrieved
+ * @param xtypeDescr description of interface to be retrieved
+ */
+ public Object getRegisteredInterface(String oId, Class zInterface) {
+ Object object = _objects.get(oId + zInterface, zInterface);
+
+ if(DEBUG) System.err.println("#### AbstractEnvironment(" + getName() + ").getRegisteredInterface:>" + oId + "< " + zInterface +" " + object);
+
+ return object;
+ }
+
+ /**
+ * Retrieves the object identifier for a registered interface from this environment.
+ *<BR>
+ * @param object a registered interface
+ */
+ public String getRegisteredObjectIdentifier(Object object) {
+ return UnoRuntime.generateOid(object);
+ }
+
+ public void list() {
+ System.err.println("#### AbstractEnvironment.list(" + getName() + " " + getContext() + "):");
+
+ Enumeration elements = _objects.keys();
+ while(elements.hasMoreElements()) {
+ System.err.println("#### key:" + (String)elements.nextElement());
+ }
+ }
+
+ public void dispose() {
+ boolean result = _objects.reset();
+ if(!result)
+ System.err.println(getClass().getName() + ".reset - " + getName() + " " + result);
+
+// return result;
+ }
+}
+
diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java b/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java
new file mode 100644
index 000000000000..c1300bc327e3
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * $RCSfile: Cache.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.protocols.urp;
+
+
+import java.util.Hashtable;
+
+
+class Cache {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static private final boolean DEBUG = false;
+
+ private static class Entry {
+ short _prev;
+ short _next;
+
+ Object _content;
+
+ Entry(short prev, short next, Object content) {
+ _prev = prev;
+ _next = next;
+ _content = content;
+ }
+ }
+
+ private Entry _entrys[];
+ private short _size;
+ private short _last;
+ private short _first;
+
+ private Hashtable _keyMap = new Hashtable();
+
+ Cache(short size) {
+ _size = size;
+ _entrys = new Entry[size];
+
+ for(short i = 0; i < size; ++ i) {
+ _entrys[i] = new Entry((short)(i - 1), (short)(i + 1), new Object());
+ }
+
+ _first = 0;
+ _last = 4;
+
+ _entrys[_first]._prev = -1; // end of list
+ _entrys[_last]._next = -1; // end of list
+ }
+
+ short add(boolean found[], Object content) {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".add:" + content);
+
+ short index = -1;
+
+// for(index = 0; index < _entrys.length && !_entrys[index]._content.equals(content); ++ index);
+ Short ii = (Short)_keyMap.get(content);
+
+ if(ii != null)
+ index = ii.shortValue();
+
+
+ if(index < 0 || index >= _entrys.length) { // not found
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".add - not found:" + content + " index:" + _last);
+
+ // remove last from list
+ index = _last;
+ _last = _entrys[_last]._prev;
+ _entrys[_last]._next = -1; // end of list
+
+ // insert last as head
+ _entrys[index]._next = _first;
+ _entrys[_first]._prev = index;
+
+ _entrys[index]._content = content;
+
+ _first = index;
+ _entrys[_first]._prev = -1; // end of list
+
+ _keyMap.put(new Short(index), content);
+
+ found[0] = false;
+ }
+ else { // found
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".add - found:" + content + " " + index);
+
+ touch(index);
+
+ found[0] = true;
+ }
+
+ return index;
+ }
+
+ void touch(short index) {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".touch:" + index);
+
+ // remove index of list
+ if(index != _first && _entrys[index]._prev != -1)
+ _entrys[_entrys[index]._prev]._next = _entrys[index]._next;
+
+ if(index != _last)
+ _entrys[_entrys[index]._next]._prev = _entrys[index]._prev;
+ else {
+ _last = _entrys[_last]._prev;
+ _entrys[_last]._next = -1; // end of list
+ }
+
+
+ // insert index at first
+ _entrys[index]._next = _first;
+ _entrys[_first]._prev = index;
+
+ _first = index;
+ _entrys[_first]._prev = -1; // end of list
+ }
+
+
+ void list() {
+ System.err.println("################# listing cache #############" + _first + " " + _last);
+
+ short curr = _first;
+ do {
+ System.err.println("e:" + _entrys[curr]._content);
+
+ curr = _entrys[curr]._next;
+ }
+ while(curr != -1);
+
+ System.err.println();
+ }
+
+ static public void main(String args[]) {
+ Cache cache = new Cache((short)5);
+
+ cache.list();
+
+ boolean found[] = new boolean[1];
+
+ for(int i = 0; i < 7; ++ i) {
+ short index = cache.add(found, new Integer(i));
+
+ System.err.println("added: " + i + " " + found[0]);
+ cache.list();
+ }
+
+ for(int x = 0; x < 2; x++) {
+ cache.add(found, new Integer(5));
+ cache.list();
+
+ cache.add(found, new Integer(4));
+ cache.list();
+ }
+ }
+}
diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java b/jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java
new file mode 100644
index 000000000000..41ac2e66143d
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java
@@ -0,0 +1,480 @@
+/*************************************************************************
+ *
+ * $RCSfile: Marshal.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+package com.sun.star.lib.uno.protocols.urp;
+
+
+import java.io.ByteArrayInputStream;
+import java.util.Hashtable;
+import com.sun.star.uno.IEnvironment;
+import com.sun.star.uno.MappingException;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+
+import com.sun.star.uno.Any;
+import com.sun.star.uno.Enum;
+import com.sun.star.uno.IBridge;
+import com.sun.star.uno.IQueryInterface;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.TypeClass;
+import com.sun.star.uno.Union;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.lib.uno.environments.remote.IMarshal;
+import com.sun.star.lib.uno.environments.remote.Protocol;
+import com.sun.star.lib.uno.environments.remote.ThreadID;
+
+import com.sun.star.lib.uno.typeinfo.MemberTypeInfo;
+
+class Marshal implements IMarshal {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ static class M_ThreadId {
+ byte full[];
+ short cache;
+
+ M_ThreadId() {}
+
+ M_ThreadId(byte full[], short cache) {
+ this.full = full;
+ this.cache = cache;
+ }
+ }
+
+ static class M_InterfaceReference {
+ String full;
+ short cache;
+
+ M_InterfaceReference() {}
+
+ M_InterfaceReference(String full, short cache) {
+ this.full = full;
+ this.cache = cache;
+ }
+ }
+
+
+ private ByteArrayOutputStream _byteArrayOutputStream;
+ private DataOutput _dataOutput;
+ private IBridge _iBridge;
+ private Cache _objectCache;
+ private Cache _typeCache;
+ private Cache _threadIdCache;
+
+ Marshal(IBridge iBridge, short cacheSize) {
+ _iBridge = iBridge;
+
+ _byteArrayOutputStream = new ByteArrayOutputStream();
+ _dataOutput = new DataOutputStream(_byteArrayOutputStream);
+
+ _objectCache = new Cache(cacheSize);
+ _typeCache = new Cache(cacheSize);
+ _threadIdCache = new Cache(cacheSize);
+ }
+
+ void writeAny(Object object) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeAny:" + object);
+
+ Type type = null;
+
+ if(object == null)
+ type = new Type(Void.class);
+
+ else if(object instanceof Any) {
+ Any any = (Any)object;
+
+ type = new Type(any.getInterface());
+ object = any.getObject();
+ }
+ else if(object instanceof XInterface)
+ type = new Type(XInterface.class);
+
+ else
+ type = new Type(object.getClass());
+
+ writeType(type);
+ writeObject(type.getDescription(), object);
+ }
+
+ void writeBoolean(Boolean zBoolean) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeBoolean:" + zBoolean);
+
+ _dataOutput.writeBoolean(zBoolean.booleanValue());
+ }
+
+ void writebyte(byte zbyte) throws Exception {
+ int ibyte = zbyte & 0xff;
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writebyte:" + ibyte);
+
+ _dataOutput.writeByte(ibyte);
+ }
+
+ void writebyteSequence(byte bytes[]) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writebyteSequence:" + bytes);
+
+ writeCompressedInt(bytes.length);
+
+ _dataOutput.write(bytes);
+ }
+
+ void writeByte(Byte zByte) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeByte:" + zByte);
+
+ _dataOutput.writeByte(zByte.byteValue());
+ }
+
+ void writeCharacter(Character character) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeCharacter:" + character);
+
+ _dataOutput.writeChar(character.charValue());
+ }
+
+ void writeDouble(Double zDouble) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeDouble:" + zDouble);
+
+ _dataOutput.writeDouble(zDouble.doubleValue());
+ }
+
+ void writeEnum(Enum enum) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeEnum:" + enum + " " + enum.getValue());
+
+ writeCompressedInt(enum.getValue());
+ }
+
+ void writeThrowable(Class zClass, Throwable throwable) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeThrowable:" + throwable);
+
+ String message = throwable.getMessage();
+ writeString((message == null) ? "" : message);
+
+ if(java.lang.Exception.class.isAssignableFrom(zClass))
+ writeStruct(zClass, throwable, java.lang.Exception.class);
+
+ else if(java.lang.RuntimeException.class.isAssignableFrom(zClass))
+ writeStruct(zClass, throwable, java.lang.RuntimeException.class);
+
+ else
+ throw new Exception("urp.Marshal.writeThrowable - unsupported throwable:" + zClass);
+ }
+
+ void writeFloat(Float zFloat) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeFloat:" + zFloat);
+
+ _dataOutput.writeFloat(zFloat.floatValue());
+ }
+
+ void writeInteger(Integer integer) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeInteger:" + integer);
+
+ _dataOutput.writeInt(integer.intValue());
+ }
+
+ void writeint(int zint) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeint:" + zint);
+
+ _dataOutput.writeInt(zint);
+ }
+
+ void writeLong(Long zLong) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeLong:" + zLong);
+
+ _dataOutput.writeLong(zLong.longValue());
+ }
+
+ // we may optimize this method with a hashtable in the future
+ public void writeObject(Class zClass, Object object) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeObject: <" + zClass + "> <" + object + ">");
+
+ if(zClass == Any.class || zClass == Object.class) // write an any ?
+ writeAny(object);
+
+ else if(zClass.isArray() & zClass.getComponentType() == byte.class) // write a sequence ?
+ writebyteSequence((byte [])object);
+
+ else if(zClass.isArray()) // write a sequence ?
+ writeSequence(zClass, object);
+
+ else if(zClass == Void.class || zClass == void.class) // write nothing ?
+ ; // nop
+
+ else if(Enum.class.isAssignableFrom(zClass)) // write an enum ?
+ writeEnum((Enum)object);
+
+ else if(Union.class.isAssignableFrom(zClass)) // write a union ?
+ writeUnion((Union)object);
+
+ else if(Type.class.isAssignableFrom(zClass)) // write a type ?
+ writeType((Type)object);
+
+ else if(XInterface.class.isAssignableFrom(zClass)) // is it an interface ?
+ writeReference(zClass, object);
+
+ else if(object instanceof ThreadID) // is it a thread id ?
+ writeThreadID((ThreadID)object);
+
+ else if(zClass == boolean.class || zClass == Boolean.class) // is it a boolean
+ writeBoolean((Boolean)object);
+
+ else if(zClass == char.class || zClass == Character.class) // is it a character ?)
+ writeCharacter((Character)object);
+
+ else if(zClass == byte.class || zClass == Byte.class) // is it a byte ?
+ writeByte((Byte)object);
+
+ else if(zClass == short.class || zClass == Short.class) // is it a short ?
+ writeShort((Short)object);
+
+ else if(zClass == int.class || zClass == Integer.class) // is it an integer ?
+ writeInteger((Integer)object);
+
+ else if(zClass == long.class || zClass == Long.class) // is it a long ?
+ writeLong((Long)object);
+
+ else if(zClass == float.class || zClass == Float.class) // is it a float ?
+ writeFloat((Float)object);
+
+ else if(zClass == double.class || zClass == Double.class) // is it a double ?
+ writeDouble((Double)object);
+
+ else if(zClass == String.class) // is it a String ?
+ writeString((String)object);
+
+ else if(Throwable.class.isAssignableFrom(zClass)) // is it an exception?
+ writeThrowable(zClass, (Throwable)object);
+
+ else // otherwise it must be a struct
+ writeStruct(zClass, object);
+
+ }
+
+ static private final M_InterfaceReference null_M_InterfaceReference = new M_InterfaceReference("", (short)0xffff);
+
+ void writeOid(String oid) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeOid:" + oid);
+
+ M_InterfaceReference m_InterfaceReference = null;
+
+ if(oid == null)
+ m_InterfaceReference = null_M_InterfaceReference;
+ else {
+ boolean found[] = new boolean[1];
+ short index = _objectCache.add(found, oid);
+
+ m_InterfaceReference = new M_InterfaceReference(found[0] ? "" : oid, index);
+ }
+
+ writeObject(M_InterfaceReference.class, m_InterfaceReference);
+ }
+
+ void writeReference(Class zInterface, Object object) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeReference:" + zInterface + " " + object);
+
+ // map the object to universe
+ writeOid(object != null ? (String)_iBridge.mapInterfaceTo(object, zInterface) : null);
+ }
+
+ void writeSequence(Class zClass, Object object) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeSequence:" + zClass + " " + object);
+
+ int size = Array.getLength(object);
+ writeCompressedInt(size);
+
+ zClass = zClass.getComponentType();
+ for(int i = 0; i < size; ++ i)
+ writeObject(zClass, Array.get(object, i));
+ }
+
+ void writeShort(Short zShort) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeShort:" + zShort);
+
+ _dataOutput.writeShort(zShort.shortValue());
+ }
+
+ void writeshort(short zshort) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeshort:" + zshort);
+
+ _dataOutput.writeShort(zshort);
+ }
+
+ void writeCompressedInt(int size) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeCompressedInt:" + size);
+
+ if(size >= 255) {
+ _dataOutput.writeByte((byte)0xff);
+ _dataOutput.writeInt(size);
+ }
+ else
+ _dataOutput.writeByte((byte)size);
+ }
+
+ void writeString(String string) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeString:" + string);
+
+ byte bytes[] = string.getBytes("UTF8");
+
+ writeCompressedInt(bytes.length);
+ _dataOutput.write(bytes);
+ }
+
+ void writeStruct(Class zClass, Object object, Class untilClass) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeStruct:" + zClass + " " + object);
+
+ // write inherited members first
+ Class superClass = zClass.getSuperclass();
+ if(superClass != null && superClass != untilClass)
+ writeStruct(superClass, object, untilClass);
+
+ Field fields[] = Protocol.__getDeclaredFields(zClass);
+
+ for(int i = 0; i < fields.length; ++ i) {
+ if((fields[i].getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) { // neither static nor transient ?
+ MemberTypeInfo memberTypeInfo = Protocol.__findMemberTypeInfo(zClass, fields[i].getName());
+
+ // default the member type to the declared type
+ Class zInterface = fields[i].getType();
+
+ if(memberTypeInfo != null) { // do we have any type infos?
+ if(memberTypeInfo.isAny()) // is the member any any?
+ if(zInterface.isArray())
+ zInterface = Class.forName("[Lcom.sun.star.uno.Any;");
+ else
+ zInterface = Any.class;
+
+ else if(memberTypeInfo.isInterface()) { // is the member an interface ?
+ fields[i].getType().getFields();
+
+ Class xInterface = zInterface;
+
+ if(!XInterface.class.isAssignableFrom(fields[i].getType())) // is the member type not derived of XInterface ?
+ xInterface = XInterface.class; // ensure that we write at least an XInterface
+
+ if(zInterface.isArray())
+ zInterface = Class.forName("[L" + xInterface.getName() + ";");
+ else
+ zInterface = xInterface;
+ }
+ }
+
+ writeObject(zInterface, fields[i].get(object));
+ }
+ }
+ }
+
+ void writeStruct(Class zClass, Object object) throws Exception {
+ writeStruct(zClass, object, Object.class);
+ }
+
+ void writeThreadID(ThreadID threadID) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeThreadID:" + threadID);
+
+ boolean found[] = new boolean[1];
+ short index = _threadIdCache.add(found, threadID.getBytes());
+
+ M_ThreadId m_ThreadId = new M_ThreadId(found[0] ? null : threadID.getBytes(), index);
+
+ writeObject(M_ThreadId.class, m_ThreadId);
+ }
+
+ void writeType(Type type) throws Exception {
+ TypeClass typeClass = type.getTypeClass();
+
+ if(Type.isTypeClassSimple(typeClass))
+ _dataOutput.writeByte((byte)typeClass.getValue()); // write the typeclass value
+ else {
+ boolean found[] = new boolean[1];
+ short index = _typeCache.add(found, type.getTypeName());
+
+ _dataOutput.writeByte((byte)(typeClass.getValue() | (found[0] ? 0x0 : 0x80))); // write the typeclass value
+
+ _dataOutput.writeShort(index); // write the cache index
+
+ if(!found[0]) // if not found in cache and the type is complex, write the type name
+ writeString(type.getTypeName());
+ }
+ }
+
+ void writeUnion(Union union) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeUnion:" + union);
+
+ throw new Exception("Marshal.writeUnion is not implemented yet!!!");
+ }
+
+ public byte []reset() {
+ byte result[] = _byteArrayOutputStream.toByteArray();
+ _byteArrayOutputStream.reset();
+
+ return result;
+ }
+}
+
diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java b/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java
new file mode 100644
index 000000000000..878bbc6fd6b1
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java
@@ -0,0 +1,483 @@
+/*************************************************************************
+ *
+ * $RCSfile: Unmarshal.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+package com.sun.star.lib.uno.protocols.urp;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.InputStream;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+
+import com.sun.star.bridge.XInstanceProvider;
+
+import com.sun.star.uno.Any;
+import com.sun.star.uno.Enum;
+import com.sun.star.uno.IBridge;
+import com.sun.star.uno.IQueryInterface;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.TypeClass;
+import com.sun.star.uno.Union;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.lib.uno.environments.remote.IUnmarshal;
+import com.sun.star.lib.uno.environments.remote.Protocol;
+import com.sun.star.lib.uno.environments.remote.ThreadID;
+
+import com.sun.star.lib.uno.typeinfo.MemberTypeInfo;
+
+class Unmarshal implements IUnmarshal {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ private InputStream _inputStream;
+ private DataInput _dataInput;
+ private IBridge _iBridge;
+ private Object _objectCache[];
+ private Type _typeCache[];
+ private ThreadID _threadIdCache[];
+
+ Unmarshal(IBridge iBridge, short cacheSize) {
+ _iBridge = iBridge;
+
+ _objectCache = new Object[cacheSize];
+ _typeCache = new Type[cacheSize];
+ _threadIdCache = new ThreadID[cacheSize];
+ _inputStream = new ByteArrayInputStream(new byte[0]);
+ _dataInput = new DataInputStream(_inputStream);
+ }
+
+ Object readAny() throws Exception {
+ Type type = readType();
+ Object object = readObject(type.getDescription());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readAny:" + object);
+
+ return object;
+ }
+
+ Boolean readBoolean() throws Exception {
+ Boolean result = new Boolean(_dataInput.readBoolean());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readBoolean:" + result);
+
+ return result;
+ }
+
+ Byte readByte() throws Exception {
+ Byte result = new Byte(_dataInput.readByte());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readByte:" + result);
+
+ return result;
+ }
+
+ byte readbyte() throws Exception {
+ byte result = (byte)(_dataInput.readByte() & 0xff);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readbyte:" + (result & 0xff));
+
+ return result;
+ }
+
+ byte []readbyteSequence() throws Exception {
+ int size = readCompressedInt();
+ byte bytes[] = new byte[size];
+
+ _inputStream.read(bytes);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readbyteSequence:" + bytes);
+
+ return bytes;
+ }
+
+ Character readCharacter() throws Exception {
+ Character result = new Character(_dataInput.readChar());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readChar:" + result);
+
+ return result;
+ }
+
+ Double readDouble() throws Exception {
+ Double result = new Double(_dataInput.readDouble());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readDouble:" + result);
+
+ return result;
+ }
+
+ Enum readEnum(Class zClass) throws Exception {
+ int index = readCompressedInt();
+
+ Method fromInt = zClass.getMethod("fromInt", new Class[] {int.class});
+ Enum result = (Enum)fromInt.invoke(null, new Object[]{new Integer(index)});
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readEnum:" + result);
+
+ return result;
+ }
+
+ Throwable readThrowable(Class zClass) throws Exception {
+ String message = readString();
+
+ Constructor constructor = zClass.getConstructor(new Class[]{String.class});
+ Throwable throwable = (Throwable)constructor.newInstance(new Object[]{message});
+
+ if(java.lang.Exception.class.isAssignableFrom(zClass))
+ readStruct(zClass, throwable, java.lang.Exception.class);
+
+ else if(java.lang.RuntimeException.class.isAssignableFrom(zClass))
+ readStruct(zClass, throwable, java.lang.RuntimeException.class);
+ else
+ throw new Exception("urp.Unmarshal.readThrowable - unsupported throwable:" + zClass);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readThrowable:" + throwable);
+
+ return throwable;
+ }
+
+ Float readFloat() throws Exception {
+ Float result = new Float(_dataInput.readFloat());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readFloat:" + result);
+
+ return result;
+ }
+
+ Integer readInteger() throws Exception {
+ Integer result = new Integer(_dataInput.readInt());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readInteger:" + result);
+
+ return result;
+ }
+
+ Long readLong() throws Exception {
+ Long result = new Long(_dataInput.readLong());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readLong:" + result);
+
+ return result;
+ }
+
+ public Object readObject(Class zClass) throws Exception {
+ Object result = null;
+
+ if(zClass == Any.class || zClass == Object.class) // read an any?
+ result = readAny();
+
+ else if(zClass.isArray() && zClass.getComponentType() == byte.class) // read a sequence ?
+ result = readbyteSequence();
+
+ else if(zClass.isArray()) // read a sequence ?
+ result = readSequence(zClass);
+
+ else if(zClass == Void.class || zClass == void.class) // read nothing ?
+ ; // nop
+
+ else if(Enum.class.isAssignableFrom(zClass)) // read an enum ?
+ result = readEnum(zClass);
+
+ else if(Union.class.isAssignableFrom(zClass)) // read a union ?
+ result = readUnion(zClass);
+
+ else if(zClass == Type.class) // read a type ?
+ result = readType();
+
+ else if(XInterface.class.isAssignableFrom(zClass)) // read an interface ?
+ result = readReference(zClass);
+
+ else if(zClass == ThreadID.class) // read a thread id ?
+ result = readThreadID();
+
+ else if(zClass == boolean.class || zClass == Boolean.class) // is it a boolean
+ result = readBoolean();
+
+ else if(zClass == char.class || zClass == Character.class) // is it a character ?)
+ result = readCharacter();
+
+ else if(zClass == byte.class || zClass == Byte.class) // is it a byte ?
+ result = readByte();
+
+ else if(zClass == short.class || zClass == Short.class) // is it a short ?
+ result = readShort();
+
+ else if(zClass == int.class || zClass == Integer.class) // is it an integer ?
+ result = readInteger();
+
+ else if(zClass == long.class || zClass == Long.class) // is it a long ?
+ result = readLong();
+
+ else if(zClass == float.class || zClass == Float.class) // is it a float ?
+ result = readFloat();
+
+ else if(zClass == double.class || zClass == Double.class) // is it a double ?
+ result = readDouble();
+
+ else if(zClass == String.class) // is it a String ?
+ result = readString();
+
+ else if(Throwable.class.isAssignableFrom(zClass)) // is it an exception?
+ result = readThrowable(zClass);
+
+ else // otherwise read a struct
+ result = readStruct(zClass);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readObject:" + zClass + " " + result);
+
+ return result;
+ }
+
+ String readOid() throws Exception {
+ Marshal.M_InterfaceReference m_InterfaceReference = (Marshal.M_InterfaceReference)readObject(Marshal.M_InterfaceReference.class);
+
+ String oid = null;
+
+ if(m_InterfaceReference.cache != (short)0xffff) { // is the cache entry valid ?
+ if(m_InterfaceReference.full.length() > 0) // update the cache?
+ _objectCache[m_InterfaceReference.cache] = m_InterfaceReference.full;
+
+ oid = (String)_objectCache[m_InterfaceReference.cache];
+ }
+ else if(m_InterfaceReference.full.length() > 0) // is the oid entry valid ?
+ oid = m_InterfaceReference.full;
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readOid:" + oid);
+
+ return oid;
+ }
+
+ Object readReference(Class zInterface) throws Exception {
+ Object oid = readOid();;
+
+ // the result is a null ref, in case cache and oid are invalid
+ Object result = null;
+
+ // map the object from universe
+ if(oid != null)
+ result = _iBridge.mapInterfaceFrom(oid, zInterface);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readReference:" + zInterface + " " + result);
+
+ return result;
+ }
+
+ Object readSequence(Class zClass) throws Exception {
+ int size = readCompressedInt();
+ Object result = null;
+
+ zClass = zClass.getComponentType();
+
+ if(zClass == Any.class) // take special care of any array (cause anys are mapped to objects)
+ result = Array.newInstance(Object.class, size);
+ else
+ result = Array.newInstance(zClass, size);
+
+ for(int i = 0; i < size; ++ i)
+ Array.set(result, i, readObject(zClass));
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readSequence:" + result);
+
+ return result;
+ }
+
+ Short readShort() throws Exception {
+ Short result = new Short(_dataInput.readShort());
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readShort:" + result);
+
+ return result;
+ }
+
+ short readshort() throws Exception {
+ short result = _dataInput.readShort();
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readshort:" + result);
+
+ return result;
+ }
+
+ int readCompressedInt() throws Exception {
+ int result = _dataInput.readByte() & 0xff;
+
+ if(result == 255) // if 255 then there follows a complete int
+ result = _dataInput.readInt();
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readCompressedInt:" + result);
+
+ return result;
+ }
+
+ String readString() throws Exception {
+ int utflen = readCompressedInt(); // the size of the string
+
+ byte bytes[] = new byte[utflen];
+ _inputStream.read(bytes);
+
+ return new String(bytes, "UTF8");
+ }
+
+ void readStruct(Class zClass, Object object, Class untilClass) throws Exception {
+ // read inherited members first
+ Class superClass = zClass.getSuperclass();
+ if(superClass != null && superClass != untilClass)
+ readStruct(superClass, object, untilClass);
+
+ Field fields[] = Protocol.__getDeclaredFields(zClass);
+
+ for(int i = 0; i < fields.length; ++ i) {
+ if((fields[i].getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) { // neither static nor transient ?
+ MemberTypeInfo memberTypeInfo = Protocol.__findMemberTypeInfo(zClass, fields[i].getName());
+
+ // default the member type to the declared type
+ Class zInterface = fields[i].getType();
+
+ if(memberTypeInfo != null) {
+ if(memberTypeInfo.isAny()) // is the member an any?
+ if(zInterface.isArray())
+ zInterface = Class.forName("[Lcom.sun.star.uno.Any;");
+ else
+ zInterface = Any.class;
+
+ else if(memberTypeInfo.isInterface()) { // is the member an interface ?
+ Class xInterface = zInterface;
+
+ if(!XInterface.class.isAssignableFrom(fields[i].getType())) // is the member type not derived of XInterface ?
+ xInterface = XInterface.class; // ensure that we get at least an XInterface
+
+ if(zInterface.isArray())
+ zInterface = Class.forName("[L" + xInterface.getName() + ";");
+ else
+ zInterface = xInterface;
+ }
+ }
+
+ fields[i].set(object, readObject(zInterface));
+ }
+ }
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readStruct:" + object);
+ }
+
+ Object readStruct(Class zClass) throws Exception {
+ Object object = zClass.newInstance();
+
+ readStruct(zClass, object, Object.class);
+
+ return object;
+ }
+
+
+ ThreadID readThreadID() throws Exception {
+ Marshal.M_ThreadId m_threadId = (Marshal.M_ThreadId)readObject(Marshal.M_ThreadId.class);
+
+ if( m_threadId.full.length != 0 )
+ _threadIdCache[m_threadId.cache] = new ThreadID(m_threadId.full);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readThreadID:" + _threadIdCache[m_threadId.cache]);
+
+ return _threadIdCache[m_threadId.cache];
+ }
+
+ Type readType() throws Exception {
+ int typeClassValue = _dataInput.readUnsignedByte() & 0xff;
+
+ TypeClass typeClass = TypeClass.fromInt(typeClassValue & 0x7f);
+ Type type = null;
+
+ if(Type.isTypeClassSimple(typeClass)) // is it a simple type?
+ type = new Type(typeClass);
+ else {
+ short index = _dataInput.readShort(); // the cache index
+
+ if((typeClassValue & 0x80) != 0) // update the cache?
+ _typeCache[index] = new Type(typeClass, readString());
+
+ type = _typeCache[index];
+ }
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readType:" + type);
+
+ return type;
+ }
+
+ Union readUnion(Class zClass) throws Exception {
+ throw new Exception("Unmarshal.readUnion - not implemented!!!");
+ }
+
+ void reset(byte bytes[]) {
+ _inputStream = new ByteArrayInputStream(bytes);
+ _dataInput = new DataInputStream(_inputStream);
+ }
+
+ int bytesLeft() throws Exception {
+ return _inputStream.available();
+ }
+}
diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/makefile.mk b/jurt/com/sun/star/lib/uno/protocols/urp/makefile.mk
new file mode 100644
index 000000000000..07670a04353c
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/protocols/urp/makefile.mk
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/lib$/uno$/protocols$/urp
+TARGET = com_sun_star_lib_uno_protocols_urp
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+GENJAVAFILES= \
+ $(MISC)$/java$/com$/sun$/star$/lang$/EventObject.java \
+ $(MISC)$/java$/com$/sun$/star$/lang$/XEventListener.java \
+ $(MISC)$/java$/com$/sun$/star$/uno$/TypeClass.java \
+ $(MISC)$/java$/com$/sun$/star$/beans$/XPropertySet.java \
+ $(MISC)$/java$/com$/sun$/star$/beans$/XPropertySetInfo.java \
+ $(MISC)$/java$/com$/sun$/star$/beans$/UnknownPropertyException.java \
+ $(MISC)$/java$/com$/sun$/star$/beans$/PropertyVetoException.java \
+ $(MISC)$/java$/com$/sun$/star$/beans$/XPropertyChangeListener.java \
+ $(MISC)$/java$/com$/sun$/star$/beans$/XVetoableChangeListener.java \
+ $(MISC)$/java$/com$/sun$/star$/beans$/Property.java \
+ $(MISC)$/java$/com$/sun$/star$/beans$/PropertyChangeEvent.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/urp.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Cache.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Marshal.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Unmarshal.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java
new file mode 100644
index 000000000000..c3ad77fa4fb9
--- /dev/null
+++ b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java
@@ -0,0 +1,621 @@
+/*************************************************************************
+ *
+ * $RCSfile: urp.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.protocols.urp;
+
+import java.lang.reflect.Array;
+
+import java.io.IOException;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+
+import com.sun.star.container.NoSuchElementException;
+
+import com.sun.star.uno.IBridge;
+
+import com.sun.star.lib.uno.environments.remote.IMarshal;
+import com.sun.star.lib.uno.environments.remote.IMessage;
+import com.sun.star.lib.uno.environments.remote.Protocol;
+import com.sun.star.lib.uno.environments.remote.IUnmarshal;
+import com.sun.star.lib.uno.environments.remote.ThreadID;
+
+import com.sun.star.lib.uno.typeinfo.MethodTypeInfo;
+import com.sun.star.lib.uno.typeinfo.TypeInfo;
+
+import com.sun.star.uno.Any;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Type;
+
+
+/**
+ * This class implements the complete urp protocol
+ * from uno. The functionality is reachable through
+ * the <code>IProtocol</code> interface.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:53 $
+ * @author Kay Ramme
+ * @see com.sun.star.lib.uno.environments.remote.IProtocol
+ * @since UDK1.0
+ */
+public class urp extends Protocol {
+ /**
+ * When set to true, enables various debugging output.
+ */
+ static public final boolean DEBUG = false;
+
+ static private final short __cache_size = 256;
+
+
+ protected IBridge _iBridge;
+ protected boolean _bIgnoreNextCloseConnection = false;
+
+ private String _in_oid;
+ private Type _in_interface;
+ private ThreadID _in_threadId;
+
+ private String _out_oid;
+ private Type _out_interface;
+ private ThreadID _out_threadId;
+
+ private Marshal _marshal;
+ private Unmarshal _unmarshal;
+
+ static private final byte BIG_HEADER = (byte)0x80;
+ static private final byte REQUEST = 0x40;
+ static private final byte INTERFACE = 0x20;
+ static private final byte OID = 0x10;
+ static private final byte THREADID = 0x08;
+ static private final byte MID_USHORT = 0x04;
+ static private final byte ONEWAY = 0x02;
+
+ static private final byte DIR_MID = 0x40;
+ static private final byte EXCEPTION = 0x20;
+
+
+
+ public urp(IBridge iBridge) {
+ _iBridge = iBridge;
+
+ _marshal = new Marshal(iBridge, __cache_size);
+ _unmarshal = new Unmarshal(iBridge, __cache_size);
+ }
+
+
+ /**
+ * Returns a string representation of this object.
+ * <p>
+ * @return the string representation
+ * @see java.lang.Object#toString
+ */
+// public String toString() {
+// return getName() + ": statistics - requests send:" + _requestsSend + " requests recieved:" + _requestsRecieved;
+// }
+
+ /**
+ * Gets the name of the protocol.
+ * <p>
+ * @result the name of the protocol (iiop)
+ * @see com.sun.star.lib.uno.environments.remote.IProtocol#getName
+ */
+ public String getName() {
+ return "urp";
+ }
+
+ /**
+ * Tells the protocol to ignore the next <code>closeConnection</code>
+ * meta request.
+ * <p>
+ * @see com.sun.star.lib.uno.environments.remote.IProtocol#ignore_next_closeConnection
+ */
+ public void ignore_next_closeConnection() {
+ _bIgnoreNextCloseConnection = true;
+ }
+
+ /**
+ * Tells the protocol to send a <code>closeConnection</code>
+ * meta request.
+ * <p>
+ * @param outputStream the output stream
+ * @see com.sun.star.lib.uno.environments.remote.IProtocol#send_closeConnection
+ */
+ public void send_closeConnection(OutputStream outputStream) throws IOException {
+ }
+
+ private Object readReply(byte header, boolean exception[]) throws Exception {
+ if((header & THREADID) != 0) // new thread id ?
+ _in_threadId = _unmarshal.readThreadID();
+
+ // get the out signature and parameter array of the reply
+ Object objects[] = (Object[])removePendingRequest(_in_threadId);
+ Object param[] = (Object[])objects[0];
+ Class signature[] = (Class[])objects[1];
+ Class resultClass = (Class)objects[2];
+
+ exception[0] = (header & EXCEPTION) != 0;
+ if(exception[0]) {// Exception? So the reply has an any as the result
+ signature = new Class[0];
+ resultClass = com.sun.star.uno.Any.class;
+ }
+
+ // read the result object
+ Object result = null;
+ if(resultClass != null)
+ result = _unmarshal.readObject(resultClass);
+
+ // read the out parameters
+ for(int i = 0; i < signature.length; ++ i) {
+ if(signature[i] != null) // is this an out parameter
+ Array.set(param[i], 0, _unmarshal.readObject(signature[i].getComponentType()));
+ }
+
+ return result;
+ }
+
+
+ private Object []readParams(MMDesc mMDesc) throws Exception {
+ Object params[] = new Object[mMDesc._in_sig.length];
+
+ for(int i = 0; i < params.length; ++ i) {
+ if(mMDesc._in_sig[i] != null) // is it an in parameter?
+ if(mMDesc._out_sig[i] != null) {// is it also an out -> inout?
+ Object inout = Array.newInstance(mMDesc._out_sig[i].getComponentType(), 1);
+ Array.set(inout, 0, _unmarshal.readObject(mMDesc._out_sig[i].getComponentType()));
+ params[i] = inout;
+ }
+ else // it is only an in parameter
+ params[i] = _unmarshal.readObject(mMDesc._in_sig[i]);
+ else // it is only an out parameter, so provide the holder
+ params[i] = Array.newInstance(mMDesc._out_sig[i].getComponentType(), 1);
+ }
+
+ return params;
+ }
+
+
+ private void readShortRequest(byte header, String operation[], Object param[][], boolean synchron[]) throws Exception {
+ ++ _requestsRecieved;
+
+ int methodId = 0;
+
+ if((header & DIR_MID) != 0)
+ methodId = (((header & 0x3f) << 8) | _unmarshal.readbyte()) & 0x3fff;
+ else
+ methodId = (header & 0x3f);
+
+ MMDesc mMDesc = getMMDesc(_in_interface.getDescription(), methodId);
+ operation[0] = mMDesc._name;
+
+ if(mMDesc._methodTypeInfo == null) // is there a method type info
+ synchron[0] = true; // if not, the default is synchron
+ else
+ synchron[0] = !mMDesc._methodTypeInfo.isOneway();
+
+ param[0] = readParams(mMDesc);
+
+ if(synchron[0]) { // if the request is synchron, it is pending
+ putPendingReply(_in_threadId, new Object[]{param[0], mMDesc._out_sig, mMDesc._res/*, mMDesc*/});
+ }
+ }
+
+ private void readLongRequest(byte header, String operation[], Object param[][], boolean synchron[]) throws Exception {
+ ++ _requestsRecieved;
+
+ // read the method id
+ int methodId = 0;
+ if((header & MID_USHORT) != 0) // usigned short ?
+ methodId = _unmarshal.readshort();
+ else
+ methodId = _unmarshal.readbyte();
+
+ if((header & INTERFACE) != 0)
+ _in_interface = _unmarshal.readType();
+
+ if((header & OID) != 0) // new oid?
+ _in_oid = _unmarshal.readOid();
+
+ if((header & THREADID) != 0) // new thread id ?
+ _in_threadId = _unmarshal.readThreadID();
+
+ MMDesc mMDesc = getMMDesc(_in_interface.getDescription(), methodId);
+
+ operation[0] = mMDesc._name;
+
+ synchron[0] = (header & ONEWAY) == 0;
+
+ param[0] = readParams(mMDesc);
+
+ if(synchron[0]) // if the request is synchron, the reply is pending
+ putPendingReply(_in_threadId, new Object[]{param[0], mMDesc._out_sig, mMDesc._res/*, mMDesc*/});
+ }
+
+ private Object readMessage(String operation[], Object param[], boolean synchron[], boolean exception[]) throws Exception {
+ byte header = _unmarshal.readbyte();
+
+ Class signature[];
+ int methodId;
+ Object result = null;
+
+ if((header & BIG_HEADER) != 0) { // full header?
+ if((header & REQUEST) != 0) // a request ?
+ readLongRequest(header, operation, (Object [][])param, synchron);
+ else // a reply
+ result = readReply(header, exception);
+ }
+ else // only a short request header
+ readShortRequest(header, operation, (Object[][])param, synchron);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readMessage:" + _in_oid + " " + operation[0] + " " + _in_threadId + " " + param[0] + " " + result);
+
+ return result;
+ }
+
+
+ public void writeRequest(String oid, Type zInterface, String operation, ThreadID threadId, Object params[], Boolean synchron[]) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeRequest:" + oid + " " + zInterface + " " + operation);
+
+ ++ _requestsSend;
+
+ synchronized(_marshal) {
+ MMDesc mMDesc = getMMDesc(zInterface.getDescription(), operation);
+
+ byte header = 0;
+ boolean bigHeader = false;
+
+ if(_out_oid == null || !oid.equals(_out_oid)) { // change the oid?
+ header |= OID;
+
+ _out_oid = oid;
+ bigHeader = true;
+ }
+ else
+ oid = null;
+
+
+ if(_out_interface == null || !_out_interface.equals(zInterface)) { // change interface
+ header |= INTERFACE;
+
+ _out_interface = zInterface;
+ bigHeader = true;
+ }
+ else
+ zInterface = null;
+
+ if(_out_threadId == null || !_out_threadId.equals(threadId)) { // change thread id
+ header |= THREADID;
+
+ _out_threadId = threadId;
+
+ bigHeader = true;
+ }
+ else
+ threadId = null;
+
+ // if the type of request is provided, test if it differs from declaration
+ if(synchron[0] != null) {
+ if(mMDesc._methodTypeInfo != null && mMDesc._methodTypeInfo.isOneway() == synchron[0].booleanValue()) {
+ bigHeader = true;
+ }
+ }
+ else if(mMDesc._methodTypeInfo != null) // if the request type is not provided, use the typeInfo if available
+ synchron[0] = new Boolean(!mMDesc._methodTypeInfo.isOneway());
+ else // if no request type provided and no typeInfo available fall back to synchron
+ synchron[0] = new Boolean(true);
+
+
+ if(bigHeader) { // something has changed, send big header
+ header |= BIG_HEADER; // big header
+ header |= REQUEST;
+ header |= synchron[0].booleanValue() ? 0 : ONEWAY;
+
+ if(mMDesc._index > 255)
+ header |= MID_USHORT;
+
+ _marshal.writebyte(header);
+
+ // write the method id
+ if(mMDesc._index > 255)
+ _marshal.writeshort((short)mMDesc._index);
+ else
+ _marshal.writebyte((byte)mMDesc._index);
+
+ if(zInterface != null) // has the interface changed? -> write it
+ _marshal.writeType(zInterface);
+
+ if(oid != null) // has the oid changed? -> write it
+ _marshal.writeOid(_out_oid);
+
+ if(threadId != null) // has the thread id changed? -> write it
+ _marshal.writeThreadID(threadId);
+ }
+ else { // simple request
+ if(mMDesc._index <= 0x2f) // does the method id fit in the header?
+ _marshal.writebyte((byte)mMDesc._index);
+ else { // no
+ header |= DIR_MID;
+ header |= mMDesc._index >> 8;
+
+ _marshal.writebyte(header);
+ _marshal.writebyte((byte)(mMDesc._index & 0xff));
+ }
+ }
+
+ // write the in parameters
+ for(int i = 0; i < mMDesc._in_sig.length; ++ i) {
+ if(mMDesc._in_sig[i] != null) { // is it an in parameter?
+ if(mMDesc._out_sig[i] != null) // is it also an out parameter?
+ _marshal.writeObject(mMDesc._out_sig[i].getComponentType(), ((Object [])params[i])[0]);
+ else // in only
+ _marshal.writeObject(mMDesc._in_sig[i], params[i]);
+ }
+ }
+
+ if(synchron[0].booleanValue()) // if we are waiting for a reply, the reply is pending
+ putPendingRequest(_out_threadId, new Object[]{params, mMDesc._out_sig, mMDesc._res});
+ }
+ }
+
+ public void writeReply(boolean exception, ThreadID threadId, Object result) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeReply:" + exception + " " + threadId + " " + result);
+
+ synchronized(_marshal) {
+ Object objects[] = (Object[])removePendingReply(threadId);
+ Object params[] = (Object[])objects[0];
+ Class signature[] = (Class[])objects[1];
+ Class resClass = (Class)objects[2];
+
+ byte header = BIG_HEADER; // big header
+
+ if(exception) { // has an exception occurred?
+ header |= EXCEPTION;
+
+ signature = new Class[0];
+ resClass = Any.class;
+ }
+
+ if(_out_threadId == null || !_out_threadId.equals(threadId)) { // change thread id ?
+ header |= THREADID;
+
+ _out_threadId = threadId;
+ }
+ else
+ threadId = null;
+
+ _marshal.writebyte(header);
+
+ if(threadId != null) // has the thread id changed? -> write it
+ _marshal.writeThreadID(threadId);
+
+ // write the result
+ _marshal.writeObject(resClass, result);
+
+ // write the out parameters
+ for(int i = 0; i < signature.length; ++ i)
+ if(signature[i] != null)
+ _marshal.writeObject(signature[i].getComponentType(), Array.get(params[i], 0));
+ }
+ }
+
+
+ private byte []readBlock(DataInput dataInput) throws Exception {
+ int size = dataInput.readUnsignedByte();
+ if(size == 0xff)
+ size = dataInput.readInt();
+
+ byte bytes[] = new byte[size];
+
+ dataInput.readFully(bytes);
+
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".readBlock:" + size);
+
+ return bytes;
+ }
+
+ private void writeBlock(DataOutput dataOutput, byte bytes[]) throws Exception {
+ if(DEBUG) System.err.println("##### " + getClass().getName() + ".writeBlock:" + bytes.length);
+
+ if(bytes.length >= 255) {
+ dataOutput.writeByte((byte)0xff);
+ dataOutput.writeInt(bytes.length);
+ }
+ else
+ dataOutput.writeByte((byte)bytes.length);
+
+ dataOutput.write(bytes);
+ }
+
+ static class Message implements IMessage {
+ String _oid;
+ Object _result;
+ Class _interface;
+ String _operation;
+ ThreadID _threadId;
+ boolean _synchron;
+ boolean _exception;
+ Object _params[];
+
+ Message(String oid,
+ Object result,
+ Class zInterface,
+ String operation,
+ ThreadID threadId,
+ boolean synchron,
+ boolean exception,
+ Object params[])
+ {
+ _oid = oid;
+ _result = result;
+ _interface = zInterface;
+ _operation = operation;
+ _threadId = threadId;
+ _synchron = synchron;
+ _exception = exception;
+ _params = params;
+ }
+
+ public String getOperation() {
+ return _operation;
+ }
+
+ public ThreadID getThreadID() {
+ return _threadId;
+ }
+
+ public Class getInterface() {
+ return _interface;
+ }
+
+ public boolean isSynchron() {
+ return _synchron;
+ }
+
+ public boolean isException() {
+ return _exception;
+ }
+
+ public String getOid() {
+ return _oid;
+ }
+
+ public Object getData(Object params[][]) throws Exception {
+ params[0] = _params;
+
+ return _result;
+ }
+ }
+
+ /**
+ * reads a job from the given stream.
+ * <p>
+ * @return thread read job.
+ * @see com.sun.star.lib.uno.environments.remote.Job
+ * @see com.sun.star.lib.uno.environments.remote.IProtocol#readJob
+ */
+ public IMessage readMessage(InputStream inputStream) throws Exception {
+ IMessage iMessage = null;
+
+ while(iMessage == null) { // try hard to get a message
+ if(_unmarshal.bytesLeft() <= 0) { // the last block is empty, get a new one
+ byte bytes[] = readBlock(new DataInputStream(inputStream));
+ _unmarshal.reset(bytes);
+ }
+
+ if(_unmarshal.bytesLeft() == 0) {// we already got a new block and there are still no bytes left? -> close or ignore
+ // (i hope we can rid of this in the nead future
+ if(!_bIgnoreNextCloseConnection)
+ inputStream.close();
+
+ throw new java.io.IOException("connection close message received");
+ }
+ else {
+ String operation[] = new String[1];
+ Object params[][] = new Object[1][];
+ boolean synchron[] = new boolean[1];
+ boolean exception[] = new boolean[1];
+
+ Object result = readMessage(operation, params, synchron, exception);
+
+ if(operation[0] == null) { // a reply ?
+ iMessage = new Message(null, // oid
+ result, // object
+ null, // interface
+ null, // operation
+ _in_threadId,
+ false,
+ exception[0],
+ params[0]);
+ }
+ else { // a request
+ iMessage = new Message(_in_oid,
+ null,
+ _in_interface.getDescription(),
+ operation[0],
+ _in_threadId,
+ synchron[0],
+ false,
+ params[0]);
+ }
+ }
+ }
+
+ return iMessage;
+ }
+
+
+ public void flush(DataOutput dataOutput) throws Exception {
+ writeBlock(dataOutput, _marshal.reset());
+ }
+
+ public IMarshal createMarshal() {
+ return new Marshal(_iBridge, __cache_size);
+ }
+
+ public IUnmarshal createUnmarshal(byte bytes[]) {
+ Unmarshal unmarshal = new Unmarshal(_iBridge, __cache_size);
+ unmarshal.reset(bytes);
+
+ return unmarshal;
+ }
+}
+
diff --git a/jurt/com/sun/star/lib/util/makefile.mk b/jurt/com/sun/star/lib/util/makefile.mk
new file mode 100644
index 000000000000..3da8bf39e0a3
--- /dev/null
+++ b/jurt/com/sun/star/lib/util/makefile.mk
@@ -0,0 +1,83 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/lib$/util
+TARGET = com_sun_star_lib_util
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/IStableListener.class \
+ $(CLASSDIR)$/$(PACKAGE)$/IStableObject.class \
+ $(CLASSDIR)$/$(PACKAGE)$/RefObject.class \
+ $(CLASSDIR)$/$(PACKAGE)$/RefererObject.class \
+ $(CLASSDIR)$/$(PACKAGE)$/WeakTable.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/jurt/com/sun/star/uno/Ascii.java b/jurt/com/sun/star/uno/Ascii.java
new file mode 100644
index 000000000000..7ed1117312c2
--- /dev/null
+++ b/jurt/com/sun/star/uno/Ascii.java
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * $RCSfile: Ascii.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.uno;
+
+/**
+ * The Ascii class represents the IDL build in type <code>ascii</code>.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:53 $
+ * @author Markus Meyer
+ * @since UDK1.0
+ */
+public final class Ascii {
+ public final char ascii;
+
+ /**
+ * Constructs a new <code>Ascii</code>.
+ * <p>
+ * @param c the char value
+ */
+ public Ascii(char c) {
+ ascii = c;
+ }
+}
+
diff --git a/jurt/com/sun/star/uno/AsciiString.java b/jurt/com/sun/star/uno/AsciiString.java
new file mode 100644
index 000000000000..10f6a1baa896
--- /dev/null
+++ b/jurt/com/sun/star/uno/AsciiString.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * $RCSfile: AsciiString.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:54 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.uno;
+
+/**
+ * The Ascii class represents the IDL build in type <code>asciistring</code>.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:54 $
+ * @author Markus Meyer
+ * @since UDK1.0
+ */
+public final class AsciiString {
+ public final String asciistring;
+
+ /**
+ * Constructs a new <code>AsciiString</code>.
+ * <p>
+ * @param s the String value
+ */
+ public AsciiString(String s) {
+ asciistring = s;
+ }
+
+}
+
diff --git a/jurt/com/sun/star/uno/MappingException.java b/jurt/com/sun/star/uno/MappingException.java
new file mode 100644
index 000000000000..1281d3648d6b
--- /dev/null
+++ b/jurt/com/sun/star/uno/MappingException.java
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * $RCSfile: MappingException.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:54 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.uno;
+
+
+/**
+ * The mapping Exception.
+ * <p>
+ * @version $Revision: 1.1.1.1 $ $ $Date: 2000-09-18 15:27:54 $
+ * @author Kay Ramme
+ * @see com.sun.star.uno.UnoRuntime
+ * @see com.sun.star.uno.IQueryInterface
+ * @see com.sun.star.uno.IBridge
+ * @since UDK1.0
+ */
+public class MappingException extends com.sun.star.uno.RuntimeException {
+ /**
+ * Contructs an empty <code>MappingException</code>.
+ */
+ public MappingException() {
+ super();
+ }
+
+ /**
+ * Contructs an <code>MappingException</code> with a detail message.
+ * <p>
+ * @param message the detail message.
+ */
+ public MappingException(String message) {
+ super(message);
+ }
+
+ /**
+ * Contructs an <code>MappingException</code> with a detail message
+ * and a context.
+ * <p>
+ * @param message the detail message.
+ * @param context the context.
+ */
+ public MappingException(String message, Object context) {
+ super(message, context);
+ }
+}
+
+
diff --git a/jurt/com/sun/star/uno/makefile.mk b/jurt/com/sun/star/uno/makefile.mk
new file mode 100644
index 000000000000..d1f7879d159d
--- /dev/null
+++ b/jurt/com/sun/star/uno/makefile.mk
@@ -0,0 +1,103 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:54 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..
+PRJNAME = jurt
+PACKAGE = com$/sun$/star$/uno
+TARGET = com_sun_star_uno
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+GENJAVAFILES = \
+ $(MISC)$/java$/$(PACKAGE)$/Exception.java \
+ $(MISC)$/java$/$(PACKAGE)$/RuntimeException.java \
+ $(MISC)$/java$/$(PACKAGE)$/TypeClass.java \
+ $(MISC)$/java$/$(PACKAGE)$/Uik.java \
+ $(MISC)$/java$/$(PACKAGE)$/XInterface.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/Any.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Ascii.class \
+ $(CLASSDIR)$/$(PACKAGE)$/AsciiString.class \
+ $(CLASSDIR)$/$(PACKAGE)$/BridgeTurner.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Enum.class \
+ $(CLASSDIR)$/$(PACKAGE)$/IBridge.class \
+ $(CLASSDIR)$/$(PACKAGE)$/IEnvironment.class \
+ $(CLASSDIR)$/$(PACKAGE)$/IQueryInterface.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Mapping.class \
+ $(CLASSDIR)$/$(PACKAGE)$/MappingException.class \
+ $(CLASSDIR)$/$(PACKAGE)$/MappingWrapper.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Type.class \
+ $(CLASSDIR)$/$(PACKAGE)$/Union.class \
+ $(CLASSDIR)$/$(PACKAGE)$/UnoRuntime.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+doc:
+ pwd
+ cd $(PRJ) && javadoc -sourcepath /usr/local/java/src:unxlngi3.pro/japi:.:../jlibs com.sun.star.lib.util com.sun.star.uno com.sun.star.lib.uno.typeinfo com.sun.star.lib.uno.environments.java com.sun.star.lib.uno.environments.remote com.sun.star.lib.uno.protocols.iiop com.sun.star.lib.uno.bridges.java_remote com.sun.star.comp.loader com.sun.star.comp.connections -d unxlngi3.pro/doc
diff --git a/jurt/demo/com/sun/star/demo/DemoServer.java b/jurt/demo/com/sun/star/demo/DemoServer.java
new file mode 100644
index 000000000000..21c551c56a1a
--- /dev/null
+++ b/jurt/demo/com/sun/star/demo/DemoServer.java
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * $RCSfile: DemoServer.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:54 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+package com.sun.star.demo;
+
+import com.sun.star.bridge.XBridge;
+import com.sun.star.bridge.XBridgeFactory;
+import com.sun.star.bridge.XInstanceProvider;
+
+import com.sun.star.comp.servicemanager.ServiceManager;
+
+import com.sun.star.connection.XAcceptor;
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.uno.UnoRuntime;
+
+public class DemoServer {
+ static String neededServices[] = new String[] {
+ "com.sun.star.comp.servicemanager.ServiceManager",
+ "com.sun.star.comp.loader.JavaLoader",
+ "com.sun.star.comp.connections.Acceptor",
+ "com.sun.star.comp.bridgefactory.BridgeFactory"
+ };
+
+ static class InstanceProvider implements XInstanceProvider {
+ public Object getInstance( /*IN*/String sInstanceName ) throws com.sun.star.container.NoSuchElementException, com.sun.star.uno.RuntimeException {
+ System.err.println("##### " + getClass().getName() + ".getInstance:" + sInstanceName);
+
+ return null;
+ }
+ }
+
+ static public void main(String args[]) throws Exception {
+ if(args.length != 1) {
+ System.err.println("usage : SCalc uno:connection;protocol;objectName");
+ System.exit(-1);
+ }
+
+ String conDcp = null;
+ String protDcp = null;
+ String rootOid = null;
+
+ String dcp = args[0];
+
+ if(dcp.indexOf(';') == -1) {// use old style
+ conDcp = dcp;
+ protDcp = "iiop";
+ rootOid = "classic_uno";
+ }
+ else { // new style
+ int index = dcp.indexOf(':');
+ String url = dcp.substring(0, index).trim();
+ dcp = dcp.substring(index + 1).trim();
+
+ index = dcp.indexOf(';');
+ conDcp = dcp.substring(0, index).trim();
+ dcp = dcp.substring(index + 1).trim();
+
+ index = dcp.indexOf(';');
+ protDcp = dcp.substring(0, index).trim();
+ dcp = dcp.substring(index + 1).trim();
+
+ rootOid = dcp.trim().trim();
+ }
+
+ ServiceManager serviceManager = new ServiceManager();
+ serviceManager.addFactories(neededServices);
+
+ XAcceptor xAcceptor = (XAcceptor)UnoRuntime.queryInterface(XAcceptor.class, serviceManager.createInstance("com.sun.star.connection.Acceptor"));
+
+ System.err.println("waiting for connect...");
+ XConnection xConnection = xAcceptor.accept(conDcp);
+
+ XBridgeFactory xBridgeFactory = (XBridgeFactory)UnoRuntime.queryInterface(XBridgeFactory.class, serviceManager.createInstance("com.sun.star.bridge.BridgeFactory"));
+ XBridge xBridge = xBridgeFactory.createBridge(conDcp + ";" + protDcp, protDcp, xConnection, new InstanceProvider());
+
+ }
+}
diff --git a/jurt/demo/com/sun/star/demo/TestOffice.java b/jurt/demo/com/sun/star/demo/TestOffice.java
new file mode 100644
index 000000000000..21e633657cf2
--- /dev/null
+++ b/jurt/demo/com/sun/star/demo/TestOffice.java
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * $RCSfile: TestOffice.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:54 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.demo;
+
+
+import java.io.IOException;
+
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+
+import com.sun.star.io.BufferSizeExceededException;
+import com.sun.star.io.NotConnectedException;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XOutputStream;
+
+import com.sun.star.frame.XComponentLoader;
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+
+import com.sun.star.text.XSimpleText;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextRange;
+
+import com.sun.star.uno.IBridge;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.XNamingService;
+
+
+public class TestOffice {
+ static void testPipe(XMultiServiceFactory rSmgr) throws com.sun.star.uno.Exception {
+ XOutputStream rOut = (XOutputStream) rSmgr.createInstance("com.sun.star.io.Pipe");
+
+ {
+ byte bytes[] = new byte[10];
+ bytes[0] = 42;
+ rOut.writeBytes(bytes);
+ }
+
+
+ {
+ byte bytes[][] = new byte[1][];
+
+ XInputStream rIn = (XInputStream)UnoRuntime.queryInterface(XInputStream.class, rOut);
+ if(rIn.available() != 10)
+ System.err.println("wrong bytes available\n");
+
+ if(rIn.readBytes(bytes, 10) != 10)
+ System.err.println("wrong bytes read\n");
+
+ if(42 != bytes[0][0])
+ System.err.println("wrong element in sequence\n");
+ }
+ }
+
+
+ static void testWriter(XComponent rCmp) throws IOException {
+ XTextDocument rTextDoc = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, rCmp);
+
+ XText rText = (XText)UnoRuntime.queryInterface(XText.class, rTextDoc.getText());
+ XTextCursor rCursor = (XTextCursor)UnoRuntime.queryInterface(XTextCursor.class, rText.createTextCursor());
+ XTextRange rRange = (XTextRange)UnoRuntime.queryInterface(XTextRange.class, rCursor);
+
+ byte pcText[] = new byte[1024];
+ pcText[0] = 0;
+ System.err.println("pleast type any text\n");
+ while(true) {
+ System.in.read(pcText);
+
+ String string = new String(pcText);
+ if(string.equals("end")) break;
+
+ string += " ";
+
+ rText.insertString(rRange , string, false);
+ }
+ }
+
+ static void testDocument(XMultiServiceFactory rSmgr) throws com.sun.star.uno.Exception, IOException {
+ XComponentLoader rLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, rSmgr.createInstance("com.sun.star.frame.Desktop"));
+
+ String urls[] = new String[] {
+ "private:factory/swriter",
+ "private:factory/scalc",
+ "private:factory/sdraw",
+ "http://www.heise.de",
+ };
+
+ String docu[] = new String[] {
+ "a new writer document ...\n",
+ "a new calc document ...\n",
+ "a new draw document ...\n",
+ "www.heise.de\n",
+ };
+
+ for(int i = 0; i < urls.length; ++ i) {
+ System.err.println("press any key to open " + docu[i]);
+
+ System.in.read();
+ while(System.in.available() > 0)
+ System.in.read();
+
+ XComponent rComponent = rLoader.loadComponentFromURL(urls[i], "_blank", 0, new PropertyValue[0]);
+
+// testWriter(rComponent);
+ System.err.println("press any key to close the document");
+ System.in.read();
+ while(System.in.available() > 0)
+ System.in.read();
+
+ rComponent.dispose();
+ }
+ }
+
+ static void doSomething(Object r) throws com.sun.star.uno.Exception, IOException {
+ XNamingService rName = (XNamingService)UnoRuntime.queryInterface(XNamingService.class, r);
+
+ if(rName != null) {
+ System.err.println("got the remote naming service !");
+ Object rXsmgr = rName.getRegisteredObject("StarOffice.ServiceManager");
+
+ XMultiServiceFactory rSmgr = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, rXsmgr);
+ if(rSmgr != null) {
+ System.err.println("got the remote service manager !");
+// testPipe(rSmgr);
+ testDocument(rSmgr);
+ }
+ }
+ }
+
+
+
+ static String neededServices[] = new String[] {
+ "com.sun.star.comp.servicemanager.ServiceManager",
+ "com.sun.star.comp.loader.JavaLoader",
+ "com.sun.star.comp.connections.Connector",
+ "com.sun.star.comp.bridgefactory.BridgeFactory",
+ "com.sun.star.comp.urlresolver.UrlResolver"
+ };
+
+ public static void main(String argv[]) throws Exception {
+ if(argv.length != 1) {
+ System.err.println("usage : testoffice uno:connection;protocol;objectName");
+ System.exit(-1);
+ }
+
+ com.sun.star.comp.servicemanager.ServiceManager smgr = new com.sun.star.comp.servicemanager.ServiceManager();
+ smgr.addFactories(neededServices);
+
+ Object resolver = smgr.createInstance("com.sun.star.bridge.UnoUrlResolver" );
+ XUnoUrlResolver resolver_xUnoUrlResolver = (XUnoUrlResolver)UnoRuntime.queryInterface(XUnoUrlResolver.class, resolver);
+
+ Object rInitialObject = resolver_xUnoUrlResolver.resolve(argv[0]);
+
+ if(rInitialObject != null) {
+ System.err.println("got the remote object");
+ doSomething(rInitialObject);
+ }
+ }
+}
+
diff --git a/jurt/demo/com/sun/star/demo/makefile.mk b/jurt/demo/com/sun/star/demo/makefile.mk
new file mode 100644
index 000000000000..a05978e13c73
--- /dev/null
+++ b/jurt/demo/com/sun/star/demo/makefile.mk
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:54 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..$/..
+
+PRJNAME := jurt
+PACKAGE := com$/sun$/star$/demo
+TARGET := com_sun_star_demo
+
+RDB=$(SOLARBINDIR)$/applicat.rdb
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+#Files --------------------------------------------------------
+
+JARFILES = sandbox.jar unoil.jar
+
+GENJAVACLASSFILES =
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/SCalc.class \
+ $(CLASSDIR)$/$(PACKAGE)$/SDraw.class \
+ $(CLASSDIR)$/$(PACKAGE)$/SWriter.class \
+ $(CLASSDIR)$/$(PACKAGE)$/TestOffice.class
+
+TYPES={$(subst,.class, $(subst,$/,. $(subst,$(CLASSDIR)$/,-T $(GENJAVACLASSFILES))))}
+GENJAVAFILES = {$(subst,.class,.java $(subst,$/class, $(GENJAVACLASSFILES)))}
+
+JAVAFILES= $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES))) $(GENJAVAFILES)
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : target.mk
diff --git a/jurt/prj/d.lst b/jurt/prj/d.lst
new file mode 100644
index 000000000000..1c048acad62b
--- /dev/null
+++ b/jurt/prj/d.lst
@@ -0,0 +1 @@
+..\%__SRC%\class\jurt.jar %_DEST%\bin%_EXT%\jurt.jar
diff --git a/jurt/test/com/sun/star/comp/connections/PipedConnection_Test.java b/jurt/test/com/sun/star/comp/connections/PipedConnection_Test.java
new file mode 100644
index 000000000000..280e24854c93
--- /dev/null
+++ b/jurt/test/com/sun/star/comp/connections/PipedConnection_Test.java
@@ -0,0 +1,187 @@
+/*************************************************************************
+ *
+ * $RCSfile: PipedConnection_Test.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:54 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.comp.connections;
+
+
+import java.util.Vector;
+
+
+public class PipedConnection_Test {
+ static class Reader extends Thread {
+ PipedConnection _pipedConnection;
+ byte _theByte[];
+ boolean _quit;
+ boolean _state = false;
+
+ Reader(PipedConnection pipedConnection, byte theByte[]) {
+ _pipedConnection = pipedConnection;
+ _theByte = theByte;
+ }
+
+ public void run() {
+ try {
+ byte bytes[][] = new byte[1][];
+
+ while(!_quit) {
+ int read = _pipedConnection.read(bytes, 1);
+
+ if(read == 1) {
+// System.err.println("read :" + bytes[0][0]);
+
+ if(_theByte[0] != bytes[0][0])
+ throw new NullPointerException();
+
+ synchronized(this) {
+ notifyAll();
+ }
+ }
+ else
+ _quit = true; // EOF
+ }
+
+ _pipedConnection.close();
+ _state = true;
+ }
+ catch(com.sun.star.io.IOException ioException) {
+ System.err.println("#### Reader - unexpected:" + ioException);
+ }
+
+ }
+ }
+
+ static class Writer extends Thread {
+ PipedConnection _pipedConnection;
+ byte _theByte[];
+ Reader _reader;
+ boolean _quit;
+ boolean _state = false;
+
+ Writer(PipedConnection pipedConnection, byte theByte[], Reader reader) {
+ _pipedConnection = pipedConnection;
+ _reader = reader;
+ _theByte = theByte;
+ }
+
+ public void run() {
+ try {
+ while(!_quit) {
+ synchronized(_reader) {
+ _pipedConnection.write(_theByte);
+ _pipedConnection.flush();
+// System.err.println("written :" + _theByte[0]);
+
+ _reader.wait();
+ }
+ ++ _theByte[0];
+ }
+
+ _pipedConnection.close();
+
+ _state = true;
+ }
+ catch(com.sun.star.io.IOException ioException) {
+ System.err.println("#### Writer:" + ioException);
+ }
+ catch(InterruptedException interruptedException) {
+ System.err.println("#### Writer:" + interruptedException);
+ }
+ }
+
+ public void term() {
+ _quit = true;
+ }
+ }
+
+ static public boolean test(Vector notpassed) throws Exception {
+ System.err.println("\tTesting PipedConnection...");
+
+ PipedConnection rightSide = new PipedConnection(new Object[0]);
+ PipedConnection leftSide = new PipedConnection(new Object[]{rightSide});
+
+ byte theByte[] = new byte[1];
+
+ Reader reader = new Reader(rightSide, theByte);
+ Writer writer = new Writer(leftSide, theByte, reader);
+
+ reader.start();
+ writer.start();
+
+ Thread.sleep(2000);
+
+ writer.term();
+ writer.join();
+
+ reader.join();
+
+ boolean passed = writer._state && reader._state;
+
+ System.err.println("PipedConnection - passed? " + passed + " transmitted:" + theByte[0]);
+ if(!passed)
+ notpassed.addElement("PipedConnection - passed? " + passed + " transmitted:" + theByte[0]);
+
+ return passed;
+ }
+
+ static public void main(String argv[]) throws Exception {
+ test(null);
+ }
+}
diff --git a/jurt/test/com/sun/star/comp/connections/makefile.mk b/jurt/test/com/sun/star/comp/connections/makefile.mk
new file mode 100644
index 000000000000..d0070b2c34ea
--- /dev/null
+++ b/jurt/test/com/sun/star/comp/connections/makefile.mk
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:54 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..$/..$/..
+
+PRJNAME := jurt
+PACKAGE := com$/sun$/star$/comp$/connections
+TARGET := test_com_sun_star_comp_connections
+
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+
+# Files --------------------------------------------------------
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/PipedConnection_Test.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java b/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java
new file mode 100644
index 000000000000..59f9cbf97c40
--- /dev/null
+++ b/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * $RCSfile: java_remote_bridge_Test.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:55 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.bridges.java_remote;
+
+
+import java.io.IOException;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+
+import java.lang.reflect.InvocationTargetException;
+
+import java.util.Vector;
+
+
+import com.sun.star.bridge.XInstanceProvider;
+
+import com.sun.star.comp.connections.PipedConnection;
+
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.uno.IEnvironment;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.lib.uno.environments.java.java_environment;
+import com.sun.star.lib.uno.environments.java.Proxy;
+
+import com.sun.star.lib.uno.environments.remote.IProtocol;
+
+
+public class java_remote_bridge_Test {
+ static IEnvironment __java_environment_A;
+ static IEnvironment __java_environment_B;
+
+ static java_remote_bridge __java_remote_bridge_A;
+ static java_remote_bridge __java_remote_bridge_B;
+
+ static PipedConnection __xConnection_A;
+ static PipedConnection __xConnection_B;
+
+ static XInstanceProvider __xInstanceProvider;
+
+ static byte __bytes[] = new byte[] {(byte)255, (byte)0, (byte)128};
+
+ static boolean test_lifecycle(int objects) throws Exception {
+ System.err.println("\tjava_remote_bridge - testing lifecycle...");
+
+ boolean passed = true;
+
+// XInterface theProxy = (XInterface)__java_remote_bridge_B.mapInterfaceFrom("testinstance", XInterface.class); // map the instance back from oid world to Bs real world
+ XInterface theProxy = (XInterface)Proxy.create(__java_remote_bridge_B, "testinstance", XInterface.class, true);
+
+
+ TestInterface theProxy_TestInterfaces[] = new TestInterface[objects];
+
+ for(int i = 0; i < objects; ++ i) {
+ theProxy_TestInterfaces[i] = (TestInterface)com.sun.star.uno.UnoRuntime.queryInterface(TestInterface.class, theProxy);
+
+ theProxy_TestInterfaces[i].function(); // call the function
+ }
+
+ System.err.println("\t\tobject method called " + TestInterface_Object.__called + " times, should be " + objects + " - passed?" + (TestInterface_Object.__called == objects));
+
+
+ System.err.println("\t\tbridge A life count: " + __java_remote_bridge_A.getLifeCount() + " should be " + objects + " - passed?" + (__java_remote_bridge_A.getLifeCount() == objects));
+ passed = passed && (__java_remote_bridge_A.getLifeCount() == objects);
+ System.err.println("\t\tbridge B life count: " + __java_remote_bridge_B.getLifeCount() + " should be " + objects + " - passed?" + (__java_remote_bridge_B.getLifeCount() == objects));
+ passed = passed && (__java_remote_bridge_B.getLifeCount() == objects);
+ System.err.println("\t\tproxy count:" + Proxy.getInstances() + " should be " + (objects + 1) + " - passed?" + (Proxy.getInstances() == (objects + 1)));
+ passed = passed && (Proxy.getInstances() == (objects + 1));
+
+ theProxy = null;
+ theProxy_TestInterfaces = null;
+
+ System.err.println("\t\twaiting for gc to clear all proxies");
+ while(Proxy.getInstances() > 0) { // try to force proxy recycling
+ System.gc();
+ System.runFinalization();
+
+ byte bytes[] = new byte[1024];
+ }
+
+ IProtocol protocol_A = __java_remote_bridge_A.getProtocol();
+ IProtocol protocol_B = __java_remote_bridge_B.getProtocol();
+
+ System.err.println("\t\twaiting for pending messages to be done");
+ while(protocol_B.getRequestsSendCount() > protocol_A.getRequestsReceivedCount()) {// wait while messages are pending
+ System.err.println("pending:" + (protocol_B.getRequestsSendCount() - protocol_A.getRequestsReceivedCount()));
+ Thread.sleep(100);
+ }
+ System.err.println("\t\tbridge A life count: " + __java_remote_bridge_A.getLifeCount() + " should be 0" + " - passed?" + (__java_remote_bridge_A.getLifeCount() == 0));
+ passed = passed && (__java_remote_bridge_A.getLifeCount() == 0);
+ System.err.println("\t\tbridge B life count: " + __java_remote_bridge_B.getLifeCount() + " should be 0" + " - passed?" + (__java_remote_bridge_B.getLifeCount() == 0));
+ passed = passed && (__java_remote_bridge_B.getLifeCount() == 0);
+ System.err.println("\t\tproxy count:" + Proxy.getInstances() + " should be 0" + " - passed?" + (Proxy.getInstances() == 0));
+ passed = passed && (Proxy.getInstances() == 0);
+
+
+ // both bridges should be disposed now
+
+ return passed;
+ }
+
+
+ static boolean test_releasing_of_outmapped_objects() throws InterruptedException {
+ System.err.println("\tjava_remote_bridge - testing release of outmapped objects - not implemented yet");
+
+ return true;
+ }
+
+ static public boolean test(Vector notpassed, String protocol) throws Exception {
+ System.err.println("java_remote_bridge - testing with protocol: " + protocol + "...");
+ __xConnection_A = new PipedConnection(new Object[0]);
+ __xConnection_B = new PipedConnection(new Object[]{__xConnection_A});
+
+ __java_environment_A = new java_environment(null);
+ __java_environment_B = new java_environment(null);
+
+
+ class yXInstanceProvider implements XInstanceProvider {
+ public Object getInstance(String name) throws com.sun.star.container.NoSuchElementException, com.sun.star.uno.RuntimeException {
+// System.err.println("\t\tTest_XInstanceProvider.getInstance:" + name);
+ return new TestInterface_Object(); // create the instance, which is to be mapped from A to B
+ }
+ }
+
+ __xInstanceProvider = new yXInstanceProvider();
+
+ __java_remote_bridge_A = new java_remote_bridge(__java_environment_A, null, new Object[]{protocol, __xConnection_A, __xInstanceProvider});
+ __java_remote_bridge_B = new java_remote_bridge(__java_environment_B, null, new Object[]{protocol, __xConnection_B, null});
+// __java_remote_bridge_A = new java_remote_bridge(__java_environment_A, null, new Object[]{"iiop", __xConnection_A, __xInstanceProvider});
+// __java_remote_bridge_B = new java_remote_bridge(__java_environment_B, null, new Object[]{"iiop", __xConnection_B, null});
+
+ boolean passed = test_lifecycle(100);
+ passed = passed && test_releasing_of_outmapped_objects();
+
+ System.err.println("java_remote_bridge_Test - " + protocol + " test passed?" + passed);
+ if(!passed && notpassed != null)
+ notpassed.addElement("java_remote_bridge_Test - " + protocol + " test passed?" + passed);
+
+ return passed;
+ }
+
+ static public void main(String args[]) throws Exception {
+ if(args.length == 1)
+ test(null, args[0]);
+ else
+ test(null, "iiop");
+
+// System.exit(0);
+ }
+}
+
diff --git a/jurt/test/com/sun/star/lib/uno/bridges/java_remote/makefile.mk b/jurt/test/com/sun/star/lib/uno/bridges/java_remote/makefile.mk
new file mode 100644
index 000000000000..3d2f8eb252cc
--- /dev/null
+++ b/jurt/test/com/sun/star/lib/uno/bridges/java_remote/makefile.mk
@@ -0,0 +1,88 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:55 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..$/..$/..$/..$/..
+
+PRJNAME := jurt
+PACKAGE := com$/sun$/star$/lib$/uno$/bridges$/java_remote
+TARGET := test_com_sun_star_lib_uno_bridges_java_remote
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# Files --------------------------------------------------------
+
+
+GENJAVAFILES= \
+ $(MISC)$/java$/com$/sun$/star$/bridge$/XBridge.java
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/TestInterface.class \
+ $(CLASSDIR)$/$(PACKAGE)$/TestInterface_Object.class \
+ $(CLASSDIR)$/$(PACKAGE)$/java_remote_bridge_Test.class
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
diff --git a/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java b/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java
new file mode 100644
index 000000000000..8e1957ee7dde
--- /dev/null
+++ b/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: java_environment_Test.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:55 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+package com.sun.star.lib.uno.environments.java;
+
+
+import java.util.Vector;
+
+
+import com.sun.star.uno.XInterface;
+
+
+public class java_environment_Test {
+ static public boolean test(Vector notpassed) throws Exception {
+ boolean passed = true;
+
+ System.err.println("java_environment - doing tests...");
+
+ java_environment env = new java_environment(null);
+
+ Object obj = new Integer(3);
+ String oid[] = new String[1];
+
+ System.err.println("\tregistering ordinary interface twice...");
+ Object obj2 = env.registerInterface(obj, oid, XInterface.class, null);
+ Object obj3 = env.registerInterface(obj, oid, XInterface.class, null);
+
+ passed = passed && (obj == obj2) && (obj == obj3);
+
+// env.list();
+
+ System.err.println("\tasking for registered interface...");
+ passed = passed && (obj == env.getRegisteredInterface(oid[0], XInterface.class, null));
+
+
+ System.err.println("\trevoking interface...");
+ env.revokeInterface(oid[0], XInterface.class);
+ env.revokeInterface(oid[0], XInterface.class);
+
+ passed = passed && (null == env.getRegisteredInterface(oid[0], XInterface.class, null));
+
+ System.err.println("java_environment - tests passed? " + passed);
+
+ if(!passed && notpassed != null)
+ notpassed.addElement("java_environment - tests passed? " + passed);
+
+
+ return passed;
+ }
+
+ static public void main(String args[]) throws Exception{
+ test(null);
+ }
+}
diff --git a/jurt/test/com/sun/star/lib/uno/environments/java/makefile.mk b/jurt/test/com/sun/star/lib/uno/environments/java/makefile.mk
new file mode 100644
index 000000000000..3d2d663759e0
--- /dev/null
+++ b/jurt/test/com/sun/star/lib/uno/environments/java/makefile.mk
@@ -0,0 +1,87 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:55 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..$/..$/..$/..$/..
+
+PRJNAME := jurt
+PACKAGE := com$/sun$/star$/lib$/uno$/environments$/java
+TARGET := test_com_sun_star_lib_uno_environments_java
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# Files --------------------------------------------------------
+
+
+GENJAVAFILES= \
+ $(MISC)$/java$/com$/sun$/star$/uno$/XInterface.java
+
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/java_environment_Test.class
+
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
diff --git a/jurt/test/com/sun/star/lib/uno/environments/remote/JobQueue_Test.java b/jurt/test/com/sun/star/lib/uno/environments/remote/JobQueue_Test.java
new file mode 100644
index 000000000000..7cce4894ec7c
--- /dev/null
+++ b/jurt/test/com/sun/star/lib/uno/environments/remote/JobQueue_Test.java
@@ -0,0 +1,412 @@
+/*************************************************************************
+ *
+ * $RCSfile: JobQueue_Test.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:55 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.remote;
+
+
+import java.util.Vector;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import com.sun.star.uno.IEnvironment;
+import com.sun.star.uno.UnoRuntime;
+
+
+public class JobQueue_Test {
+ static interface MyInterface {
+ int getNext();
+
+ Object syncCall(Object param) throws Exception;
+ Object asyncCall(Object param) throws Exception;
+ }
+
+ static class MyContext {
+ }
+
+ static class MyImpl implements MyInterface {
+ int _received_requestId;
+ int _send_requestId;
+ boolean _passed = true;
+ Object _context = new MyContext();
+
+ public int getNext() {
+ return _send_requestId ++;
+ }
+
+ public Object doSomething(Object param) throws InterruptedException {
+ // synchronized(this) {
+// long waitTime = (long)(Math.random() * 100);
+// if(waitTime > 0)
+// wait(waitTime); // simulate work
+// }
+
+ _passed = _passed && (((Integer)param).intValue() == _received_requestId);
+
+ if(!_passed)
+ throw new NullPointerException("blblbl");
+
+ ++ _received_requestId;
+
+
+// synchronized(this) {
+// long waitTime = (long)(Math.random() * 100);
+// if(waitTime > 0)
+// wait(waitTime); // simulate work
+// }
+
+ return "blabla";
+ }
+
+ public Object syncCall(Object param) throws Exception{
+ Object object = doSomething(param);
+
+ // send a request to ourself
+
+ ThreadPool.addThread(_context);
+ Job job = new Job(new MyReceiver(null), // receiver
+ new MyMessage(true,
+ MyInterface.class,
+ UnoRuntime.generateOid(this),
+ JavaThreadPool.getThreadId(Thread.currentThread()),
+ this,
+ null,
+ null));
+
+ ThreadPool.putJob(job, null);
+// System.err.println("entering ...");
+ ThreadPool.enter();
+// System.err.println("left");
+
+ return object;
+
+ }
+
+ public Object asyncCall(Object param) throws Exception {
+ return doSomething(param);
+ }
+
+ void finish() {
+ _passed = _passed && (_send_requestId == _received_requestId);
+ }
+ }
+
+
+ // this is for testing dispose
+ static class MyImpl2 implements MyInterface {
+ int _received_requestId;
+ int _send_requestId;
+ boolean _passed = true;
+ Object _context = new MyContext();
+
+
+ public int getNext() {
+ return _send_requestId ++;
+ }
+
+ boolean waitForException() {
+ boolean result = false;
+
+ try {
+ synchronized(this) {
+ notify(); // notify the tester that we entered the call
+ wait(); // wait for tester to tell us to leave
+ }
+ }
+ catch(InterruptedException interruptedException) {
+ result = true;
+ }
+
+ return result;
+ }
+
+ public Object syncCall(Object param) throws Exception{
+ System.err.println("\tsyncCall - waiting for exception...");
+ boolean occurred = waitForException();
+ System.err.println("\toccurred (should):" + occurred);
+
+ _passed = _passed && occurred;
+
+ synchronized(this) {
+ notify();
+ }
+
+ return "hallo";
+ }
+
+ public Object asyncCall(Object param) throws Exception {
+ System.err.println("\tasyncCall - waiting for exception...");
+ boolean occurred = waitForException();
+ System.err.println("\toccurred (should not):" + occurred);
+
+ _passed = _passed && !occurred;
+
+ synchronized(this) {
+ notify();
+ }
+
+ return "hallo";
+ }
+ }
+
+
+
+
+ static void sendAsyncJobs(int jobs, JobQueue jobQueue, MyReceiver myReceiver, ThreadID threadID, MyInterface myImpl, Object context) {
+ // sending asynchrones calls
+ System.err.println("\tsending " + jobs + " asynchrones calls...");
+
+ for(int i = 0; i < jobs; ++ i) {
+ MyMessage myMessage = new MyMessage(false,
+ MyInterface.class,
+ UnoRuntime.generateOid(myImpl),
+ threadID,
+ myImpl,
+ "asyncCall",
+ new Object[]{new Integer(myImpl.getNext())});
+
+ Job job = new Job(myReceiver, myMessage);
+
+ jobQueue.putJob(job, context);
+ }
+ }
+
+ static void sendSyncJobs(int jobs, JobQueue jobQueue, MyReceiver myReceiver, ThreadID threadID, MyInterface myImpl, Thread thread, Object context, boolean wait) throws Exception {
+ // sending synchronous calls
+ System.err.println("\tsending " + jobs + " synchrones calls...");
+
+ for(int i = 0; i < jobs; ++ i) {
+ MyMessage myMessage = new MyMessage(true,
+ MyInterface.class,
+ UnoRuntime.generateOid(myImpl),
+ threadID,
+ myImpl,
+ "syncCall",
+ new Object[]{new Integer(myImpl.getNext())});
+
+
+ Job job_do = new Job(myReceiver, myMessage);
+
+ job_do._disposeId = context;
+ if(thread == null) {
+ synchronized(myReceiver) {
+ jobQueue.putJob(job_do, context);
+
+ if(wait) { // wait for the answer?
+ myReceiver.wait();
+ }
+ }
+ }
+ else {
+ jobQueue.putJob(job_do, context);
+
+ myMessage = new MyMessage(true,
+ MyInterface.class,
+ UnoRuntime.generateOid(myImpl),
+ threadID,
+ myImpl,
+ null,
+ null);
+ Job job_return = new Job(myReceiver, myMessage);
+
+ jobQueue.putJob(job_return, context);
+ jobQueue.enter(context);
+ }
+ }
+ }
+
+ static public boolean test_without_thread() throws Exception { // this is like sending jobs from remote
+ boolean passed[] = new boolean[]{true};
+
+ System.err.println("doing test_without_thread ...");
+
+ ThreadID threadID = new ThreadID("test_thread_id".getBytes());
+
+ Object context = new MyContext();
+
+ JobQueue jobQueue = new JobQueue(threadID, true);
+ MyImpl myImpl = new MyImpl();
+ MyReceiver myReceiver = new MyReceiver(passed);
+
+ do {
+ sendAsyncJobs((int)(Math.random() * 10 + 1), jobQueue, myReceiver, threadID, myImpl, context);
+ sendSyncJobs((int)(Math.random() * 10 + 1), jobQueue, myReceiver, threadID, myImpl, null, context, true);
+ sendAsyncJobs((int)(Math.random() * 10 + 1), jobQueue, myReceiver, threadID, myImpl, context);
+ sendSyncJobs((int)(Math.random() * 10 + 1), jobQueue, myReceiver, threadID, myImpl, null, context, true);
+ }
+ while(Math.random() > 0.25);
+
+
+ myImpl.finish();
+
+ passed[0] = passed[0] && myImpl._passed;
+
+ System.err.println("test_without_thread - passed? " + passed[0]);
+
+ jobQueue.printStats();
+
+ return passed[0];
+ }
+
+ static public boolean test_with_thread() throws Exception {
+ boolean passed[] = new boolean[]{true};
+
+ System.err.println("doing test_with_thread ...");
+
+ ThreadID threadID = new ThreadID("test_thread_id".getBytes());
+
+ Object context = new MyContext();
+
+ Thread thread = Thread.currentThread();
+
+ JobQueue jobQueue = new JobQueue(threadID, false);
+ MyImpl myImpl = new MyImpl();
+ MyReceiver myReceiver = new MyReceiver(passed);
+
+ do {
+ sendAsyncJobs((int)(Math.random() * 10 + 1), jobQueue, myReceiver, threadID, myImpl, context);
+ sendSyncJobs((int)(Math.random() * 10 + 1), jobQueue, myReceiver, threadID, myImpl, thread, context, true);
+ sendAsyncJobs((int)(Math.random() * 10 + 1), jobQueue, myReceiver, threadID, myImpl, context);
+ sendSyncJobs((int)(Math.random() * 10 + 1), jobQueue, myReceiver, threadID, myImpl, thread, context, true);
+ }
+ while(Math.random() > 0.25);
+
+
+ myImpl.finish();
+
+ passed[0] = passed[0] && myImpl._passed;
+
+ System.err.println("test_with_thread - passed? " + passed[0]);
+
+ jobQueue.printStats();
+
+ return passed[0];
+ }
+
+
+
+ static public boolean test_disposing() throws Exception {
+ boolean passed[] = new boolean[]{true};
+
+ System.err.println("doing test_disposing ...");
+
+ ThreadID threadID = new ThreadID("test_thread_id".getBytes());
+
+ Object context = new MyContext();
+
+ JobQueue jobQueue = new JobQueue(threadID, true);
+ MyImpl2 myImpl = new MyImpl2();
+ MyReceiver myReceiver = new MyReceiver(passed);
+
+
+ // see if asyncs are interruptable, they should not be
+ synchronized(myImpl) {
+ sendAsyncJobs(1, jobQueue, myReceiver, threadID, myImpl, context);
+ myImpl.wait();
+ jobQueue.interrupt(context);
+ myImpl.notify();
+ myImpl.wait();
+ }
+
+ // see if syncs are interruptable, they should be
+ synchronized(myImpl) {
+ sendSyncJobs(1, jobQueue, myReceiver, threadID, myImpl, null, context, false);
+ myImpl.wait();
+ jobQueue.interrupt(context);
+ myImpl.notify();
+ myImpl.wait();
+ }
+
+ passed[0] = passed[0] && myImpl._passed;
+
+ System.err.println("test_disposing - passed? " + passed[0]);
+
+ jobQueue.printStats();
+
+ return passed[0];
+ }
+
+
+ static public boolean test(Vector notpassed) throws Exception {
+ boolean passed = true;
+
+ passed = passed && test_without_thread();
+ if(!passed && notpassed != null)
+ notpassed.addElement("JobQueue_Test - test_without_thread passed?" + passed);
+
+ passed = passed && test_with_thread();
+ if(!passed && notpassed != null)
+ notpassed.addElement("JobQueue_Test - test_with_thread passed?" + passed);
+
+ passed = passed && test_disposing();
+ if(!passed && notpassed != null)
+ notpassed.addElement("JobQueue_Test - test_disposing passed?" + passed);
+
+ return passed;
+ }
+
+ static public void main(String args[]) throws Exception {
+ test(null);
+ }
+}
+
+
diff --git a/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadPool_Test.java b/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadPool_Test.java
new file mode 100644
index 000000000000..756c0adb3bbb
--- /dev/null
+++ b/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadPool_Test.java
@@ -0,0 +1,404 @@
+/*************************************************************************
+ *
+ * $RCSfile: ThreadPool_Test.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:27:55 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.uno.environments.remote;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+
+import com.sun.star.uno.IEnvironment;
+import com.sun.star.uno.UnoRuntime;
+
+
+public class ThreadPool_Test {
+ static int __requestId = 0;
+ static int __running_thread_count;
+
+ static interface MyInterface {
+ Object syncCall(Object param) throws Exception;
+ Object asyncCall(Object param) throws Exception;
+ }
+
+ static interface IReadyListener {
+ void readyEvent();
+ }
+
+
+ static class MyImpl implements MyInterface {
+ int _received_requestId;
+ int _send_requestId;
+ boolean _passed = true;
+ IReadyListener _iReadyListener;
+ boolean _block;
+
+ MyImpl() {
+ }
+
+ int getNext() {
+ return _send_requestId ++;
+ }
+
+ void addReadyListener(IReadyListener iReadyListener) {
+ _iReadyListener = iReadyListener;
+ }
+
+ public Object syncCall(Object param) throws Exception{
+ Object object = doSomething(param);
+
+ // send a request to ourself
+
+// ThreadPool.addThread(null);
+// Job job = new Job(new MyReceiver(null), // receiver
+// JavaThreadPool.getThreadId(Thread.currentThread()), // threadID
+// __requestId ++, // requestId
+// this, // object
+// null, // operation,
+// new MyMessage(0), // parameter
+// true, // synchron ?
+// null, // exception ?
+// MyInterface.class); // interface
+
+
+// ThreadPool.putJob(job, null);
+// System.err.println("entering ...");
+// ThreadPool.enter();
+// System.err.println("left");
+ if(_block) {
+ try {
+ synchronized(this) {
+ System.err.println(this + " waiting for interrupt...");
+ wait(); // wait for exception
+ }
+ }
+ catch(InterruptedException interruptedException) {
+ System.err.println(this + " succecessfully interrupted - rethrowing...");
+ throw interruptedException;
+ }
+ }
+
+ return object;
+
+ }
+
+ public Object asyncCall(Object param) throws Exception {
+ return doSomething(param);
+ }
+
+ Object doSomething(Object param) throws Exception {
+// synchronized(this) {
+// long waitTime = (long)(Math.random() * 100);
+// if(waitTime > 0)
+// wait(waitTime); // simulate work
+// }
+
+ _passed = _passed && (((Integer)param).intValue() == _received_requestId);
+
+ if(!_passed)
+ throw new NullPointerException("blblbl");
+
+
+
+
+ ++ _received_requestId;
+
+ if(_iReadyListener != null)
+ _iReadyListener.readyEvent();
+
+// synchronized(this) {
+// long waitTime = (long)(Math.random() * 100);
+// if(waitTime > 0)
+// wait(waitTime); // simulate work
+// }
+
+ return "blabla";
+ }
+
+ void finish() {
+ _passed = _passed && (_send_requestId == _received_requestId);
+ }
+
+ boolean pendingRequests() {
+ return _send_requestId != _received_requestId;
+ }
+ }
+
+
+
+ static void sendJobs(int jobs, MyReceiver myReceiver, ThreadID threadID, MyImpl myImpl, boolean synchron, boolean finish, Object disposeId) throws Exception {
+ // sending synchronous calls
+ System.err.println("sending " + jobs + " " + synchron + " calls...");
+
+ for(int i = 0; i < jobs; ++ i) {
+ MyMessage myMessage = new MyMessage(synchron,
+ MyInterface.class,
+ UnoRuntime.generateOid(myImpl),
+ threadID,
+ myImpl,
+ finish ? null : (synchron ? "syncCall": "asyncCall"),
+ new Object[]{new Integer(myImpl.getNext())});
+
+ Job job = new Job(myReceiver, myMessage);
+// Job job = new Job(UnoRuntime.generateOid(myImpl),
+// myReceiver, // receiver
+// threadID, // threadID
+// __requestId ++, // requestId
+// myImpl, // object
+// finish ? null : (synchron ? "syncCall": "asyncCall"), // operation,
+// myMessage, // parameter
+// synchron, // synchron ?
+// null, // exception ?
+// MyInterface.class); // interface
+
+ ThreadPool.putJob(job, disposeId);
+ }
+ }
+
+
+
+ static class Worker_with_Thread extends Thread {
+ MyImpl _myImpl = new MyImpl();
+ MyReceiver _myReceiver = new MyReceiver(null);
+ boolean _started = false;
+
+ public void run() {
+ System.err.println("WorkerThread - started");
+ try {
+ ThreadPool.addThread(null);
+ _started = true;
+
+ ThreadPool.enter();
+
+// _myImpl.finish();
+ }
+ catch(Exception exception) {
+ System.err.println("WorkerThread - exception:" + exception);
+ exception.printStackTrace();
+ }
+ System.err.println("WorkerThread - finished - passed:" + _myImpl._passed);
+ }
+ }
+
+ static class RemoteObject implements IReadyListener {
+ MyImpl _myImpl = new MyImpl();
+ MyReceiver _myReceiver = new MyReceiver(null);
+ ThreadID _threadID = new ThreadID(UnoRuntime.generateOid(this).getBytes());
+
+ boolean _finished = false;
+
+ {
+ _myImpl.addReadyListener(this);
+ }
+
+ public synchronized void readyEvent() {
+ _finished = true;
+ notifyAll();
+ }
+ }
+
+ static Vector __threads = new Vector();
+
+
+ static class SenderThread extends Thread {
+ boolean _quit = false;
+ Object _disposeId;
+
+ SenderThread(Object disposeId) {
+ _disposeId = disposeId;
+ }
+
+ public void run() {
+ try {
+ while(!_quit && __threads.size() > 0) {
+ Enumeration elements = __threads.elements();
+ while(elements.hasMoreElements() && !_quit) {
+ Object object = elements.nextElement();
+
+ if(object instanceof Worker_with_Thread) {
+ Worker_with_Thread thread = (Worker_with_Thread)object;
+
+ if(thread._started && !thread._myImpl.pendingRequests()) {
+ sendJobs((int)(Math.random() * 50 + 1), thread._myReceiver, JavaThreadPool.getThreadId(thread), thread._myImpl, false, false, _disposeId);
+ sendJobs((int)(1), thread._myReceiver, JavaThreadPool.getThreadId(thread), thread._myImpl, true, false, _disposeId);
+
+ if(Math.random() > 0.95) {
+ sendJobs(1, thread._myReceiver, JavaThreadPool.getThreadId(thread), thread._myImpl, true, true, _disposeId); // finish
+
+ __threads.removeElement(thread);
+ }
+ }
+ }
+ else {
+ RemoteObject remoteObject = (RemoteObject)object;
+
+ if(!remoteObject._myImpl.pendingRequests()) {
+ sendJobs((int)(Math.random() * 50 + 1), remoteObject._myReceiver, remoteObject._threadID, remoteObject._myImpl, false, false, _disposeId);
+ sendJobs((int)(Math.random() * 50 + 1), remoteObject._myReceiver, remoteObject._threadID, remoteObject._myImpl, true, false, _disposeId);
+
+ if(Math.random() > 0.95) {
+ __threads.removeElement(remoteObject);
+ }
+ }
+ }
+ }
+ synchronized(this) {
+ notify();
+ }
+// Thread.sleep((int)(Math.random() * 100));
+ }
+ }
+ catch(Exception exception) {
+ System.err.println("SenderThread - exception:" + exception);
+ exception.printStackTrace();
+ }
+ }
+ }
+
+ static public boolean test_with_thread() throws InterruptedException {
+ Object disposeId = new Integer(0);
+
+ int blockers = 0;
+
+ SenderThread senderThread = new SenderThread(disposeId);
+ senderThread.start();
+
+ Vector threads = new Vector();
+
+ do {
+ ++ __running_thread_count;
+ Object object = null;
+
+ if(Math.random() > 1.25) {
+ Thread thread = new Worker_with_Thread();
+ thread.start();
+
+ object = thread;
+ }
+ else {
+ object = new RemoteObject();
+
+ if(Math.random() > 0.70) {
+ ((RemoteObject)object)._myImpl._block = true;
+ ++ blockers;
+ }
+ }
+
+ __threads.addElement(object);
+ threads.addElement(object);
+ Thread.sleep((int)(Math.random() * 1000));
+ }
+ while(Math.random() > 0.05);
+
+
+ System.err.println("waiting for SenderThread to die...");
+ senderThread._quit = true;
+ senderThread.join();
+
+ System.err.println("disposing ThreadPool for id " + disposeId + " with " + blockers + " blocked ...");
+ ThreadPool.dispose(disposeId);
+
+ boolean passed = true;
+
+ // wait for all threads
+ System.err.println("joining all threads ...");
+ Enumeration elements = threads.elements();
+ while(elements.hasMoreElements()) {
+ Object object = elements.nextElement();
+ if(object instanceof Worker_with_Thread) {
+ Worker_with_Thread thread = (Worker_with_Thread)object;
+ thread.join();
+
+ passed = passed && thread._myImpl._passed;
+ }
+ else {
+ RemoteObject remoteObject = (RemoteObject)object;
+ synchronized(remoteObject) {
+ while(!remoteObject._finished && !remoteObject._myImpl._block)
+ remoteObject.wait();
+ }
+ }
+ }
+
+ System.err.println("test_with_thread - passed? " + passed);
+
+ return passed;
+ }
+
+ static public boolean test(Vector notpassed) throws Exception {
+ boolean passed = true;
+
+ passed = passed && test_with_thread();
+ if(!passed && notpassed != null)
+ notpassed.addElement("ThreadPool_Test - test_with_thread passed?" + passed);
+
+ return passed;
+ }
+
+ static public void main(String args[]) throws Exception {
+ test(null);
+ }
+}
+
+
diff --git a/jurt/test/com/sun/star/lib/uno/environments/remote/makefile.mk b/jurt/test/com/sun/star/lib/uno/environments/remote/makefile.mk
new file mode 100644
index 000000000000..1b723c3bf8ca
--- /dev/null
+++ b/jurt/test/com/sun/star/lib/uno/environments/remote/makefile.mk
@@ -0,0 +1,84 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:55 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..$/..$/..$/..$/..
+
+PRJNAME := jurt
+PACKAGE := com$/sun$/star$/lib$/uno$/environments$/remote
+TARGET := test_com_sun_star_lib_uno_environments_remote
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# Files --------------------------------------------------------
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/JobQueue_Test.class \
+ $(CLASSDIR)$/$(PACKAGE)$/MyMessage.class \
+ $(CLASSDIR)$/$(PACKAGE)$/MyReceiver.class \
+ $(CLASSDIR)$/$(PACKAGE)$/ThreadPool_Test.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/test/com/sun/star/lib/util/makefile.mk b/jurt/test/com/sun/star/lib/util/makefile.mk
new file mode 100644
index 000000000000..9270050562b8
--- /dev/null
+++ b/jurt/test/com/sun/star/lib/util/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..$/..$/..
+
+PRJNAME := jurt
+PACKAGE := com$/sun$/star$/lib$/util
+TARGET := test_com_sun_star_lib_util
+
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+
+# Files --------------------------------------------------------
+
+JARFILES = sandbox.jar
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/WeakTable_Test.class
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/test/com/sun/star/uno/makefile.mk b/jurt/test/com/sun/star/uno/makefile.mk
new file mode 100644
index 000000000000..f74ccb1aed65
--- /dev/null
+++ b/jurt/test/com/sun/star/uno/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..$/..
+
+PRJNAME := jurt
+PACKAGE := com$/sun$/star$/uno
+TARGET := test_com_sun_star_uno
+
+
+RDB= $(SOLARBINDIR)$/applicat.rdb
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# Files --------------------------------------------------------
+
+JARFILES = jurt.jar
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/UnoRuntime_Test.class
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/jurt/test/makefile.mk b/jurt/test/makefile.mk
new file mode 100644
index 000000000000..7ac4f74ca694
--- /dev/null
+++ b/jurt/test/makefile.mk
@@ -0,0 +1,80 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:54 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+
+test:
+# cd ./com/sun/star/comp/bootstrap; make debug
+# cd ./com/sun/star/comp/implementationregistration/makefile.mk
+# cd ./com/sun/star/comp/loader; dmake debug=t
+# cd ./com/sun/star/comp/rmclient/makefile.mk
+# cd ./com/sun/star/comp/rmserver/makefile.mk
+# cd ./com/sun/star/comp/typedescriptionmanager/makefile.mk
+# cd ./com/sun/star/comp/testcomp/makefile.mk
+ cd ./com/sun/star/comp/connections; dmake debug=t
+ cd ./com/sun/star/lib/util; dmake debug=t
+ cd ./com/sun/star/uno; dmake debug=t
+ cd ./com/sun/star/lib/uno/environments/java; dmake debug=t
+ cd ./com/sun/star/lib/uno/bridges/java_remote; dmake debug=t
+ cd ./com/sun/star/lib/uno/environments/remote; dmake debug=t
+ cd ./com/sun/star/lib/uno/protocols; dmake debug=t
+ javac DoTests.java
+ java -classpath $(CLASSPATH):. DoTests
diff --git a/jurt/util/makefile.mk b/jurt/util/makefile.mk
new file mode 100644
index 000000000000..939d44dd9cf7
--- /dev/null
+++ b/jurt/util/makefile.mk
@@ -0,0 +1,77 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..
+PRJNAME = jurt
+TARGET = jurt
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+JARCLASSDIRS = com
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/jurt/util/makefile.pmk b/jurt/util/makefile.pmk
new file mode 100644
index 000000000000..cd77efec41cf
--- /dev/null
+++ b/jurt/util/makefile.pmk
@@ -0,0 +1,77 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.pmk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:27:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+JARFILES = sandbox.jar
+CLASSGENDIR = $(OUT)$/classgen
+#classpath if jarfiles not set
+XCLASSPATH := $(XCLASSPATH)$(PATH_SEPERATOR)$(MISC)$/java
+#XCLASSPATH = $(XCLASSPATH)$(PATH_SEPERATOR)$(CLASSGENDIR)
+RDB = $(SOLARBINDIR)$/applicat.rdb
+JAVAFILES = $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES)))
+
+
+%.java:
+ javamaker -BUCR -O$(OUT)$/misc$/java $(subst,$/,. $(subst,$(OUT)$/misc$/java$/,-T $*)) $(RDB)
diff --git a/rdbmaker/inc/codemaker/dependency.hxx b/rdbmaker/inc/codemaker/dependency.hxx
new file mode 100644
index 000000000000..f8b2d1805931
--- /dev/null
+++ b/rdbmaker/inc/codemaker/dependency.hxx
@@ -0,0 +1,215 @@
+/*************************************************************************
+ *
+ * $RCSfile: dependency.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#define _CODEMAKER_DEPENDENCY_HXX_
+
+#include <hash_map>
+
+#ifndef _REGISTRY_REGISTRY_HXX_
+#include <registry/registry.hxx>
+#endif
+#ifndef __REGISTRY_REFLREAD_HXX__
+#include <registry/reflread.hxx>
+#endif
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#include <codemaker/global.hxx>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#define TYPEUSE_NORMAL 0x0001
+#define TYPEUSE_SUPER 0x0002
+#define TYPEUSE_MEMBER 0x0004
+#define TYPEUSE_INPARAM 0x0008
+#define TYPEUSE_OUTPARAM 0x0010
+#define TYPEUSE_INOUTPARAM 0x0020
+#define TYPEUSE_RETURN 0x0040
+#define TYPEUSE_EXCEPTION 0x0080
+
+/**
+ * Flag shows the state of the code generation. If the Flag is set
+ * the code for this type is generated.
+ */
+#define CODEGEN_DEFAULT 0x0001
+
+struct TypeUsing
+{
+ TypeUsing(const ::rtl::OString& type, sal_uInt16 use)
+ : m_type(type)
+ , m_use(use)
+ {}
+
+ ::rtl::OString m_type;
+ sal_uInt16 m_use;
+
+ sal_Bool operator == (const TypeUsing & typeUsing) const
+ {
+ OSL_ASSERT(0);
+ return m_type == typeUsing.m_type && m_use == typeUsing.m_use;
+ }
+};
+
+struct LessTypeUsing
+{
+ sal_Bool operator()(const TypeUsing& tuse1, const TypeUsing& tuse2) const
+ {
+ return (tuse1.m_type < tuse2.m_type);
+ }
+};
+
+typedef NAMESPACE_STD(set) <TypeUsing, LessTypeUsing> TypeUsingSet;
+
+
+#if (defined( _MSC_VER ) && ( _MSC_VER < 1200 ))
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString,
+ TypeUsingSet,
+ HashString,
+ EqualString,
+ NewAlloc
+> DependencyMap;
+
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString,
+ sal_uInt16,
+ HashString,
+ EqualString,
+ NewAlloc
+> GenerationMap;
+#else
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString,
+ TypeUsingSet,
+ HashString,
+ EqualString
+> DependencyMap;
+
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString,
+ sal_uInt16,
+ HashString,
+ EqualString
+> GenerationMap;
+
+#endif
+
+struct TypeDependencyImpl
+{
+ TypeDependencyImpl()
+ : m_refCount(0)
+ {}
+
+ sal_Int32 m_refCount;
+ DependencyMap m_dependencies;
+ GenerationMap m_generatedTypes;
+};
+
+class TypeDependency
+{
+public:
+ TypeDependency();
+ ~TypeDependency();
+
+ TypeDependency( const TypeDependency& value )
+ : m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+
+ TypeDependency& operator = ( const TypeDependency& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+
+ sal_Bool insert(const ::rtl::OString& type, const ::rtl::OString& depend, sal_uInt16);
+ TypeUsingSet getDependencies(const ::rtl::OString& type);
+ sal_Bool lookupDependency(const ::rtl::OString& type, const ::rtl::OString& depend, sal_uInt16);
+ sal_Bool hasDependencies(const ::rtl::OString& type);
+
+ void setGenerated(const ::rtl::OString& type, sal_uInt16 genFlag=CODEGEN_DEFAULT);
+ sal_Bool isGenerated(const ::rtl::OString& type, sal_uInt16 genFlag=CODEGEN_DEFAULT);
+
+ sal_Int32 getSize() { return m_pImpl->m_generatedTypes.size(); }
+protected:
+ void acquire();
+ void release();
+
+protected:
+ TypeDependencyImpl* m_pImpl;
+};
+
+sal_Bool checkTypeDependencies(TypeManager& typeMgr, TypeDependency& dependencies, const ::rtl::OString& type);
+
+#endif // _CODEMAKER_DEPENDENCY_HXX_
diff --git a/rdbmaker/inc/codemaker/global.hxx b/rdbmaker/inc/codemaker/global.hxx
new file mode 100644
index 000000000000..6ab359efd970
--- /dev/null
+++ b/rdbmaker/inc/codemaker/global.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * $RCSfile: global.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#define _CODEMAKER_GLOBAL_HXX_
+
+#include <list>
+#include <vector>
+#include <set>
+
+#include <fstream.h>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _VOS_MACROS_HXX_
+#include <vos/macros.hxx>
+#endif
+
+
+struct EqualString
+{
+ sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
+ {
+ return (str1 == str2);
+ }
+};
+
+struct HashString
+{
+ size_t operator()(const ::rtl::OString& str) const
+ {
+ return str.hashCode();
+ }
+};
+
+struct LessString
+{
+ sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
+ {
+ return (str1 < str2);
+ }
+};
+
+#if defined(_MSC_VER) && _MSC_VER < 1200
+typedef NAMESPACE_STD(new_alloc) NewAlloc;
+#endif
+
+
+typedef NAMESPACE_STD(list) < ::rtl::OString > StringList;
+typedef NAMESPACE_STD(vector)< ::rtl::OString > StringVector;
+typedef NAMESPACE_STD(set) < ::rtl::OString, LessString > StringSet;
+
+::rtl::OString makeTempName(sal_Char* prefix);
+
+::rtl::OString createFileNameFromType(const ::rtl::OString& destination,
+ const ::rtl::OString type,
+ const ::rtl::OString postfix,
+ sal_Bool bLowerCase=sal_False,
+ const ::rtl::OString prefix="");
+
+sal_Bool fileExists(const ::rtl::OString& fileName);
+sal_Bool checkFileContent(const ::rtl::OString& targetFileName, const ::rtl::OString& tmpFileName);
+
+const ::rtl::OString inGlobalSet(const ::rtl::OUString & r);
+inline const ::rtl::OString inGlobalSet(sal_Char* p)
+{
+ return inGlobalSet( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(p) ) );
+}
+
+//*************************************************************************
+// FileStream
+//*************************************************************************
+class FileStream : public ofstream
+{
+public:
+ FileStream();
+ FileStream(const ::rtl::OString& name, sal_Int32 nMode = ios::out | ios::trunc);
+ virtual ~FileStream();
+
+ sal_Bool isValid();
+
+ void openFile(const ::rtl::OString& name, sal_Int32 nMode = ios::out | ios::trunc);
+ void closeFile();
+
+ sal_Int32 getSize();
+ ::rtl::OString getName() { return m_name; }
+protected:
+ ::rtl::OString m_name;
+};
+
+#endif // _CODEMAKER_GLOBAL_HXX_
+
diff --git a/rdbmaker/inc/codemaker/options.hxx b/rdbmaker/inc/codemaker/options.hxx
new file mode 100644
index 000000000000..875d3e785d9b
--- /dev/null
+++ b/rdbmaker/inc/codemaker/options.hxx
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * $RCSfile: options.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_OPTIONS_HXX_
+#define _CODEMAKER_OPTIONS_HXX_
+
+#include <hash_map>
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#include <codemaker/global.hxx>
+#endif
+
+#if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString,
+ ::rtl::OString,
+ HashString,
+ EqualString,
+ NewAlloc
+> OptionMap;
+#else
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString,
+ ::rtl::OString,
+ HashString,
+ EqualString
+> OptionMap;
+#endif
+
+class CannotDumpException
+{
+public:
+ CannotDumpException(const ::rtl::OString& msg)
+ : m_message(msg) {}
+
+ ::rtl::OString m_message;
+};
+
+
+class IllegalArgument
+{
+public:
+ IllegalArgument(const ::rtl::OString& msg)
+ : m_message(msg) {}
+
+ ::rtl::OString m_message;
+};
+
+
+class Options
+{
+public:
+ Options();
+ ~Options();
+
+ virtual sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
+ throw( IllegalArgument ) = 0;
+
+ virtual ::rtl::OString prepareHelp() = 0;
+
+ const ::rtl::OString& getProgramName() const;
+ sal_uInt16 getNumberOfOptions() const;
+ sal_Bool isValid(const ::rtl::OString& option);
+ const ::rtl::OString getOption(const ::rtl::OString& option)
+ throw( IllegalArgument );
+ const OptionMap& getOptions();
+
+ sal_uInt16 getNumberOfInputFiles() const;
+ const ::rtl::OString getInputFile(sal_uInt16 index)
+ throw( IllegalArgument );
+
+ const StringVector& getInputFiles();
+
+protected:
+ ::rtl::OString m_program;
+ StringVector m_inputFiles;
+ OptionMap m_options;
+};
+
+#endif // _CODEMAKER_OPTIONS_HXX_
+
diff --git a/rdbmaker/inc/codemaker/registry.hxx b/rdbmaker/inc/codemaker/registry.hxx
new file mode 100644
index 000000000000..aef51ffa048d
--- /dev/null
+++ b/rdbmaker/inc/codemaker/registry.hxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * $RCSfile: registry.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_REGISTRY_HXX_
+#define _CODEMAKER_REGISTRY_HXX_
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+
+#ifndef _REGISTRY_REGISTRY_HXX_
+#include <registry/registry.hxx>
+#endif
+#ifndef __REGISTRY_REFLREAD_HXX__
+#include <registry/reflread.hxx>
+#endif
+
+#ifndef _CODEMAKER_OPTIONS_HXX_
+#include <codemaker/options.hxx>
+#endif
+
+struct TypeReader_Impl
+{
+ TypeReader_Impl(const RegistryTypeReaderLoader& rLoader,
+ const sal_uInt8* buffer,
+ sal_uInt32 bufferLen,
+ sal_Bool copyData)
+ : m_refCount(0)
+ , m_copyData(copyData)
+ , m_blopSize(bufferLen)
+ , m_pBlop(buffer)
+ {
+ if (copyData)
+ {
+ m_pBlop = (sal_uInt8*)rtl_allocateMemory(bufferLen);
+ rtl_copyMemory((void*)m_pBlop, buffer, bufferLen);
+ } else
+ {
+ m_blopSize = bufferLen;
+ m_pBlop = buffer;
+ }
+
+ m_pReader = new RegistryTypeReader( rLoader, m_pBlop, m_blopSize, sal_False);
+ }
+
+ ~TypeReader_Impl()
+ {
+ if (m_copyData && m_pReader)
+ {
+ delete m_pReader;
+ }
+ }
+
+ sal_Int32 m_refCount;
+ sal_Bool m_copyData;
+ sal_Int32 m_blopSize;
+ const sal_uInt8* m_pBlop;
+ RegistryTypeReader* m_pReader;
+};
+
+class TypeReader
+{
+/*
+ inline TypeReader(const RegistryTypeReader_Api* pApi,
+ const sal_uInt8* buffer,
+ sal_uInt32 bufferLen,
+ sal_Bool copyData);
+*/
+public:
+ inline TypeReader()
+ : m_pImpl(NULL)
+ {}
+
+ inline TypeReader(const RegistryTypeReaderLoader& rLoader,
+ const sal_uInt8* buffer,
+ sal_uInt32 bufferLen,
+ sal_Bool copyData)
+ {
+ m_pImpl = new TypeReader_Impl(rLoader, buffer, bufferLen, copyData);
+ acquire();
+ }
+
+ inline TypeReader(const TypeReader& toCopy)
+ : m_pImpl(toCopy.m_pImpl)
+ {
+ acquire();
+ }
+
+ inline void acquire()
+ {
+ if (m_pImpl)
+ osl_incrementInterlockedCount(&m_pImpl->m_refCount);
+ }
+
+ inline void release()
+ {
+ if (m_pImpl && 0 == osl_decrementInterlockedCount(&m_pImpl->m_refCount))
+ {
+ delete m_pImpl;
+ }
+ }
+
+ inline TypeReader& operator = ( const TypeReader& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+
+ inline sal_Bool isValid() const
+ {
+ if (m_pImpl)
+ return m_pImpl->m_pReader->isValid();
+ else
+ return sal_False;
+ }
+
+ inline sal_uInt16 getMinorVersion() const
+ { return m_pImpl->m_pReader->getMinorVersion(); }
+ inline sal_uInt16 getMajorVersion() const
+ { return m_pImpl->m_pReader->getMajorVersion(); }
+ inline RTTypeClass getTypeClass() const
+ { return m_pImpl->m_pReader->getTypeClass(); }
+ inline const ::rtl::OString getTypeName() const
+ { return inGlobalSet( m_pImpl->m_pReader->getTypeName() ); }
+ inline const ::rtl::OString getSuperTypeName() const
+ { return inGlobalSet( m_pImpl->m_pReader->getSuperTypeName() ); }
+ inline void getUik(RTUik& uik) const
+ { m_pImpl->m_pReader->getUik(uik); }
+ inline const ::rtl::OString getDoku() const
+ { return inGlobalSet( m_pImpl->m_pReader->getDoku() ); }
+ inline const ::rtl::OString getFileName() const
+ { return inGlobalSet( m_pImpl->m_pReader->getFileName() ); }
+ inline sal_uInt32 getFieldCount() const
+ { return m_pImpl->m_pReader->getFieldCount(); }
+ inline const ::rtl::OString getFieldName( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getFieldName(index) ); }
+ inline const ::rtl::OString getFieldType( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getFieldType(index) ); }
+ inline RTFieldAccess getFieldAccess( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getFieldAccess(index); }
+ inline RTConstValue getFieldConstValue( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getFieldConstValue(index); }
+ inline const ::rtl::OString getFieldDoku( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getFieldDoku(index) ); }
+ inline const ::rtl::OString getFieldFileName( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getFieldFileName(index) ); }
+ inline sal_uInt32 getMethodCount() const
+ { return m_pImpl->m_pReader->getMethodCount(); }
+ inline const ::rtl::OString getMethodName( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodName(index) ); }
+ inline sal_uInt32 getMethodParamCount( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getMethodParamCount(index); }
+ inline const ::rtl::OString getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodParamType(index,paramIndex) ); }
+ inline const ::rtl::OString getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodParamName(index,paramIndex) ); }
+ inline RTParamMode getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const
+ { return m_pImpl->m_pReader->getMethodParamMode(index,paramIndex); }
+ inline sal_uInt32 getMethodExcCount( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getMethodExcCount(index); }
+ inline const ::rtl::OString getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodExcType(index,excIndex) ); }
+ inline const ::rtl::OString getMethodReturnType( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodReturnType(index) ); }
+ inline RTMethodMode getMethodMode( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getMethodMode(index); }
+ inline const ::rtl::OString getMethodDoku( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodDoku(index) ); }
+
+ inline sal_uInt32 getReferenceCount() const
+ { return m_pImpl->m_pReader->getReferenceCount(); }
+ inline const ::rtl::OString getReferenceName( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getReferenceName(index) ); }
+ inline RTReferenceType getReferenceType( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getReferenceType(index); }
+ inline const ::rtl::OString getReferenceDoku( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getReferenceDoku(index) ); }
+
+ inline sal_uInt32 getBlopSize() const
+ { return m_pImpl->m_blopSize; }
+
+ inline const sal_uInt8* getBlop() const
+ { return m_pImpl->m_pBlop; }
+
+private:
+ TypeReader_Impl* m_pImpl;
+};
+
+
+#endif // _CODEMAKER_REGISTRY_HXX_
diff --git a/rdbmaker/inc/codemaker/typemanager.hxx b/rdbmaker/inc/codemaker/typemanager.hxx
new file mode 100644
index 000000000000..030dd962795e
--- /dev/null
+++ b/rdbmaker/inc/codemaker/typemanager.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * $RCSfile: typemanager.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <hash_map>
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#define _CODEMAKER_TYPEMANAGER_HXX_
+
+#ifndef _CODEMAKER_REGISTRY_HXX_
+#include <codemaker/registry.hxx>
+#endif
+
+RegistryTypeReaderLoader & getRegistryTypeReaderLoader();
+
+
+typedef NAMESPACE_STD(list) <Registry*> RegistryList;
+
+#if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString, // Typename
+ RTTypeClass, // TypeClass
+ HashString,
+ EqualString,
+ NewAlloc
+> T2TypeClassMap;
+#else
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString, // Typename
+ RTTypeClass, // TypeClass
+ HashString,
+ EqualString
+> T2TypeClassMap;
+#endif
+
+struct TypeManagerImpl
+{
+ TypeManagerImpl()
+ : m_refCount(0)
+ {}
+
+ sal_Int32 m_refCount;
+};
+
+class TypeManager
+{
+public:
+ TypeManager();
+ ~TypeManager();
+
+ TypeManager( const TypeManager& value )
+ : m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+
+ TypeManager& operator = ( const TypeManager& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+
+ virtual sal_Bool init(sal_Bool bMerge, const StringVector& regFiles)
+ { return sal_False; }
+ virtual sal_Bool init(const ::rtl::OString& registryName)
+ { return sal_False; }
+
+ virtual sal_Bool isValidType(const ::rtl::OString& name)
+ { return sal_False; }
+
+ virtual RegistryKey getTypeKey(const ::rtl::OString& name)
+ { return RegistryKey(); }
+ virtual TypeReader getTypeReader(const ::rtl::OString& name)
+ { return TypeReader(); }
+ virtual RTTypeClass getTypeClass(const ::rtl::OString& name)
+ { return RT_TYPE_INVALID; }
+
+ virtual void setBase(const ::rtl::OString& base) {}
+ virtual ::rtl::OString getBase() { return ::rtl::OString(); }
+
+ virtual sal_Int32 getSize() { return 0; }
+
+protected:
+ sal_Int32 acquire();
+ sal_Int32 release();
+
+protected:
+ TypeManagerImpl* m_pImpl;
+};
+
+struct RegistryTypeManagerImpl
+{
+ RegistryTypeManagerImpl()
+ : m_pMergedRegistry(NULL)
+ , m_isMerged(sal_False)
+ , m_base("/")
+ {}
+
+ T2TypeClassMap m_t2TypeClass;
+ RegistryList m_registries;
+ Registry* m_pMergedRegistry;
+ ::rtl::OString m_base;
+ sal_Bool m_isMerged;
+};
+
+class RegistryTypeManager : public TypeManager
+{
+public:
+ RegistryTypeManager();
+ ~RegistryTypeManager();
+
+ RegistryTypeManager( const RegistryTypeManager& value )
+ : TypeManager(value)
+ , m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+/*
+ RegistryTypeManager& operator = ( const RegistryTypeManager& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+*/
+ sal_Bool init(sal_Bool bMerge, const StringVector& regFiles);
+
+ sal_Bool isValidType(const ::rtl::OString& name)
+ { return searchTypeKey(name).isValid(); }
+ RegistryKey getTypeKey(const ::rtl::OString& name)
+ { return searchTypeKey(name); }
+ TypeReader getTypeReader(const ::rtl::OString& name);
+ RTTypeClass getTypeClass(const ::rtl::OString& name);
+
+ void setBase(const ::rtl::OString& base);
+ ::rtl::OString getBase() { return m_pImpl->m_base; }
+
+ sal_Int32 getSize() { return m_pImpl->m_t2TypeClass.size(); }
+protected:
+ RegistryKey searchTypeKey(const ::rtl::OString& name);
+ void freeRegistries();
+
+ void acquire();
+ void release();
+
+protected:
+ RegistryTypeManagerImpl* m_pImpl;
+};
+
+#endif // _CODEMAKER_TYPEMANAGER_HXX_
diff --git a/rdbmaker/prj/d.lst b/rdbmaker/prj/d.lst
new file mode 100644
index 000000000000..47a8ff0d36c1
--- /dev/null
+++ b/rdbmaker/prj/d.lst
@@ -0,0 +1,5 @@
+..\%__SRC%\bin\rdbmaker.exe %_DEST%\bin%_EXT%\rdbmaker.exe
+..\%__SRC%\bin\rdbmaker.pdb %_DEST%\bin%_EXT%\rdbmaker.pdb
+
+..\%__SRC%\bin\rdbmaker %_DEST%\bin%_EXT%\rdbmaker
+
diff --git a/rdbmaker/source/codemaker/dependency.cxx b/rdbmaker/source/codemaker/dependency.cxx
new file mode 100644
index 000000000000..2bba05227f01
--- /dev/null
+++ b/rdbmaker/source/codemaker/dependency.cxx
@@ -0,0 +1,348 @@
+/*************************************************************************
+ *
+ * $RCSfile: dependency.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+using namespace rtl;
+
+TypeDependency::TypeDependency()
+{
+ m_pImpl = new TypeDependencyImpl();
+ acquire();
+}
+
+TypeDependency::~TypeDependency()
+{
+ release();
+}
+
+void TypeDependency::acquire()
+{
+ osl_incrementInterlockedCount(&m_pImpl->m_refCount);
+}
+
+void TypeDependency::release()
+{
+ if (0 == osl_decrementInterlockedCount(&m_pImpl->m_refCount))
+ {
+ delete m_pImpl;
+ }
+}
+
+sal_Bool TypeDependency::insert(const OString& type, const OString& depend, sal_uInt16 use)
+{
+ sal_Bool ret = sal_False;
+
+ if (type.getLength() > 0 && depend.getLength() > 0)
+ {
+ if (m_pImpl->m_dependencies.count(type) > 0)
+ {
+ TypeUsing typeUsing(depend, use);
+ TypeUsingSet::iterator iter;
+ if ((iter = m_pImpl->m_dependencies[type].find(typeUsing)) != m_pImpl->m_dependencies[type].end())
+ {
+ (((TypeUsing *) &(*iter))->m_use) = (*iter).m_use | use;
+ } else
+ {
+ m_pImpl->m_dependencies[type].insert(typeUsing);
+ }
+ } else
+ {
+ TypeUsing typeUsing(depend, use);
+ TypeUsingSet tmpSet;
+ tmpSet.insert(typeUsing);
+ m_pImpl->m_dependencies[type]=tmpSet;
+ }
+ }
+
+ return ret;
+}
+
+TypeUsingSet TypeDependency::getDependencies(const OString& type)
+{
+ if (type.getLength() > 0)
+ {
+ if (m_pImpl->m_dependencies.count(type) > 0)
+ {
+ return m_pImpl->m_dependencies[type];
+ }
+ }
+
+ return TypeUsingSet();
+}
+
+sal_Bool TypeDependency::lookupDependency(const OString& type, const OString& depend, sal_uInt16 use)
+{
+ sal_Bool ret = sal_False;
+
+ if (type.getLength() > 0 && depend.getLength() > 0)
+ {
+ if (m_pImpl->m_dependencies.count(type) > 0)
+ {
+ TypeUsingSet::const_iterator iter = m_pImpl->m_dependencies[type].begin();
+
+ while (iter != m_pImpl->m_dependencies[type].end())
+ {
+ if (depend == (*iter).m_type &&
+ (use & (*iter).m_use))
+ {
+ ret = sal_True;
+ break;
+ }
+ iter++;
+ }
+ } else
+ {
+ ret = sal_False;
+ }
+ }
+
+ return ret;
+}
+
+sal_Bool TypeDependency::hasDependencies(const OString& type)
+{
+ if (type.getLength() > 0)
+ {
+ if (m_pImpl->m_dependencies.count(type) > 0)
+ {
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+void TypeDependency::setGenerated(const OString& type, sal_uInt16 genFlag)
+{
+// m_pImpl->m_generatedTypes.insert(type);
+ if (m_pImpl->m_generatedTypes.count(type) > 0)
+ m_pImpl->m_generatedTypes[type]= m_pImpl->m_generatedTypes[type] | genFlag;
+ else
+ m_pImpl->m_generatedTypes[type]=genFlag;
+}
+
+sal_Bool TypeDependency::isGenerated(const OString& type, sal_uInt16 genFlag)
+{
+/*
+ if (m_pImpl->m_generatedTypes.count(type) > 0)
+ return sal_True;
+
+ return sal_False;
+*/
+ if (m_pImpl->m_generatedTypes.count(type) > 0 &&
+ m_pImpl->m_generatedTypes[type] & genFlag)
+ {
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+static sal_Bool checkFieldDependencies(TypeManager& typeMgr, TypeDependency& dependencies,
+ TypeReader& reader, const OString& type)
+{
+ sal_uInt32 count = reader.getFieldCount();
+
+ if (count == 0 || reader.getTypeClass() == RT_TYPE_ENUM)
+ return sal_True;
+
+ OString fieldType;
+ for (sal_uInt16 i=0; i < count; i++)
+ {
+ fieldType = reader.getFieldType(i);
+
+ if (fieldType.getLength() > 0)
+ {
+ dependencies.insert(type, fieldType, TYPEUSE_MEMBER);
+ checkTypeDependencies(typeMgr, dependencies, fieldType);
+ }
+ }
+
+ return sal_True;
+}
+
+static sal_Bool checkMethodDependencies(TypeManager& typeMgr, TypeDependency& dependencies,
+ TypeReader& reader, const OString& type)
+{
+ sal_uInt32 count = reader.getMethodCount();
+
+ if (count == 0)
+ return sal_True;
+
+ OString returnType, paramType, excType;
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+ RTParamMode paramMode = RT_PARAM_INVALID;
+ for (sal_uInt16 i=0; i < count; i++)
+ {
+ returnType = reader.getMethodReturnType(i);
+
+ dependencies.insert(type, returnType, TYPEUSE_RETURN);
+ checkTypeDependencies(typeMgr, dependencies, returnType);
+
+ paramCount = reader.getMethodParamCount(i);
+ excCount = reader.getMethodExcCount(i);
+
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ paramType = reader.getMethodParamType(i, j);
+ paramMode = reader.getMethodParamMode(i, j);
+
+ switch (paramMode)
+ {
+ case RT_PARAM_IN:
+ dependencies.insert(type, paramType, TYPEUSE_INPARAM);
+ break;
+ case RT_PARAM_OUT:
+ dependencies.insert(type, paramType, TYPEUSE_OUTPARAM);
+ break;
+ case RT_PARAM_INOUT:
+ dependencies.insert(type, paramType, TYPEUSE_INOUTPARAM);
+ break;
+ }
+
+ checkTypeDependencies(typeMgr, dependencies, paramType);
+ }
+
+ for (j=0; j < excCount; j++)
+ {
+ excType = reader.getMethodExcType(i, j);
+ dependencies.insert(type, excType, TYPEUSE_EXCEPTION);
+ checkTypeDependencies(typeMgr, dependencies, excType);
+ }
+
+ }
+
+ return sal_True;
+}
+
+static sal_Bool checkReferenceDependencies(TypeManager& typeMgr, TypeDependency& dependencies,
+ TypeReader& reader, const OString& type)
+{
+ sal_uInt32 count = reader.getReferenceCount();
+
+ if (count == 0)
+ return sal_True;
+
+ OString referenceName;
+ for (sal_uInt16 i=0; i < count; i++)
+ {
+ referenceName = reader.getReferenceName(i);
+
+ dependencies.insert(type, referenceName, TYPEUSE_NORMAL);
+ checkTypeDependencies(typeMgr, dependencies, referenceName);
+ }
+
+ return sal_True;
+}
+
+sal_Bool checkTypeDependencies(TypeManager& typeMgr, TypeDependency& dependencies, const OString& type)
+{
+ if (!typeMgr.isValidType(type))
+ return sal_False;
+
+ if (dependencies.hasDependencies(type))
+ return sal_True;
+
+ TypeReader reader = typeMgr.getTypeReader(type);
+
+ if ( !reader.isValid() )
+ {
+ if (type.equals("/"))
+ return sal_True;
+ else
+ return sal_False;
+ }
+
+ OString superType(reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ dependencies.insert(type, superType, TYPEUSE_SUPER);
+ checkTypeDependencies(typeMgr, dependencies, superType);
+ }
+
+ if (reader.getTypeClass() == RT_TYPE_INTERFACE)
+ {
+ dependencies.insert(type, "com/sun/star/uno/RuntimeException", TYPEUSE_EXCEPTION);
+ dependencies.insert(type, "com/sun/star/uno/TypeClass", TYPEUSE_NORMAL);
+ checkTypeDependencies(typeMgr, dependencies, "com/sun/star/uno/RuntimeException");
+ }
+
+ checkFieldDependencies(typeMgr, dependencies, reader, type);
+ checkMethodDependencies(typeMgr, dependencies, reader, type);
+ checkReferenceDependencies(typeMgr, dependencies, reader, type);
+
+ return sal_True;
+}
+
+
diff --git a/rdbmaker/source/codemaker/global.cxx b/rdbmaker/source/codemaker/global.cxx
new file mode 100644
index 000000000000..8dccbc9b9ea6
--- /dev/null
+++ b/rdbmaker/source/codemaker/global.cxx
@@ -0,0 +1,377 @@
+/*************************************************************************
+ *
+ * $RCSfile: global.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+#ifndef _RTL_OSTRINGBUFFER_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#if defined(SAL_W32) || defined(SAL_OS2)
+#include <io.h>
+#include <direct.h>
+#include <errno.h>
+#endif
+
+#ifdef UNX
+#include <sys/stat.h>
+#include <errno.h>
+#include <unistd.h>
+#endif
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#include <codemaker/global.hxx>
+#endif
+
+using namespace vos;
+using namespace rtl;
+
+OString makeTempName(sal_Char* prefix)
+{
+ static OUString uTMP( RTL_CONSTASCII_USTRINGPARAM("TMP") );
+ static OUString uTEMP( RTL_CONSTASCII_USTRINGPARAM("TEMP") );
+ OUString uPrefix( RTL_CONSTASCII_USTRINGPARAM("cmk_") );
+ OUString uPattern;
+
+ sal_Char* pPrefix = "cmk_";
+ sal_Char tmpPattern[512];
+ sal_Char *pTmpName = NULL;
+
+ if (prefix)
+ pPrefix = prefix;
+
+ OStartupInfo StartupInfo;
+
+ if (StartupInfo.getEnvironment(uTMP, uPattern) != OStartupInfo::E_None)
+ {
+ if (StartupInfo.getEnvironment(uTEMP, uPattern) != OStartupInfo::E_None)
+ {
+#if defined(WIN32) || defined(WNT) || defined(OS2)
+ strcpy(tmpPattern, ".");
+#else
+ strcpy(tmpPattern, "/tmp");
+#endif
+ }
+ }
+
+ if (uPattern.getLength())
+ {
+ strcpy(tmpPattern, OUStringToOString(uPattern, RTL_TEXTENCODING_UTF8).getStr());
+ }
+
+#ifdef SAL_W32
+ strcat(tmpPattern, "\\");
+ strcat(tmpPattern, pPrefix);
+ strcat(tmpPattern, "XXXXXX");
+ pTmpName = mktemp(tmpPattern);
+#endif
+
+#ifdef SAL_OS2
+ strcpy(tmpPattern, tempnam(NULL, prefix);
+ pTmpName = tmpPattern;
+#endif
+
+#ifdef SAL_UNX
+ strcat(tmpPattern, "\\");
+ strcat(tmpPattern, pPrefix);
+ strcat(tmpPattern, "XXXXXX");
+ pTmpName = mktemp(tmpPattern);
+#endif
+
+ return OString(pTmpName);
+}
+
+OString createFileNameFromType( const OString& destination,
+ const OString typeName,
+ const OString postfix,
+ sal_Bool bLowerCase,
+ const OString prefix )
+{
+ OString type(typeName);
+
+ if (bLowerCase)
+ {
+ type = typeName.toLowerCase();
+ }
+
+ sal_uInt32 length = destination.getLength();
+
+ sal_Bool withPoint = sal_False;
+ if (length == 0)
+ {
+ length++;
+ withPoint = sal_True;
+ }
+
+ length += prefix.getLength() + type.getLength() + postfix.getLength();
+
+ sal_Bool withSeperator = sal_False;
+ if (destination.getStr()[destination.getLength()] != '\\' &&
+ destination.getStr()[destination.getLength()] != '/' &&
+ type.getStr()[0] != '\\' &&
+ type.getStr()[0] != '/')
+ {
+ length++;
+ withSeperator = sal_True;
+ }
+
+ OStringBuffer nameBuffer(length);
+
+ if (withPoint)
+ nameBuffer.append('.');
+ else
+ nameBuffer.append(destination.getStr(), destination.getLength());
+
+ if (withSeperator)
+ nameBuffer.append("/", 1);
+
+ OString tmpStr(type);
+ if (prefix.getLength() > 0)
+ {
+ tmpStr = type.replaceAt(type.lastIndexOf('/')+1, 0, prefix);
+ }
+
+ nameBuffer.append(tmpStr.getStr(), tmpStr.getLength());
+ nameBuffer.append(postfix.getStr(), postfix.getLength());
+
+ OString fileName(nameBuffer);
+
+ sal_Char token;
+#ifdef SAL_UNX
+ fileName = fileName.replace('\\', '/');
+ token = '/';
+#else
+ fileName = fileName.replace('/', '\\');
+ token = '\\';
+#endif
+
+ sal_Int32 count = fileName.getTokenCount(token) - 1;
+
+ nameBuffer = OStringBuffer(length);
+
+ for (int i=0; i < count; i++)
+ {
+ nameBuffer.append(fileName.getToken(i, token).getStr());
+
+ if (nameBuffer.getLength() == 0 || OString(".") == nameBuffer.getStr())
+ {
+ nameBuffer.append(token);
+ continue;
+ }
+
+#ifdef SAL_UNX
+ if (mkdir((char*)nameBuffer.getStr(), 0777) == -1)
+#else
+ if (mkdir((char*)nameBuffer.getStr()) == -1)
+#endif
+ {
+// #if __SUNPRO_CC >= 0x500
+// if( * ::___errno() == ENOENT )
+// #else
+ if ( errno == ENOENT )
+// #endif
+ return OString();
+ }
+
+ nameBuffer.append(token);
+ }
+
+ return fileName;
+}
+
+sal_Bool fileExists(const OString& fileName)
+{
+ FILE *f= fopen(fileName.getStr(), "r");
+
+ if (f != NULL)
+ {
+ fclose(f);
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+sal_Bool checkFileContent(const OString& targetFileName, const OString& tmpFileName)
+{
+ FILE *target = fopen(targetFileName.getStr(), "r");
+ FILE *tmp = fopen(tmpFileName.getStr(), "r");
+ sal_Bool ret = sal_False;
+
+ if (target != NULL && tmp != NULL)
+ {
+ sal_Bool bFindChanges = sal_False;
+ sal_Char buffer1[1024+1];
+ sal_Char buffer2[1024+1];
+ sal_Int32 n1 = 0;
+ sal_Int32 n2 = 0;
+
+ while ( !bFindChanges && !feof(target) && !feof(tmp))
+ {
+ n1 = fread(buffer1, sizeof(sal_Char), 1024, target);
+ n2 = fread(buffer2, sizeof(sal_Char), 1024, tmp);
+
+ if ( n1 != n2 )
+ {
+ bFindChanges = sal_True;
+ }
+ else
+ {
+ if ( rtl_compareMemory(buffer1, buffer2, n2) != 0 )
+ bFindChanges = sal_True;
+ }
+ }
+
+ fclose(target);
+ fclose(tmp);
+
+ if ( bFindChanges )
+ {
+ if ( !unlink(targetFileName.getStr()) )
+ if ( !rename(targetFileName.getStr(), tmpFileName.getStr()) )
+ ret = sal_True;
+ }
+ else
+ {
+ if ( !unlink(tmpFileName.getStr()) )
+ ret = sal_True;
+ }
+ }
+
+ return ret;
+}
+
+const OString inGlobalSet(const OUString & rValue)
+{
+ OString sValue( OUStringToOString(rValue, RTL_TEXTENCODING_UTF8) );
+ static StringSet aGlobalMap;
+ StringSet::iterator iter = aGlobalMap.find( sValue );
+ if( iter != aGlobalMap.end() )
+ return *iter;
+ return *(aGlobalMap.insert( sValue ).first);
+}
+
+
+//*************************************************************************
+// FileStream
+//*************************************************************************
+FileStream::FileStream()
+{
+}
+
+FileStream::FileStream(const OString& name, sal_Int32 nMode)
+ : ofstream(name, nMode)
+ , m_name(name)
+{
+}
+
+FileStream::~FileStream()
+{
+ flush();
+ close();
+}
+
+sal_Bool FileStream::isValid()
+{
+#if defined(SAL_UNX) || defined(SAL_OS2)
+ if(rdbuf()->fd() < 0)
+#else
+ if(fd() < 0)
+#endif
+ {
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+void FileStream::openFile(const OString& name, sal_Int32 nMode)
+{
+ if ( name.getLength() > 0 )
+ m_name = name;
+
+ if ( m_name.getLength() > 0 )
+ open(m_name, nMode);
+}
+
+void FileStream::closeFile()
+{
+ flush();
+ close();
+}
+
+sal_Int32 FileStream::getSize()
+{
+ flush();
+
+ FILE* f = fopen(m_name, "r");
+ sal_Int32 size = 0;
+ if (!fseek(f, 0, SEEK_END))
+ size = ftell(f);
+ fclose(f);
+ return size;
+}
+
diff --git a/rdbmaker/source/codemaker/makefile.mk b/rdbmaker/source/codemaker/makefile.mk
new file mode 100644
index 000000000000..946cd49d00c7
--- /dev/null
+++ b/rdbmaker/source/codemaker/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=codemaker
+TARGET=$(PRJNAME)
+
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+CXXFILES= \
+ global.cxx \
+ options.cxx \
+ typemanager.cxx \
+ dependency.cxx
+
+OBJFILES= \
+ $(OBJ)$/global.obj \
+ $(OBJ)$/options.obj \
+ $(OBJ)$/typemanager.obj \
+ $(OBJ)$/dependency.obj
+
+# ------------------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/rdbmaker/source/codemaker/options.cxx b/rdbmaker/source/codemaker/options.cxx
new file mode 100644
index 000000000000..2b582ad730d3
--- /dev/null
+++ b/rdbmaker/source/codemaker/options.cxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: options.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_OPTIONS_HXX_
+#include <codemaker/options.hxx>
+#endif
+
+using namespace rtl;
+
+Options::Options()
+{
+}
+
+Options::~Options()
+{
+
+}
+
+const OString& Options::getProgramName() const
+{
+ return m_program;
+}
+
+sal_uInt16 Options::getNumberOfOptions() const
+{
+ return m_options.size();
+}
+
+sal_Bool Options::isValid(const OString& option)
+{
+ return (m_options.count(option) > 0);
+}
+
+const OString Options::getOption(const OString& option)
+ throw( IllegalArgument )
+{
+ const OString ret;
+
+ if (m_options.count(option) > 0)
+ {
+ return m_options[option];
+ } else
+ {
+ throw IllegalArgument("Option is not valid or currently not set.");
+ }
+
+ return ret;
+}
+
+const OptionMap& Options::getOptions()
+{
+ return m_options;
+}
+
+sal_uInt16 Options::getNumberOfInputFiles() const
+{
+ return m_inputFiles.size();
+}
+
+const OString Options::getInputFile(sal_uInt16 index)
+ throw( IllegalArgument )
+{
+ const OString ret;
+
+ if (index < m_inputFiles.size())
+ {
+ return m_inputFiles[index];
+ } else
+ {
+ throw IllegalArgument("index is out of bound.");
+ }
+
+ return ret;
+}
+
+const StringVector& Options::getInputFiles()
+{
+ return m_inputFiles;
+}
+
diff --git a/rdbmaker/source/codemaker/typemanager.cxx b/rdbmaker/source/codemaker/typemanager.cxx
new file mode 100644
index 000000000000..88031401083f
--- /dev/null
+++ b/rdbmaker/source/codemaker/typemanager.cxx
@@ -0,0 +1,322 @@
+/*************************************************************************
+ *
+ * $RCSfile: typemanager.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+using namespace rtl;
+
+RegistryTypeReaderLoader & getRegistryTypeReaderLoader()
+{
+ static RegistryTypeReaderLoader aLoader;
+ return aLoader;
+}
+
+TypeManager::TypeManager()
+{
+ m_pImpl = new TypeManagerImpl();
+ acquire();
+}
+
+TypeManager::~TypeManager()
+{
+ release();
+}
+
+sal_Int32 TypeManager::acquire()
+{
+ return osl_incrementInterlockedCount(&m_pImpl->m_refCount);
+}
+
+sal_Int32 TypeManager::release()
+{
+ sal_Int32 refCount = 0;
+ if (0 == (refCount = osl_decrementInterlockedCount(&m_pImpl->m_refCount)) )
+ {
+ delete m_pImpl;
+ }
+ return refCount;;
+}
+
+RegistryTypeManager::RegistryTypeManager()
+{
+ m_pImpl = new RegistryTypeManagerImpl();
+ acquire();
+}
+
+RegistryTypeManager::~RegistryTypeManager()
+{
+ release();
+}
+
+void RegistryTypeManager::acquire()
+{
+ TypeManager::acquire();
+}
+
+void RegistryTypeManager::release()
+{
+ if (0 == TypeManager::release())
+ {
+ if (m_pImpl->m_pMergedRegistry)
+ {
+ if (m_pImpl->m_pMergedRegistry->isValid())
+ {
+ m_pImpl->m_pMergedRegistry->destroy(OUString());
+ }
+
+ delete m_pImpl->m_pMergedRegistry;
+ }
+
+ if (m_pImpl->m_registries.size() > 0)
+ {
+ freeRegistries();
+ }
+
+ delete m_pImpl;
+ }
+}
+
+sal_Bool RegistryTypeManager::init(sal_Bool bMerged, const StringVector& regFiles)
+{
+ m_pImpl->m_isMerged = bMerged && (regFiles.size() > 1);
+
+ if (regFiles.empty())
+ return sal_False;
+
+ StringVector::const_iterator iter = regFiles.begin();
+
+ RegistryLoader loader;
+ Registry tmpReg(loader);
+ while (iter != regFiles.end())
+ {
+ if (!tmpReg.open( OStringToOUString(*iter, RTL_TEXTENCODING_UTF8), REG_READONLY))
+ m_pImpl->m_registries.push_back(new Registry(tmpReg));
+ else
+ {
+ freeRegistries();
+ return sal_False;
+ }
+ iter++;
+ }
+
+ if (m_pImpl->m_isMerged)
+ {
+ Registry *pTmpReg = new Registry(loader);
+ OString tmpName(makeTempName(NULL));
+
+ if (!pTmpReg->create( OStringToOUString(tmpName, RTL_TEXTENCODING_UTF8) ) )
+ {
+ RegistryKey rootKey;
+ RegError ret = REG_NO_ERROR;
+ OUString aRoot( RTL_CONSTASCII_USTRINGPARAM("/") );
+ iter = regFiles.begin();
+ pTmpReg->openRootKey(rootKey);
+
+ while (iter != regFiles.end())
+ {
+ if ( ret = pTmpReg->mergeKey(rootKey, aRoot, OUString::createFromAscii( *iter )) )
+ {
+ if (ret != REG_MERGE_CONFLICT)
+ {
+ freeRegistries();
+ rootKey.closeKey();
+ pTmpReg->destroy( OUString() );
+ delete pTmpReg;
+ return sal_False;
+ }
+ }
+ iter++;
+ }
+
+ m_pImpl->m_pMergedRegistry = pTmpReg;
+ freeRegistries();
+ } else
+ {
+ delete pTmpReg;
+ freeRegistries();
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+TypeReader RegistryTypeManager::getTypeReader(const OString& name)
+{
+ TypeReader reader;
+ RegistryKey key(searchTypeKey(name));
+
+ if (key.isValid())
+ {
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ reader = TypeReader(rReaderLoader, pBuffer, valueSize, sal_True);
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ }
+ return reader;
+}
+
+RTTypeClass RegistryTypeManager::getTypeClass(const OString& name)
+{
+ if (m_pImpl->m_t2TypeClass.count(name) > 0)
+ {
+ return m_pImpl->m_t2TypeClass[name];
+ } else
+ {
+ RegistryKey key(searchTypeKey(name));
+
+ if (key.isValid())
+ {
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_False);
+
+ RTTypeClass ret = reader.getTypeClass();
+
+ rtl_freeMemory(pBuffer);
+
+ m_pImpl->m_t2TypeClass[name] = ret;
+ return ret;
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ }
+ }
+
+ return RT_TYPE_INVALID;
+}
+
+void RegistryTypeManager::setBase(const OString& base)
+{
+ m_pImpl->m_base = base;
+
+ if (base.lastIndexOf('/') != (base.getLength() - 1))
+ {
+ m_pImpl->m_base += "/";
+ }
+}
+
+void RegistryTypeManager::freeRegistries()
+{
+ RegistryList::const_iterator iter = m_pImpl->m_registries.begin();
+
+ while (iter != m_pImpl->m_registries.end())
+ {
+ delete *iter;
+
+ iter++;
+ }
+
+}
+
+RegistryKey RegistryTypeManager::searchTypeKey(const OString& name)
+{
+ RegistryKey key, rootKey;
+
+ if (m_pImpl->m_isMerged)
+ {
+ if (!m_pImpl->m_pMergedRegistry->openRootKey(rootKey))
+ {
+ rootKey.openKey(OStringToOUString(m_pImpl->m_base + name, RTL_TEXTENCODING_UTF8), key);
+ }
+ } else
+ {
+ RegistryList::const_iterator iter = m_pImpl->m_registries.begin();
+
+ while (iter != m_pImpl->m_registries.end())
+ {
+ if (!(*iter)->openRootKey(rootKey))
+ {
+ if (!rootKey.openKey(OStringToOUString(m_pImpl->m_base + name, RTL_TEXTENCODING_UTF8), key))
+ break;
+ }
+
+ iter++;
+ }
+ }
+
+ return key;
+}
+
diff --git a/rdbmaker/source/rdbmaker/makefile.mk b/rdbmaker/source/rdbmaker/makefile.mk
new file mode 100644
index 000000000000..6cd7e3918c02
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/makefile.mk
@@ -0,0 +1,128 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=codemaker
+TARGET=rdbmaker
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb
+
+UNOUCROUT= $(OUT)$/inc
+INCPRE+= $(OUT)$/inc
+
+UNOTYPES= \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.container.XHierarchicalNameAccess \
+ com.sun.star.reflection.XInterfaceTypeDescription \
+ com.sun.star.reflection.XInterfaceMemberTypeDescription \
+ com.sun.star.reflection.XInterfaceMethodTypeDescription \
+ com.sun.star.reflection.XInterfaceAttributeTypeDescription \
+ com.sun.star.reflection.XCompoundTypeDescription \
+ com.sun.star.reflection.XIndirectTypeDescription \
+ com.sun.star.reflection.XEnumTypeDescription \
+ com.sun.star.registry.XRegistryKey \
+
+CXXFILES= rdbmaker.cxx \
+ rdboptions.cxx \
+ typeblop.cxx \
+ specialtypemanager.cxx \
+ rdbtype.cxx
+
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/rdbmaker.obj \
+ $(OBJ)$/rdboptions.obj \
+ $(OBJ)$/typeblop.obj \
+ $(OBJ)$/specialtypemanager.obj \
+ $(OBJ)$/rdbtype.obj
+
+APP1STDLIBS=\
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(REGLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+= \
+ $(LIBCIMT) $(LIBCMT)
+.ENDIF
+
+APP1LIBS= \
+ $(LB)$/codemaker.lib
+
+.INCLUDE : target.mk
diff --git a/rdbmaker/source/rdbmaker/rdbmaker.cxx b/rdbmaker/source/rdbmaker/rdbmaker.cxx
new file mode 100644
index 000000000000..575d13dee99f
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdbmaker.cxx
@@ -0,0 +1,554 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdbmaker.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+#ifndef _RTL_OSTRINGBUFFER_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#if defined(SAL_W32) || defined(SAL_OS2)
+#include <io.h>
+#include <direct.h>
+#include <errno.h>
+#endif
+
+#ifdef UNX
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <unistd.h>
+#endif
+
+#include "specialtypemanager.hxx"
+#include "rdboptions.hxx"
+#include "rdbtype.hxx"
+
+#define PATH_DELEMITTER '/'
+
+using namespace rtl;
+using namespace osl;
+using namespace vos;
+
+FileStream listFile;
+RegistryKey rootKey;
+RegistryLoader loader;
+Registry regFile(loader);
+sal_Bool useSpecial;
+TypeManager* pTypeMgr = NULL;
+StringList dirEntries;
+StringSet filterTypes;
+
+OString getFullNameOfApplicatRdb()
+{
+ OUString bootReg;
+ OUString uTmpStr;
+ if( OStartupInfo::E_None == OStartupInfo().getExecutableFile(uTmpStr) )
+ {
+ sal_uInt32 lastIndex = uTmpStr.lastIndexOf(PATH_DELEMITTER);
+ OUString tmpReg;
+
+ if ( lastIndex > 0 )
+ {
+ tmpReg =uTmpStr.copy(0, lastIndex + 1);
+ }
+
+ tmpReg += OUString( RTL_CONSTASCII_USTRINGPARAM("applicat.rdb") );
+
+ FileBase::getSystemPathFromNormalizedPath(tmpReg, bootReg);
+ }
+
+ return OUStringToOString(bootReg, RTL_TEXTENCODING_ASCII_US);
+}
+
+void initFilterTypes(RdbOptions* pOptions)
+{
+ if (pOptions->isValid("-FT"))
+ {
+ OString fOption(pOptions->getOption("-FT"));
+ sal_uInt32 count = fOption.getTokenCount(';');
+
+ sal_Bool ret = sal_False;
+ for (sal_uInt32 i = 0; i < count; i++)
+ {
+ filterTypes.insert( fOption.getToken(i, ';').replace('.', '/') );
+ }
+ }
+ if (pOptions->isValid("-F"))
+ {
+ FILE *f = fopen(pOptions->getOption("-F").getStr(), "r");
+
+ if (f)
+ {
+ sal_Char buffer[1024+1];
+ sal_Char *pBuf = fgets(buffer, 1024, f);
+ sal_Char *s = NULL;
+ sal_Char *p = NULL;
+ while ( pBuf && !feof(f))
+ {
+ p = pBuf;
+ if (*p != '\n' && *p != '\r')
+ {
+ while (*p == ' ' && *p =='\t')
+ p++;
+
+ s = p;
+ while (*p != '\n' && *p != '\r' && *p != ' ' && *p != '\t')
+ p++;
+
+ *p = '\0';
+ filterTypes.insert( OString(s).replace('.', '/') );
+ }
+
+ pBuf = fgets(buffer, 1024, f);
+ }
+
+ fclose(f);
+ }
+ }
+}
+
+sal_Bool checkFilterTypes(const OString& type)
+{
+ StringSet::iterator iter = filterTypes.begin();
+ while ( iter != filterTypes.end() )
+ {
+ if ( type.indexOf( *iter ) == 0 )
+ {
+ return sal_True;
+ }
+
+ iter++;
+ }
+
+ return sal_False;
+}
+
+void cleanUp( sal_Bool bError)
+{
+ if ( pTypeMgr )
+ {
+ delete pTypeMgr;
+ }
+ if (useSpecial)
+ {
+ pTypeMgr = new SpecialTypeManager();
+ }else
+ {
+ pTypeMgr = new RegistryTypeManager();
+ }
+
+ if ( rootKey.isValid() )
+ {
+ rootKey.closeKey();
+ }
+ if ( regFile.isValid() )
+ {
+ if ( bError )
+ {
+ regFile.destroy(OUString());
+ } else
+ {
+ regFile.close();
+ }
+ }
+ if ( listFile.isValid() )
+ {
+ listFile.closeFile();
+ unlink(listFile.getName().getStr());
+ }
+
+ StringList::reverse_iterator iter = dirEntries.rbegin();
+ while ( iter != dirEntries.rend() )
+ {
+ if (rmdir((char*)(*iter).getStr()) == -1)
+ {
+ break;
+ }
+
+ iter++;
+ }
+}
+
+OString createFileName(const OString& path)
+{
+ OString fileName(path);
+
+ sal_Char token;
+#ifdef SAL_UNX
+ fileName = fileName.replace('\\', '/');
+ token = '/';
+#else
+ fileName = fileName.replace('/', '\\');
+ token = '\\';
+#endif
+
+ sal_Int32 count = fileName.getTokenCount(token) - 1;
+
+ OStringBuffer nameBuffer( path.getLength() );
+
+ for (int i=0; i < count; i++)
+ {
+ nameBuffer.append(fileName.getToken(i, token).getStr());
+
+ if (nameBuffer.getLength() == 0 || OString(".") == nameBuffer.getStr())
+ {
+ nameBuffer.append(token);
+ continue;
+ }
+
+#ifdef SAL_UNX
+ if (mkdir((char*)nameBuffer.getStr(), 0777) == -1)
+#else
+ if (mkdir((char*)nameBuffer.getStr()) == -1)
+#endif
+ {
+ if ( errno == ENOENT )
+ return OString();
+ } else
+ {
+ dirEntries.push_back(nameBuffer.getStr());
+ }
+
+ nameBuffer.append(token);
+ }
+
+ return fileName;
+}
+
+sal_Bool produceAllTypes(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ RdbOptions* pOptions,
+ sal_Bool bFullScope,
+ FileStream& o,
+ RegistryKey& regKey,
+ StringSet& filterTypes)
+ throw( CannotDumpException )
+{
+ if (!produceType(typeName, typeMgr, typeDependencies, pOptions, o, regKey, filterTypes))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+ RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+ RegistryKeyNames subKeys;
+
+ if (typeKey.getKeyNames(OUString(), subKeys))
+ return sal_False;
+
+ OString tmpName;
+ for (sal_uInt32 i=0; i < subKeys.getLength(); i++)
+ {
+ tmpName = OUStringToOString(subKeys.getElement(i), RTL_TEXTENCODING_UTF8);
+
+ if (pOptions->isValid("-B"))
+ tmpName = tmpName.copy(tmpName.indexOf('/', 1) + 1);
+ else
+ tmpName = tmpName.copy(1);
+
+ if (bFullScope)
+ {
+ if (!produceAllTypes(tmpName, typeMgr, typeDependencies, pOptions, sal_True,
+ o, regKey, filterTypes))
+ return sal_False;
+ } else
+ {
+ if (!produceType(tmpName, typeMgr, typeDependencies, pOptions, o, regKey, filterTypes))
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ RdbOptions options;
+
+ try
+ {
+ if (!options.initOptions(argc, argv))
+ {
+ cleanUp(sal_True);
+ exit(1);
+ }
+ }
+ catch( IllegalArgument& e)
+ {
+ fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+ TypeDependency typeDependencies;
+
+ OString bootReg;
+
+ if ( options.isValid("-R") )
+ {
+ bootReg = options.getOption("-R");
+ } else
+ {
+ if (options.getInputFiles().empty())
+ {
+ bootReg = getFullNameOfApplicatRdb();
+ }
+ }
+
+ if ( bootReg.getLength() )
+ {
+ pTypeMgr = new SpecialTypeManager();
+ useSpecial = sal_True;
+ } else
+ {
+ pTypeMgr = new RegistryTypeManager();
+ useSpecial = sal_False;
+ }
+
+ TypeManager& typeMgr = *pTypeMgr;
+
+ if ( useSpecial && !typeMgr.init( bootReg ) )
+ {
+ fprintf(stderr, "%s : init typemanager failed, check your environment for bootstrapping uno.\n", options.getProgramName().getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+ if ( !useSpecial && !typeMgr.init(!options.isValid("-T"), options.getInputFiles()))
+ {
+ fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+ initFilterTypes(&options);
+
+ if (options.isValid("-B"))
+ {
+ typeMgr.setBase(options.getOption("-B"));
+ }
+
+ if ( !options.isValid("-O") )
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "no output file is specified.");
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+ if ( options.generateTypeList() )
+ {
+ OString fileName = createFileName( options.getOption("-O") );
+ listFile.openFile(fileName);
+
+ if ( !listFile.isValid() )
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "could not open output file.");
+ cleanUp(sal_True);
+ exit(99);
+ }
+ } else
+ {
+ OUString fileName( OStringToOUString(createFileName( options.getOption("-O") ), RTL_TEXTENCODING_UTF8) );
+ if ( regFile.create(fileName) )
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "could not create registry output file.");
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+
+ if (options.isValid("-b"))
+ {
+ RegistryKey tmpKey;
+ regFile.openRootKey(tmpKey);
+
+ tmpKey.createKey( OStringToOUString(options.getOption("-b"), RTL_TEXTENCODING_UTF8), rootKey);
+ } else
+ {
+ regFile.openRootKey(rootKey);
+ }
+ }
+
+ try
+ {
+ if (options.isValid("-T"))
+ {
+ OString tOption(options.getOption("-T"));
+ sal_uInt32 count = tOption.getTokenCount(';');
+
+ OString typeName, tmpName;
+ sal_Bool ret = sal_False;
+ for (sal_uInt32 i = 0; i < count; i++)
+ {
+ typeName = tOption.getToken(i, ';');
+
+ tmpName = typeName.getToken(typeName.getTokenCount('.') - 1, '.');
+ if (tmpName == "*")
+ {
+ if (bootReg.getLength())
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "dumping all types of a scope is not possible if -R option is used.");
+ exit(99);
+ }
+ // produce this type and his scope, but the scope is not recursively generated.
+ if (typeName.equals("*"))
+ {
+ tmpName = "/";
+ } else
+ {
+ tmpName = typeName.copy(0, typeName.lastIndexOf('.')).replace('.', '/');
+ if (tmpName.getLength() == 0)
+ tmpName = "/";
+ else
+ tmpName.replace('.', '/');
+ }
+ ret = produceAllTypes(tmpName, typeMgr, typeDependencies, &options, sal_False,
+ listFile, rootKey, filterTypes);
+ } else
+ {
+ // produce only this type
+ ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies,
+ &options, listFile, rootKey, filterTypes);
+ }
+/*
+ // produce only this type
+ ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies,
+ &options, listFile, rootKey, filterTypes);
+*/
+ if (!ret)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+ }
+ } else
+ if (options.isValid("-X"))
+ {
+ } else
+ {
+ if (!bootReg.getLength())
+ {
+ // produce all types
+ if (!produceAllTypes("/", typeMgr, typeDependencies, &options, sal_True,
+ listFile, rootKey, filterTypes))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "an error occurs while dumping all types.");
+ exit(99);
+ }
+ } else
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "dumping all types is not possible if -R option is used.");
+ exit(99);
+ }
+ }
+ }
+ catch( CannotDumpException& e)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ e.m_message.getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+ cleanUp(sal_False);
+ return 0;
+}
+
+
diff --git a/rdbmaker/source/rdbmaker/rdboptions.cxx b/rdbmaker/source/rdbmaker/rdboptions.cxx
new file mode 100644
index 000000000000..9e0e90c6d983
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdboptions.cxx
@@ -0,0 +1,406 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdboptions.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdio.h>
+
+#include "rdboptions.hxx"
+
+using namespace rtl;
+
+sal_Bool RdbOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile)
+ throw( IllegalArgument )
+{
+ sal_Bool ret = sal_True;
+ sal_uInt16 i=0;
+
+ if (!bCmdFile)
+ {
+ bCmdFile = sal_True;
+
+ m_program = av[0];
+
+ if (ac < 2)
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ }
+
+ i = 1;
+ } else
+ {
+ i = 0;
+ }
+
+ char *s=NULL;
+ for (i; i < ac; i++)
+ {
+ if (av[i][0] == '-')
+ {
+ switch (av[i][1])
+ {
+ case 'O':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-O', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-O"] = OString(s);
+ break;
+ case 'X':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-X', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-X"] = OString(s);
+ break;
+ case 'R':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-R', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-R"] = OString(s);
+ break;
+ case 'B':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-B', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-B"] = OString(s);
+ break;
+ case 'b':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-b', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-b"] = OString(s);
+ break;
+ case 'T':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-T', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ if (m_options.count("-T") > 0)
+ {
+ OString tmp(m_options["-T"]);
+ tmp = tmp + ";" + s;
+ m_options["-T"] = tmp;
+ } else
+ {
+ m_options["-T"] = OString(s);
+ }
+ break;
+ case 'F':
+ if (av[i][2] == 'T')
+ {
+ if (av[i][3] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-FT', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 3;
+ }
+
+ if (m_options.count("-FT") > 0)
+ {
+ OString tmp(m_options["-FT"]);
+ tmp = tmp + ";" + s;
+ m_options["-FT"] = tmp;
+ } else
+ {
+ m_options["-FT"] = OString(s);
+ }
+ } else
+ {
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-F', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-F"] = OString(s);
+ }
+ break;
+ case 'L':
+ if (av[i][2] != '\0')
+ {
+ OString tmp("'-L', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ m_options["-L"] = OString();
+ m_generateTypeList = sal_True;
+ break;
+ default:
+ throw IllegalArgument("the option is unknown" + OString(av[i]));
+ break;
+ }
+ } else
+ {
+ if (av[i][0] == '@')
+ {
+ FILE* cmdFile = fopen(av[i]+1, "r");
+ if( cmdFile == NULL )
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ } else
+ {
+ int rargc=0;
+ char* rargv[512];
+ char buffer[512];
+
+ while ( fscanf(cmdFile, "%s", buffer) != EOF )
+ {
+ rargv[rargc]= strdup(buffer);
+ rargc++;
+ }
+ fclose(cmdFile);
+
+ ret = initOptions(rargc, rargv, bCmdFile);
+
+ for (long i=0; i < rargc; i++)
+ {
+ free(rargv[i]);
+ }
+ }
+ } else
+ {
+ m_inputFiles.push_back(av[i]);
+ }
+ }
+ }
+
+ return ret;
+}
+
+OString RdbOptions::prepareHelp()
+{
+ OString help("\nusing: ");
+ help += m_program + " [-options] [file_1 ... file_n]\nOptions:\n";
+ help += " [-R<regname>]= registry name specifies the registry used for bootstrapping\n"
+ " uno. If no registry is specified, the program use the\n"
+ " applicat.rdb finding near the executable.\n";
+ help += " -O<filename> = filename specifies the name of the generated registry\n";
+ help += " or text file.\n";
+ help += " -L = specifies that only a text file is generated with the\n";
+ help += " names of the specified types and their dependencies.\n";
+ help += " Default is that a registry file will be created\n";
+// help += " -X<xmlfile> = xmlfile specifies the name of an xml description where\n";
+// help += " all types are specified which will be generated.\n";
+ help += " -T<name> = name specifies a type or a list of types. The output for\n";
+ help += " [t1;...] this type is generated.\n";
+ help += " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
+ help += " -FT<name> = name specifies a type or a list of types. For this types\n";
+ help += " [t1;...] nothing will be generated.\n";
+ help += " |F<file> = file specifies an text file. For the specified types in\n" ;
+ help += " this file nothing will be generated.\n";
+ help += " -B<name> = name specifies the base node. All types are searched under\n";
+ help += " this node. Default is the root '/' of the registry files.\n";
+ help += " -b<name> = name specifies the base node of the output registry. All\n";
+ help += " types will be generated under this node. Default is the\n";
+ help += " root '/' of the registry file.\n";
+ help += prepareVersion();
+
+ return help;
+}
+
+OString RdbOptions::prepareVersion()
+{
+ OString version("\nSun Microsystems (R) ");
+ version += m_program + " Version 2.0\n\n";
+
+ return version;
+}
+
+
diff --git a/rdbmaker/source/rdbmaker/rdboptions.hxx b/rdbmaker/source/rdbmaker/rdboptions.hxx
new file mode 100644
index 000000000000..7399cea84bb9
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdboptions.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdboptions.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RDBMAKER_RDBOPTIONS_HXX_
+#define _RDBMAKER_RDBOPTIONS_HXX_
+
+#include <codemaker/options.hxx>
+
+class RdbOptions : public Options
+{
+public:
+ RdbOptions()
+ : Options()
+ , m_generateTypeList(sal_False)
+ {}
+
+ ~RdbOptions() {}
+
+ sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
+ throw( IllegalArgument );
+
+ ::rtl::OString prepareHelp();
+
+ ::rtl::OString prepareVersion();
+
+ sal_Bool generateTypeList()
+ { return m_generateTypeList; }
+
+protected:
+ sal_Bool m_generateTypeList;
+};
+
+#endif // _RDBMAKER_RDBOPTIONS_HXX_
diff --git a/rdbmaker/source/rdbmaker/rdbtype.cxx b/rdbmaker/source/rdbmaker/rdbtype.cxx
new file mode 100644
index 000000000000..aebaa1546542
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdbtype.cxx
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdbtype.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#include "rdbtype.hxx"
+#include "rdboptions.hxx"
+
+using namespace rtl;
+
+sal_Bool isBaseType(const OString& type)
+{
+ if ( type.equals("long") ||
+ type.equals("short") ||
+ type.equals("hyper") ||
+ type.equals("string") ||
+ type.equals("boolean") ||
+ type.equals("char") ||
+ type.equals("byte") ||
+ type.equals("any") ||
+ type.equals("type") ||
+ type.equals("float") ||
+ type.equals("double") ||
+ type.equals("octet") ||
+ type.equals("void") ||
+ type.equals("unsigned long") ||
+ type.equals("unsigned short") ||
+ type.equals("unsigned hyper") )
+ return sal_True;
+
+ return sal_False;
+}
+
+sal_Bool produceDependedTypes(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ RdbOptions* pOptions,
+ FileStream& o,
+ RegistryKey& regKey,
+ StringSet& filterTypes)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_True;
+
+ TypeUsingSet usingSet(typeDependencies.getDependencies(typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+ OString sTypeName;
+ sal_Int32 index = 0;
+ while (iter != usingSet.end())
+ {
+ sTypeName = (*iter).m_type;
+ if ((index = sTypeName.lastIndexOf(']')) > 0)
+ sTypeName = sTypeName.copy(index + 1);
+
+ if ( !isBaseType(sTypeName) )
+ {
+ if (!produceType(sTypeName,
+ typeMgr,
+ typeDependencies,
+ pOptions,
+ o, regKey,
+ filterTypes))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + sTypeName + "'").getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+ }
+ iter++;
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// produceType
+//*************************************************************************
+sal_Bool produceType(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ RdbOptions* pOptions,
+ FileStream& o,
+ RegistryKey& regKey,
+ StringSet& filterTypes)
+ throw( CannotDumpException )
+{
+ if (typeDependencies.isGenerated(typeName) )
+ return sal_True;
+/*
+ RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+
+ if (!typeKey.isValid())
+ return sal_False;
+*/
+ if( !checkTypeDependencies(typeMgr, typeDependencies, typeName))
+ return sal_False;
+
+ if ( !checkFilterTypes(typeName) )
+ {
+ if ( pOptions->generateTypeList() )
+ {
+ o << typeName.getStr() << endl;
+ } else
+ {
+/*
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (typeKey.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ if (typeName.equals("/"))
+ return sal_True;
+ else
+ return sal_False;
+ }
+
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+
+ if (typeKey.getValue(OUString(), pBuffer))
+ {
+ rtl_freeMemory(pBuffer);
+ return sal_False;
+ }
+*/
+ TypeReader reader = typeMgr.getTypeReader(typeName);
+
+ if (!reader.isValid())
+ {
+ if (typeName.equals("/"))
+ {
+ return sal_True;
+ } else
+ {
+ return sal_False;
+ }
+ }
+ RegistryKey typeKey;
+ if ( regKey.createKey( OStringToOUString(typeName, RTL_TEXTENCODING_UTF8), typeKey) )
+ {
+// rtl_freeMemory(pBuffer);
+ return sal_False;
+ }
+
+ if ( typeKey.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)reader.getBlop(), reader.getBlopSize()) )
+// if ( typeKey.setValue(OUString(), valueType, pBuffer, valueSize) )
+ {
+// rtl_freeMemory(pBuffer);
+ return sal_False;
+ }
+
+// rtl_freeMemory(pBuffer);
+ }
+ }
+
+ typeDependencies.setGenerated(typeName);
+ sal_Bool ret = produceDependedTypes(typeName, typeMgr, typeDependencies,
+ pOptions, o, regKey, filterTypes);
+
+ return ret;
+}
+
+
+
diff --git a/rdbmaker/source/rdbmaker/rdbtype.hxx b/rdbmaker/source/rdbmaker/rdbtype.hxx
new file mode 100644
index 000000000000..54f957a96108
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdbtype.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdbtype.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RDBMAKER_RDBTYPE_HXX_
+#define _RDBMAKER_RDBTYPE_HXX_
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+sal_Bool checkFilterTypes(const ::rtl::OString& type);
+void cleanUp(sal_Bool);
+
+class RdbOptions;
+class FileStream;
+class RegistryKey;
+
+sal_Bool produceType(const ::rtl::OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ RdbOptions* pOptions,
+ FileStream& o,
+ RegistryKey& regKey,
+ StringSet& filterTypes)
+ throw( CannotDumpException );
+
+#endif // _RDBMAKER_RDBTYPE_HXX_
+
diff --git a/rdbmaker/source/rdbmaker/specialtypemanager.cxx b/rdbmaker/source/rdbmaker/specialtypemanager.cxx
new file mode 100644
index 000000000000..11c49419cd69
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/specialtypemanager.cxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * $RCSfile: specialtypemanager.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#include "specialtypemanager.hxx"
+
+extern "C"
+{
+sal_Bool SAL_CALL initTypeMapper( const sal_Char* pRegName );
+sal_uInt32 SAL_CALL getTypeBlop(const sal_Char* pTypeName, sal_uInt8** pBlop);
+}
+
+using namespace rtl;
+
+SpecialTypeManager::SpecialTypeManager()
+{
+ m_pImpl = new SpecialTypeManagerImpl();
+ acquire();
+}
+
+SpecialTypeManager::~SpecialTypeManager()
+{
+ release();
+}
+
+void SpecialTypeManager::acquire()
+{
+ TypeManager::acquire();
+}
+
+void SpecialTypeManager::release()
+{
+ if (0 == TypeManager::release())
+ {
+ delete m_pImpl;
+ }
+}
+
+sal_Bool SpecialTypeManager::init(const OString& registryName)
+{
+ return initTypeMapper( registryName.getStr() );
+}
+
+TypeReader SpecialTypeManager::getTypeReader(const OString& name)
+{
+ TypeReader reader;
+
+ sal_uInt8* pBlop = NULL;
+ sal_uInt32 blopSize = 0;
+
+ if ( (blopSize = getTypeBlop( name.getStr(), &pBlop)) > 0 )
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ reader = TypeReader(rReaderLoader, pBlop, blopSize, sal_True);
+ }
+
+ if ( pBlop )
+ {
+ rtl_freeMemory(pBlop);
+ }
+
+ return reader;
+}
+
+RTTypeClass SpecialTypeManager::getTypeClass(const OString& name)
+{
+ if (m_pImpl->m_t2TypeClass.count(name) > 0)
+ {
+ return m_pImpl->m_t2TypeClass[name];
+ } else
+ {
+ }
+
+ return RT_TYPE_INVALID;
+}
+
+
diff --git a/rdbmaker/source/rdbmaker/specialtypemanager.hxx b/rdbmaker/source/rdbmaker/specialtypemanager.hxx
new file mode 100644
index 000000000000..567c8dabf464
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/specialtypemanager.hxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: specialtypemanager.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <hash_map>
+
+#ifndef _SPECIALTYPEMANAGER_HXX_
+#define _SPECIALTYPEMANAGER_HXX_
+
+#ifndef _CODEMAKER_REGISTRY_HXX_
+#include <codemaker/registry.hxx>
+#endif
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+
+struct SpecialTypeManagerImpl
+{
+ T2TypeClassMap m_t2TypeClass;
+};
+
+class SpecialTypeManager : public TypeManager
+{
+public:
+ SpecialTypeManager();
+ ~SpecialTypeManager();
+
+ SpecialTypeManager( const SpecialTypeManager& value )
+ : TypeManager(value)
+ , m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+
+ sal_Bool init(const ::rtl::OString& registryName);
+
+ sal_Bool isValidType(const ::rtl::OString& name)
+ { return sal_True; }
+ TypeReader getTypeReader(const ::rtl::OString& name);
+ RTTypeClass getTypeClass(const ::rtl::OString& name);
+
+ sal_Int32 getSize() { return m_pImpl->m_t2TypeClass.size(); }
+
+protected:
+ void acquire();
+ void release();
+
+protected:
+ SpecialTypeManagerImpl* m_pImpl;
+};
+
+#endif // _CODEMAKER_TYPEMANAGER_HXX_
diff --git a/rdbmaker/source/rdbmaker/typeblop.cxx b/rdbmaker/source/rdbmaker/typeblop.cxx
new file mode 100644
index 000000000000..2cc82d397c4f
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/typeblop.cxx
@@ -0,0 +1,517 @@
+/*************************************************************************
+ *
+ * $RCSfile: typeblop.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef __REGISTRY_REFLWRIT_HXX__
+#include <registry/reflwrit.hxx>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XINTERFACETYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XInterfaceTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XINTERFACEMETHODTYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XINTERFACEATTRIBUTETYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XMETHODPARAMETER_HPP_
+#include <com/sun/star/reflection/XMethodParameter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XCOMPOUNDTYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XCompoundTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XINDIRECTTYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XENUMTYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XEnumTypeDescription.hpp>
+#endif
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+using namespace cppu;
+//using namespace osl;
+using namespace rtl;
+
+static Reference< XHierarchicalNameAccess > xNameAccess;
+
+sal_uInt32 writeConstantData( const RegistryTypeWriterLoader& rLoader,
+ const OUString& typeName,
+ const Any& aTypeAny,
+ sal_uInt8** pBlop )
+{
+ sal_uInt32 lastIndex = typeName.lastIndexOf('.');
+ OUString uModuleName( typeName.copy(0, lastIndex) );
+ OUString uConstName( typeName.copy(lastIndex + 1) );
+
+ RegistryTypeWriter writer(rLoader, RT_TYPE_MODULE, uModuleName.replace('.', '/'),
+ OUString(), 1, 0, 0);
+
+ RTConstValue constValue;
+ OUString uConstTypeName;
+ switch ( aTypeAny.getValueTypeClass() )
+ {
+ case TypeClass_BOOLEAN:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("boolean") );
+ constValue.m_type = RT_TYPE_BOOL;
+ aTypeAny >>= constValue.m_value.aBool;
+ }
+ break;
+ case TypeClass_BYTE:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("byte") );
+ constValue.m_type = RT_TYPE_BYTE;
+ aTypeAny >>= constValue.m_value.aByte;
+ }
+ break;
+ case TypeClass_SHORT:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("short") );
+ constValue.m_type = RT_TYPE_INT16;
+ aTypeAny >>= constValue.m_value.aShort;
+ }
+ break;
+ case TypeClass_UNSIGNED_SHORT:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("unsigned short") );
+ constValue.m_type = RT_TYPE_UINT16;
+ aTypeAny >>= constValue.m_value.aUShort;
+ }
+ break;
+ case TypeClass_LONG:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("long") );
+ constValue.m_type = RT_TYPE_INT32;
+ aTypeAny >>= constValue.m_value.aLong;
+ }
+ break;
+ case TypeClass_UNSIGNED_LONG:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("unsigned long") );
+ constValue.m_type = RT_TYPE_UINT32;
+ aTypeAny >>= constValue.m_value.aULong;
+ }
+ break;
+ case TypeClass_FLOAT:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("float") );
+ constValue.m_type = RT_TYPE_FLOAT;
+ aTypeAny >>= constValue.m_value.aFloat;
+ }
+ break;
+ case TypeClass_DOUBLE:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("double") );
+ constValue.m_type = RT_TYPE_DOUBLE;
+ aTypeAny >>= constValue.m_value.aDouble;
+ }
+ break;
+ case TypeClass_STRING:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("string") );
+ constValue.m_type = RT_TYPE_STRING;
+ constValue.m_value.aString = ((OUString*)aTypeAny.getValue())->getStr();
+ }
+ break;
+ }
+
+ writer.setFieldData(1, uConstName, uConstTypeName, OUString(),
+ OUString(), RT_ACCESS_CONST, constValue);
+
+ sal_uInt32 length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+
+ return length;
+}
+
+sal_uInt32 getInheritedMemberCount( Reference< XTypeDescription >& xType )
+{
+ sal_uInt32 memberCount = 0;
+ if ( xType->getTypeClass() == TypeClass_INTERFACE )
+ {
+ Reference< XInterfaceTypeDescription > xIFace(xType, UNO_QUERY);
+
+ if ( !xIFace.is() )
+ return memberCount;
+
+ Reference< XTypeDescription > xSuperType = xIFace->getBaseType();
+
+ if ( xSuperType.is() )
+ memberCount = getInheritedMemberCount( xSuperType );
+
+ memberCount += xIFace->getMembers().getLength();
+ }
+// } else
+// if ( xType->getTypeClass() == TypeClass_Struct || xType->getTypeClass() == TypeClass_Exception )
+// {
+// Reference< XCompoundTypeDescription > xComp(xType, UNO_QUERY);
+//
+// if ( xComp.is() )
+// return membercount;
+//
+// Reference< XTypeDescription > xSuperType = xComp->getBaseType();
+//
+// if ( xSuperType.is() )
+// memberCount = getInheritedMemberCount( xSuperType );
+//
+// memberCount += xComp->getMemberNames().getLength();
+// }
+
+ return memberCount;
+}
+
+void writeMethodData( RegistryTypeWriter& rWriter, sal_uInt32 inheritedMmeberCount,
+ const Reference< XInterfaceMemberTypeDescription >& xMember,
+ const Reference< XInterfaceMethodTypeDescription >& xMethod )
+{
+ RTMethodMode methodMode = RT_MODE_TWOWAY;
+ if ( xMethod->isOneway() )
+ {
+ methodMode = RT_MODE_ONEWAY;
+ }
+
+ Sequence< Reference< XMethodParameter > > parameters( xMethod->getParameters() );
+ Sequence< Reference< XTypeDescription > > exceptions( xMethod->getExceptions() );
+ sal_uInt32 methodIndex = xMember->getPosition() - inheritedMmeberCount;
+ sal_uInt32 paramCount = parameters.getLength();
+ sal_uInt32 exceptionCount = exceptions.getLength();
+
+ rWriter.setMethodData(methodIndex, xMember->getMemberName(),
+ xMethod->getReturnType()->getName().replace('.', '/'),
+ methodMode, paramCount, exceptionCount, OUString());
+
+ RTParamMode paramMode = RT_PARAM_IN;
+ for (sal_Int32 i=0; i < paramCount; i++)
+ {
+ Reference< XMethodParameter > xParam = parameters[i];
+ if ( xParam->isIn() && xParam->isOut())
+ {
+ paramMode = RT_PARAM_INOUT;
+ } else
+ if ( xParam->isIn() )
+ {
+ paramMode = RT_PARAM_IN;
+ } else
+ if ( xParam->isOut() )
+ {
+ paramMode = RT_PARAM_OUT;
+ }
+
+ rWriter.setParamData(methodIndex, xParam->getPosition(), xParam->getType()->getName().replace('.', '/'),
+ xParam->getName(), paramMode);
+ }
+
+ for (i=0; i < exceptionCount; i++)
+ {
+ rWriter.setExcData(methodIndex, i, exceptions[i]->getName().replace('.', '/'));
+ }
+}
+
+extern "C"
+{
+
+sal_Bool SAL_CALL initTypeMapper( const sal_Char* pRegName )
+{
+ try
+ {
+ if (!pRegName)
+ return sal_False;
+
+ Reference< XMultiServiceFactory > xSMgr( createRegistryServiceFactory( OUString::createFromAscii(pRegName) ) );
+
+ if ( !xSMgr.is() )
+ return sal_False;
+
+ Reference< XInterface > xIFace( xSMgr->createInstance(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.TypeDescriptionManager"))) );
+
+ if ( !xIFace.is() )
+ return sal_False;
+
+ Reference< XHierarchicalNameAccess > xNAccess(xIFace, UNO_QUERY);
+
+ if ( !xNAccess.is() )
+ return sal_False;
+
+ xNameAccess = xNAccess;
+ }
+ catch( Exception& )
+ {
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+sal_uInt32 SAL_CALL getTypeBlop(const sal_Char* pTypeName, sal_uInt8** pBlop)
+{
+ sal_uInt32 length = 0;
+
+ if ( !pTypeName )
+ return length;
+
+ OUString uTypeName( OUString::createFromAscii(pTypeName).replace('/', '.') );
+ try
+ {
+ Any aTypeAny( xNameAccess->getByHierarchicalName( uTypeName ) );
+
+ if ( !aTypeAny.hasValue() )
+ return length;
+
+ RegistryTypeWriterLoader rtwLoader;
+ if ( !rtwLoader.isLoaded() )
+ return length;
+
+ if ( aTypeAny.getValueTypeClass() != TypeClass_INTERFACE )
+ {
+ return writeConstantData( rtwLoader, uTypeName, aTypeAny, pBlop );
+ }
+
+ Reference< XTypeDescription > xType;
+ aTypeAny >>= xType;
+
+ if ( !xType.is() )
+ return length;
+
+ switch (xType->getTypeClass())
+ {
+ case TypeClass_INTERFACE:
+ {
+ Reference< XInterfaceTypeDescription > xIFace(xType, UNO_QUERY);
+
+ if ( !xIFace.is() )
+ return length;
+
+ Reference< XInterfaceAttributeTypeDescription > xAttr;
+ Reference< XInterfaceMethodTypeDescription > xMethod;
+ Sequence< Reference< XInterfaceMemberTypeDescription > > memberTypes( xIFace->getMembers());
+ sal_uInt32 memberCount = memberTypes.getLength();
+ sal_uInt32 attrCount = 0;
+ sal_uInt32 inheritedMemberCount = 0;
+
+ for (sal_Int32 i=0; i < memberCount; i++)
+ {
+ xAttr = Reference< XInterfaceAttributeTypeDescription >(memberTypes[i], UNO_QUERY);
+ if ( xAttr.is() )
+ {
+ attrCount++;
+ }
+ }
+
+ OUString uSuperType;
+ Reference< XTypeDescription > xSuperType = xIFace->getBaseType();
+ if ( xSuperType.is() )
+ {
+ uSuperType = xSuperType->getName().replace('.','/');
+ inheritedMemberCount = getInheritedMemberCount( xSuperType );
+ }
+
+ RegistryTypeWriter writer(rtwLoader, RT_TYPE_INTERFACE, uTypeName.replace('.', '/'),
+ uSuperType, attrCount, memberCount-attrCount, 0);
+
+ Uik uik = xIFace->getUik();
+ RTUik rtUik = { uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5 };
+ writer.setUik( rtUik );
+
+ RTFieldAccess attrAccess = RT_ACCESS_READWRITE;
+ for (i=0; i < memberCount; i++)
+ {
+ xAttr = Reference< XInterfaceAttributeTypeDescription >(memberTypes[i], UNO_QUERY);
+ if ( xAttr.is() )
+ {
+ if (xAttr->isReadOnly())
+ {
+ attrAccess = RT_ACCESS_READONLY;
+ } else
+ {
+ attrAccess = RT_ACCESS_READWRITE;
+ }
+ writer.setFieldData(memberTypes[i]->getPosition() - inheritedMemberCount,
+ memberTypes[i]->getMemberName(),
+ xAttr->getType()->getName().replace('.', '/'),
+ OUString(), OUString(), attrAccess);
+ continue;
+ }
+
+ xMethod = Reference< XInterfaceMethodTypeDescription >(memberTypes[i], UNO_QUERY);
+ if ( xMethod.is() )
+ {
+ writeMethodData( writer, inheritedMemberCount, memberTypes[i], xMethod );
+ }
+ }
+
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ case TypeClass_STRUCT:
+ case TypeClass_EXCEPTION:
+ {
+ RTTypeClass rtTypeClass = RT_TYPE_STRUCT;
+ if (xType->getTypeClass() == TypeClass_EXCEPTION)
+ {
+ rtTypeClass = RT_TYPE_EXCEPTION;
+ }
+
+ Reference< XCompoundTypeDescription > xComp(xType, UNO_QUERY);
+
+ if ( !xComp.is() )
+ return length;
+
+ Sequence< OUString > memberNames( xComp->getMemberNames());
+ Sequence< Reference< XTypeDescription > > memberTypes( xComp->getMemberTypes());
+ sal_uInt32 memberCount = memberNames.getLength();
+
+ OUString uSuperType;
+ Reference< XTypeDescription > xSuperType = xComp->getBaseType();
+ if ( xSuperType.is() )
+ {
+ uSuperType = xSuperType->getName().replace('.','/');
+ }
+
+ RegistryTypeWriter writer(rtwLoader, rtTypeClass, uTypeName.replace('.', '/'),
+ uSuperType, memberCount, 0, 0);
+
+ for (sal_Int32 i=0; i < memberCount; i++)
+ {
+ writer.setFieldData(i , memberNames[i], memberTypes[i]->getName().replace('.', '/'),
+ OUString(), OUString(), RT_ACCESS_READWRITE);
+ }
+
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ case TypeClass_ENUM:
+ {
+ Reference< XEnumTypeDescription > xEnum(xType, UNO_QUERY);
+
+ if ( !xEnum.is() )
+ return length;
+
+ Sequence< OUString > enumNames( xEnum->getEnumNames());
+ Sequence< sal_Int32 > enumValues( xEnum->getEnumValues());
+ sal_uInt32 enumCount = enumNames.getLength();
+
+ RegistryTypeWriter writer(rtwLoader, RT_TYPE_ENUM, uTypeName.replace('.', '/'),
+ OUString(), enumCount, 0, 0);
+
+ RTConstValue constValue;
+ for (sal_Int32 i=0; i < enumCount; i++)
+ {
+ constValue.m_type = RT_TYPE_INT32;
+ constValue.m_value.aLong = enumValues[i];
+
+ writer.setFieldData(i, enumNames[i], OUString(), OUString(), OUString(),
+ RT_ACCESS_CONST, constValue);
+ }
+
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ case TypeClass_TYPEDEF:
+ {
+ Reference< XIndirectTypeDescription > xTD(xType, UNO_QUERY);
+
+ if ( !xTD.is() )
+ return length;
+
+ RegistryTypeWriter writer(rtwLoader, RT_TYPE_TYPEDEF, uTypeName.replace('.', '/'),
+ xTD->getReferencedType()->getName().replace('.', '/'),
+ 0, 0, 0);
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ }
+
+ }
+ catch( Exception& )
+ {
+ }
+
+ return length;
+}
+
+} // extern "C"
+
+
+
diff --git a/remotebridges/prj/d.lst b/remotebridges/prj/d.lst
new file mode 100644
index 000000000000..3badb71ad01b
--- /dev/null
+++ b/remotebridges/prj/d.lst
@@ -0,0 +1,6 @@
+..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*
+..\%__SRC%\bin\*.rdb %_DEST%\rdb%_EXT%\*
+..\source\factory\brdgfctr.xml %_DEST%\xml%_EXT%\brdgfctr.xml
+..\source\iiop\iiopbrdg.xml %_DEST%\xml%_EXT%\iiopbrdg.xml
+..\source\unourl_resolver\uuresolver.xml %_DEST%\xml%_EXT%\uuresolver.xml
+..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\*
diff --git a/remotebridges/source/factory/brdgfctr.xml b/remotebridges/source/factory/brdgfctr.xml
new file mode 100644
index 000000000000..fde129c103c7
--- /dev/null
+++ b/remotebridges/source/factory/brdgfctr.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Joerg Budischewski </Author>
+
+<Name> com.sun.star.comp.remotebridges.BridgeFactory </Name>
+
+<Description>
+ This component allows
+ to establish a connection to another process.
+</Description>
+
+<ModuleName> brdgfctr </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> com.sun.star.bridge.BridgeFactory </SupportedService>
+
+<ServiceDependency> ... </ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> vos </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper2 </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu2 </RuntimeModuleDependency>
+<RuntimeModuleDependency> vos2 </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal2 </RuntimeModuleDependency>
+
+
+<Type> com.sun.star.bridge.XBridgeFactory </Type>
+<Type> com.sun.star.bridge.XInstanceProvider </Type>
+<Type> com.sun.star.bridge.XBridge </Type>
+<Type> com.sun.star.bridge.BridgeExistsException </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XInitialization </Type>
+<Type> com.sun.star.lang.XComponent </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.IllegalArgumentException </Type>
+<Type> com.sun.star.lang.XInitialization </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/remotebridges/source/factory/bridgefactory.cxx b/remotebridges/source/factory/bridgefactory.cxx
new file mode 100644
index 000000000000..e58a4b99017a
--- /dev/null
+++ b/remotebridges/source/factory/bridgefactory.cxx
@@ -0,0 +1,412 @@
+/*************************************************************************
+ *
+ * $RCSfile: bridgefactory.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <hash_map>
+#include <vector>
+
+#include <rtl/alloc.h>
+
+#include <uno/mapping.hxx>
+
+#include <bridges/remote/context.h>
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/component.hxx>
+#include <cppuhelper/typeprovider.hxx>
+
+#include <com/sun/star/lang/XInitialization.hpp>
+
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+#include "bridgeimpl.hxx"
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::std;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::bridge;
+using namespace ::com::sun::star::connection;
+using namespace ::com::sun::star::registry;
+
+#define SERVICE_NAME "com.sun.star.bridge.BridgeFactory"
+#define IMPLEMENTATION_NAME "com.sun.star.comp.remotebridges.BridgeFactory"
+
+namespace remotebridges_factory
+{
+ struct hashOWString
+ {
+ size_t operator()(const OUString & s) const
+ { return s.hashCode(); }
+ };
+
+ struct equalOWString
+ {
+ sal_Bool operator()(const OUString & s1 , const OUString &s2 ) const
+ {
+ return s1 == s2;
+ }
+ };
+
+ typedef ::std::hash_map
+ <
+ OUString,
+ WeakReference< XBridge >,
+ hashOWString,
+ equalOWString
+ > BridgeHashMap;
+
+
+ class OBridgeFactory :
+ public MyMutex,
+ public OComponentHelper,
+ public XBridgeFactory
+ {
+ public:
+ OBridgeFactory( const Reference < XMultiServiceFactory > &rSMgr );
+
+ public: // XInterface
+ ::com::sun::star::uno::Any SAL_CALL
+ queryInterface( const ::com::sun::star::uno::Type & aType );
+
+ void SAL_CALL acquire()
+ { OComponentHelper::acquire(); }
+ void SAL_CALL release()
+ { OComponentHelper::release(); }
+
+ public:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::bridge::XBridge > SAL_CALL
+ createBridge(
+ const ::rtl::OUString& sName,
+ const ::rtl::OUString& sProtocol,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::connection::XConnection >& aConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::bridge::XInstanceProvider >& anInstanceProvider )
+ throw(::com::sun::star::bridge::BridgeExistsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::bridge::XBridge > SAL_CALL
+ getBridge( const ::rtl::OUString& sName )
+ throw(::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::bridge::XBridge > > SAL_CALL
+ getExistingBridges( ) throw(::com::sun::star::uno::RuntimeException);
+
+ public: //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
+ getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
+ getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ private:
+ Reference < XMultiServiceFactory > m_rSMgr;
+ BridgeHashMap m_mapBridge;
+ };
+
+ OBridgeFactory::OBridgeFactory( const Reference < XMultiServiceFactory > &rSMgr ) :
+ OComponentHelper( m_mutex ),
+ m_rSMgr( rSMgr )
+ {
+
+ }
+
+ Any OBridgeFactory::queryInterface( const Type &aType )
+ {
+ Any a = ::cppu::queryInterface(
+ aType ,
+ ( XBridgeFactory * ) this );
+ if( a.hasValue() )
+ {
+ return a;
+ }
+
+ return OComponentHelper::queryInterface( aType );
+
+ }
+
+ Reference< XBridge > OBridgeFactory::createBridge(
+ const OUString& sName,
+ const OUString& sProtocol,
+ const Reference< XConnection >& aConnection,
+ const Reference< XInstanceProvider >& anInstanceProvider )
+ throw(::com::sun::star::bridge::BridgeExistsException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException)
+ {
+ OUString sService = OUString::createFromAscii( "com.sun.star.bridge.Bridge." );
+ OUString sProtocolName = sProtocol;
+ sal_Int32 nIndex = sProtocol.indexOf( (sal_Unicode)',' );
+ if( nIndex > 0 )
+ {
+ sProtocolName = sProtocol.copy( 0 , nIndex );
+ }
+ sService += sProtocolName;
+
+ Reference < XInterface > rXInterface = m_rSMgr->createInstance ( sService );
+ Reference < XInitialization > rInit = Reference< XInitialization > (
+ rXInterface,
+ UNO_QUERY );
+
+ Reference < XBridge > rBridge( rInit , UNO_QUERY );
+ if( rInit.is() && rBridge.is() )
+ {
+ Sequence < Any > seqAny( 4 );
+ seqAny.getArray()[0] <<= sName;
+ seqAny.getArray()[1] <<= sProtocol;
+ seqAny.getArray()[2] <<= aConnection;
+ seqAny.getArray()[3] <<= anInstanceProvider;
+
+ // let the Exceptions fly ....
+ rInit->initialize( seqAny );
+ }
+ else
+ {
+ throw IllegalArgumentException();
+ }
+
+ if( sName.getLength() )
+ {
+ MutexGuard guard( m_mutex );
+ // put the bridge into the hashmap
+ m_mapBridge[ sName ] = rBridge;
+ }
+ return rBridge;
+ }
+
+ Reference< XBridge > OBridgeFactory::getBridge( const ::rtl::OUString& sName )
+ throw(::com::sun::star::uno::RuntimeException )
+
+ {
+ MutexGuard guard( m_mutex );
+ BridgeHashMap::iterator ii = m_mapBridge.find( sName );
+
+ Reference < XBridge > rBridge;
+
+ if( ii != m_mapBridge.end() )
+ {
+ rBridge = (*ii).second;
+ if( ! rBridge.is() )
+ {
+ m_mapBridge.erase( ii );
+ }
+ }
+
+ if( ! rBridge.is() )
+ {
+ // try to get it via the C-Context
+ remote_Context * pRemoteC = remote_getContext( sName.pData );
+
+ if( pRemoteC )
+ {
+ rBridge = Reference < XBridge > ((XBridge *) new OBridge( pRemoteC ) );
+ pRemoteC->aBase.release( (uno_Context * )pRemoteC );
+ m_mapBridge[ sName ] = rBridge;
+ }
+ }
+ return rBridge;
+ }
+
+ Sequence< Reference< XBridge > > OBridgeFactory::getExistingBridges( )
+ throw(::com::sun::star::uno::RuntimeException)
+ {
+ MutexGuard guard( m_mutex );
+
+ sal_Int32 nCount;
+
+ rtl_uString **ppName = remote_getContextList(
+ &nCount,
+ rtl_allocateMemory );
+
+ Sequence < Reference < XBridge > > seq( nCount );
+ if( nCount )
+ {
+
+ for( sal_Int32 i = 0;
+ i < nCount ;
+ i ++ )
+ {
+ seq.getArray()[i] = getBridge( OUString( ppName[i]) );
+ rtl_uString_release( ppName[i] );
+ }
+ rtl_freeMemory( ppName );
+ }
+
+ return seq;
+ }
+
+ // XTypeProvider
+ Sequence< Type > SAL_CALL OBridgeFactory::getTypes(void) throw( RuntimeException )
+ {
+ static OTypeCollection *pCollection = 0;
+ if( ! pCollection )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pCollection )
+ {
+ static OTypeCollection collection(
+ getCppuType( (Reference< XBridgeFactory > * ) 0 ),
+ OComponentHelper::getTypes() );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+ }
+
+ Sequence< sal_Int8 > SAL_CALL OBridgeFactory::getImplementationId( ) throw( RuntimeException)
+ {
+ static OImplementationId *pId = 0;
+ if( ! pId )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pId )
+ {
+ static OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+ }
+
+
+
+ Reference< XInterface > SAL_CALL CreateInstance( const Reference< XMultiServiceFactory > &r)
+ {
+ return Reference < XInterface > (( OWeakObject * ) new OBridgeFactory( r ) );
+ }
+
+ Sequence< OUString > getSupportedServiceNames()
+ {
+ static Sequence < OUString > *pNames = 0;
+ if( ! pNames )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( !pNames )
+ {
+ static Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString::createFromAscii( SERVICE_NAME );
+ pNames = &seqNames;
+ }
+ }
+ return *pNames;
+ }
+}
+
+using namespace remotebridges_factory;
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii("/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
+
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ), CreateInstance, getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
+
+
diff --git a/remotebridges/source/factory/bridgeimpl.cxx b/remotebridges/source/factory/bridgeimpl.cxx
new file mode 100644
index 000000000000..1aaac99a00d0
--- /dev/null
+++ b/remotebridges/source/factory/bridgeimpl.cxx
@@ -0,0 +1,263 @@
+/*************************************************************************
+ *
+ * $RCSfile: bridgeimpl.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "bridgeimpl.hxx"
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::bridge;
+
+namespace remotebridges_factory {
+
+
+ OBridge::OBridge( remote_Context *pContext ) :
+ OComponentHelper( m_mutex ),
+ m_pContext( pContext )
+ {
+ remote_DisposingListener::acquire = thisAcquire;
+ remote_DisposingListener::release = thisRelease;
+ remote_DisposingListener::disposing = thisDisposing;
+
+ m_pContext->aBase.acquire( (uno_Context*)m_pContext );
+ m_pContext->addDisposingListener( m_pContext, ( remote_DisposingListener * ) this );
+ }
+
+ OBridge::~OBridge()
+ {
+ if( m_pContext )
+ {
+ m_pContext->aBase.release( (uno_Context * ) m_pContext );
+ }
+ }
+
+ ::com::sun::star::uno::Any OBridge::queryInterface( const ::com::sun::star::uno::Type & aType )
+ {
+ Any a = ::cppu::queryInterface(
+ aType ,
+ SAL_STATIC_CAST( XBridge * , this ),
+ SAL_STATIC_CAST( XTypeProvider * , this ) );
+ if( a.hasValue() )
+ {
+ return a;
+ }
+
+ return OComponentHelper::queryInterface( aType );
+ }
+
+ void OBridge::disposing()
+ {
+ if( m_pContext )
+ {
+ m_pContext->removeDisposingListener( m_pContext , ( remote_DisposingListener * )this);
+
+ uno_Environment *pEnvRemote = 0;
+ if( m_pContext->m_pConnection )
+ {
+ OUString sProtocol = OUString( m_pContext->m_pProtocol ).getToken( 0 , ',' );
+ uno_getEnvironment( &pEnvRemote , sProtocol.pData , m_pContext );
+ OSL_ASSERT( pEnvRemote );
+ }
+ else
+ {
+ // within disposing from the context, no further dispose necessary !
+ }
+
+ if( pEnvRemote )
+ {
+ pEnvRemote->dispose( pEnvRemote );
+ pEnvRemote->release( pEnvRemote );
+ pEnvRemote = 0;
+ }
+
+ m_pContext->aBase.release( (uno_Context*)m_pContext );
+ m_pContext = 0;
+ }
+
+ }
+
+
+ Reference< XInterface > OBridge::getInstance( const ::rtl::OUString& sInstanceName )
+ throw(::com::sun::star::uno::RuntimeException)
+ {
+
+ Reference < XInterface > rReturn;
+
+ if( m_pContext && m_pContext->getRemoteInstance )
+ {
+ // get the appropriate remote environment
+ OUString sRemote( RTL_CONSTASCII_USTRINGPARAM( UNO_LB_REMOTE ));
+ uno_Environment *pEnvRemote = 0;
+ uno_getEnvironment( &pEnvRemote , sRemote.pData , m_pContext );
+
+ OSL_ASSERT( pEnvRemote );
+
+ Type type = getCppuType( (Reference < XInterface > * ) 0 );
+
+ remote_Interface *pRemoteI = 0;
+ m_pContext->getRemoteInstance(
+ pEnvRemote,
+ &pRemoteI,
+ sInstanceName.pData,
+ type.getTypeLibType() );
+
+
+ if( pRemoteI )
+ {
+ // got an interface !
+ OUString sCppu ( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME ));
+ uno_Environment *pEnvCpp =0;
+ uno_getEnvironment( &pEnvCpp , sCppu.pData , 0 );
+
+ Mapping map( pEnvRemote , pEnvCpp );
+
+ XInterface * pCppI = ( XInterface * ) map.mapInterface( pRemoteI,type );
+
+ rReturn = Reference<XInterface > ( pCppI );
+
+ pCppI->release( );
+
+ pRemoteI->release( pRemoteI );
+ pEnvCpp->release( pEnvCpp );
+ }
+
+ pEnvRemote->release( pEnvRemote );
+ }
+ return rReturn;
+ }
+
+ ::rtl::OUString SAL_CALL OBridge::getName( )
+ throw(::com::sun::star::uno::RuntimeException)
+
+ {
+ return OUString( m_pContext->m_pName );
+ }
+
+ ::rtl::OUString OBridge::getDescription( )
+ throw(::com::sun::star::uno::RuntimeException)
+ {
+ return OUString( m_pContext->m_pDescription );
+ }
+
+ // XTypeProvider
+ Sequence< Type > SAL_CALL OBridge::getTypes(void) throw( RuntimeException )
+ {
+ static OTypeCollection *pCollection = 0;
+ if( ! pCollection )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pCollection )
+ {
+ static OTypeCollection collection(
+ getCppuType( (Reference< XTypeProvider> * )0),
+ getCppuType( (Reference< XBridge > * ) 0 ),
+ OComponentHelper::getTypes() );
+ pCollection = &collection;
+ }
+ }
+
+ return (*pCollection).getTypes();
+ }
+
+ Sequence< sal_Int8 > SAL_CALL OBridge::getImplementationId( ) throw( RuntimeException)
+ {
+ static OImplementationId *pId = 0;
+ if( ! pId )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pId )
+ {
+ static OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+ }
+
+ //----------------------
+ // static methods
+ //----------------------
+ void OBridge::thisAcquire( remote_DisposingListener *p )
+ {
+ OBridge *m = (OBridge * ) p;
+ m->acquire();
+ }
+
+ void OBridge::thisRelease( remote_DisposingListener *p )
+ {
+ OBridge *m = (OBridge * ) p;
+ m->release();
+ }
+
+ void OBridge::thisDisposing( remote_DisposingListener * p,
+ rtl_uString *pString )
+ {
+ OBridge *m = (OBridge * ) p;
+ m->dispose();
+ }
+
+
+}
+
+
+
diff --git a/remotebridges/source/factory/bridgeimpl.hxx b/remotebridges/source/factory/bridgeimpl.hxx
new file mode 100644
index 000000000000..03a144a23358
--- /dev/null
+++ b/remotebridges/source/factory/bridgeimpl.hxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * $RCSfile: bridgeimpl.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <osl/mutex.hxx>
+#include <osl/diagnose.h>
+
+#include <uno/mapping.hxx>
+#include <uno/environment.h>
+
+#include <bridges/remote/context.h>
+#include <bridges/remote/remote.h>
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/component.hxx>
+#include <cppuhelper/typeprovider.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+
+#include <com/sun/star/bridge/XBridge.hpp>
+#include <com/sun/star/bridge/XInstanceProvider.hpp>
+
+namespace remotebridges_factory {
+
+ struct MyMutex
+ {
+ ::osl::Mutex m_mutex;
+ };
+
+ class OBridge :
+ public MyMutex,
+ public remote_DisposingListener,
+ public ::com::sun::star::bridge::XBridge,
+ public ::cppu::OComponentHelper
+ {
+ public:
+ OBridge( remote_Context *pContext );
+ ~OBridge();
+
+ // XInterface
+ public:
+ ::com::sun::star::uno::Any SAL_CALL
+ queryInterface( const ::com::sun::star::uno::Type & aType );
+
+ void SAL_CALL acquire()
+ { OComponentHelper::acquire(); }
+ void SAL_CALL release()
+ { OComponentHelper::release(); }
+
+ public:
+ virtual void SAL_CALL disposing(); // called by OComponentHelper
+
+ public:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ getInstance( const ::rtl::OUString& sInstanceName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getName( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDescription( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ public:
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
+ getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
+ getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ public:
+ static void SAL_CALL thisAcquire( remote_DisposingListener * );
+ static void SAL_CALL thisRelease( remote_DisposingListener * );
+ static void SAL_CALL thisDisposing( remote_DisposingListener * ,
+ rtl_uString * pBridgeName );
+
+ public:
+ remote_Context *m_pContext;
+ ::rtl::OString m_sName;
+ ::rtl::OString m_sDescription;
+ };
+}
+
diff --git a/remotebridges/source/factory/makefile.mk b/remotebridges/source/factory/makefile.mk
new file mode 100644
index 000000000000..1101522fab67
--- /dev/null
+++ b/remotebridges/source/factory/makefile.mk
@@ -0,0 +1,108 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=remotebridges
+TARGET=brdgfctr
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+COMP1TYPELIST=$(TARGET)
+COMPRDB=$(SOLARBINDIR)$/applicat.rdb
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+# ------------------------------------------------------------------
+UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb
+UNOUCROUT=$(OUT)$/inc$/factory
+INCPRE+= $(UNOUCROUT)
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+SLOFILES= \
+ $(SLO)$/bridgefactory.obj\
+ $(SLO)$/bridgeimpl.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(RMCXTLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/remotebridges/source/unourl_resolver/makefile.mk b/remotebridges/source/unourl_resolver/makefile.mk
new file mode 100644
index 000000000000..8c6815c3027e
--- /dev/null
+++ b/remotebridges/source/unourl_resolver/makefile.mk
@@ -0,0 +1,127 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:57 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=remotebridges
+TARGET=uuresolver
+USE_DEFFILE=TRUE
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb
+UNOUCROUT=$(OUT)$/inc$/uuresolver
+INCPRE+= $(UNOUCROUT)
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+UNOTYPES= \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.lang.XTypeProvider \
+ com.sun.star.lang.XServiceInfo \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.lang.XComponent \
+ com.sun.star.registry.XRegistryKey \
+ com.sun.star.connection.XConnector \
+ com.sun.star.bridge.XBridgeFactory \
+ com.sun.star.bridge.XUnoUrlResolver \
+ com.sun.star.uno.XAggregation \
+ com.sun.star.uno.XWeak
+
+SLOFILES= \
+ $(SLO)$/unourl_resolver.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+# NETBSD: somewhere we have to instantiate the static data members.
+# NETBSD-1.2.1 doesn't know about weak symbols so the default mechanism for GCC won't work.
+# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols
+.IF "$(OS)"=="NETBSD" || "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX"
+SLOFILES+=$(SLO)$/staticmb.obj
+.ENDIF
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/remotebridges/source/unourl_resolver/unourl_resolver.cxx b/remotebridges/source/unourl_resolver/unourl_resolver.cxx
new file mode 100644
index 000000000000..c21601305e11
--- /dev/null
+++ b/remotebridges/source/unourl_resolver/unourl_resolver.cxx
@@ -0,0 +1,269 @@
+/*************************************************************************
+ *
+ * $RCSfile: unourl_resolver.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:57 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+// #define TRACE(x) OSL_TRACE(x)
+#define TRACE(x)
+
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/connection/XConnector.hpp>
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
+
+using namespace cppu;
+using namespace rtl;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::connection;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::registry;
+
+#define SERVICENAME "com.sun.star.bridge.UnoUrlResolver"
+#define IMPLNAME "com.sun.star.comp.bridge.UnoUrlResolver"
+
+namespace unourl_resolver
+{
+
+//--------------------------------------------------------------------------------------------------
+inline static Sequence< OUString > getSupportedServiceNames()
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//==================================================================================================
+class ResolverImpl : public WeakImplHelper2< XServiceInfo, XUnoUrlResolver >
+{
+ Reference< XMultiServiceFactory > _xSMgr;
+
+public:
+ ResolverImpl( const Reference< XMultiServiceFactory > & xSMgr );
+ virtual ~ResolverImpl();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XUnoUrlResolver
+ virtual Reference< XInterface > SAL_CALL resolve( const OUString & rUnoUrl )
+ throw (NoConnectException, ConnectionSetupException, RuntimeException);
+};
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+ResolverImpl::ResolverImpl( const Reference< XMultiServiceFactory > & xSMgr )
+ : _xSMgr( xSMgr )
+{
+}
+//__________________________________________________________________________________________________
+ResolverImpl::~ResolverImpl()
+{
+}
+
+// XServiceInfo
+//__________________________________________________________________________________________________
+OUString ResolverImpl::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
+}
+//__________________________________________________________________________________________________
+sal_Bool ResolverImpl::supportsService( const OUString & rServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ {
+ if (pArray[nPos] == rServiceName)
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > ResolverImpl::getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return unourl_resolver::getSupportedServiceNames();
+}
+
+// XUnoUrlResolver
+//__________________________________________________________________________________________________
+Reference< XInterface > ResolverImpl::resolve( const OUString & rUnoUrl )
+ throw (NoConnectException, ConnectionSetupException, RuntimeException)
+{
+ if (rUnoUrl.getTokenCount( ';' ) != 3 || rUnoUrl.getLength() < 10 ||
+ !rUnoUrl.copy( 0, 4 ).equalsIgnoreCase( OUString( RTL_CONSTASCII_USTRINGPARAM("uno:") ) ))
+ {
+ throw ConnectionSetupException( OUString( RTL_CONSTASCII_USTRINGPARAM("illegal uno url given!" ) ), Reference< XInterface >() );
+ }
+
+ Reference< XConnector > xConnector( _xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector") ) ), UNO_QUERY );
+ if (! xConnector.is())
+ throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM("no connector!" ) ), Reference< XInterface >() );
+
+ OUString aConnectDescr( rUnoUrl.getToken( 0 ).copy( 4 ) ); // uno:CONNECTDESCR;iiop;InstanceName
+ OUString aInstanceName( rUnoUrl.getToken( 2 ) );
+
+ Reference< XConnection > xConnection( xConnector->connect( aConnectDescr ) );
+
+ Reference< XBridgeFactory > xBridgeFactory( _xSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory") ) ), UNO_QUERY );
+ if (! xBridgeFactory.is())
+ throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM("no bridge factory!" ) ), Reference< XInterface >() );
+
+ // bridge
+ Reference< XBridge > xBridge( xBridgeFactory->createBridge(
+ OUString(), rUnoUrl.getToken( 1 ),
+ xConnection, Reference< XInstanceProvider >() ) );
+
+ Reference< XInterface > xRet( xBridge->getInstance( aInstanceName ) );
+
+// if (! xRet.is()) // dispose bridge manually
+// {
+// Reference< XComponent > xComp( xBridge, UNO_QUERY );
+// if (xComp.is())
+// xComp->dispose();
+// }
+
+ return xRet;
+}
+
+//==================================================================================================
+static Reference< XInterface > SAL_CALL ResolverImpl_create( const Reference< XMultiServiceFactory > & xSMgr )
+{
+ return Reference< XInterface >( *new ResolverImpl( xSMgr ) );
+}
+
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+ xNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) ) );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
+ unourl_resolver::ResolverImpl_create,
+ unourl_resolver::getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
diff --git a/remotebridges/source/unourl_resolver/uuresolver.xml b/remotebridges/source/unourl_resolver/uuresolver.xml
new file mode 100644
index 000000000000..82645f838d2e
--- /dev/null
+++ b/remotebridges/source/unourl_resolver/uuresolver.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Daniel Boelzle </Author>
+
+<Name> com.sun.star.comp.bridge.UnoUrlResolver </Name>
+
+<Description>
+ This component allows
+ to retrieve an object reference from another process.
+</Description>
+
+<ModuleName> uuresolver </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> com.sun.star.bridge.UnoUrlResolver </SupportedService>
+
+<ServiceDependency> ... </ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper2 </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu2 </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal2 </RuntimeModuleDependency>
+
+
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.lang.XComponent </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.connection.XConnector </Type>
+<Type> com.sun.star.bridge.XBridgeFactory </Type>
+<Type> com.sun.star.bridge.XUnoUrlResolver </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/stoc/prj/d.lst b/stoc/prj/d.lst
new file mode 100644
index 000000000000..ae5dbff4a6de
--- /dev/null
+++ b/stoc/prj/d.lst
@@ -0,0 +1,25 @@
+mkdir: %_DEST%\inc%_EXT%\stoc
+
+..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*
+..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\*
+
+..\%__SRC%\bin\*.rdb %_DEST%\rdb%_EXT%\*
+
+..\source\componentdescription.dtd %_DEST%\xml%_EXT%\componentdescription.dtd
+
+..\source\corereflection\corefl.xml %_DEST%\xml%_EXT%\corefl.xml
+..\source\defaultregistry\defreg.xml %_DEST%\xml%_EXT%\defreg.xml
+..\source\implementationregistration\impreg.xml %_DEST%\xml%_EXT%\impreg.xml
+..\source\inspect\insp.xml %_DEST%\xml%_EXT%\insp.xml
+..\source\invocation\inv.xml %_DEST%\xml%_EXT%\inv.xml
+..\source\invocation_adapterfactory\invadp.xml %_DEST%\xml%_EXT%\invadp.xml
+..\source\io\io.xml %_DEST%\xml%_EXT%\io.xml
+..\source\javavm\jen.xml %_DEST%\xml%_EXT%\jen.xml
+..\source\loader\cpld.xml %_DEST%\xml%_EXT%\cpld.xml
+..\source\namingservice\namingservice.xml %_DEST%\xml%_EXT%\namingservice.xml
+..\source\proxy_factory\proxyfac.xml %_DEST%\xml%_EXT%\proxyfac.xml
+..\source\registry_tdprovider\rdbtdp.xml %_DEST%\xml%_EXT%\rdbtdp.xml
+..\source\servicemanager\smgr.xml %_DEST%\xml%_EXT%\smgr.xml
+..\source\simpleregistry\simreg.xml %_DEST%\xml%_EXT%\simreg.xml
+..\source\tdmanager\tdmgr.xml %_DEST%\xml%_EXT%\tdmgr.xml
+..\source\typeconv\tcv.xml %_DEST%\xml%_EXT%\tcv.xml
diff --git a/stoc/source/corereflection/base.hxx b/stoc/source/corereflection/base.hxx
new file mode 100644
index 000000000000..671aec5306e6
--- /dev/null
+++ b/stoc/source/corereflection/base.hxx
@@ -0,0 +1,558 @@
+/*************************************************************************
+ *
+ * $RCSfile: base.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+// #define TEST_LIST_CLASSES
+// #define TRACE(x) OSL_TRACE(x)
+#define TRACE(x)
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+
+#include "lrucache.hxx"
+
+#ifdef TEST_LIST_CLASSES
+#include <stl/list>
+#include <stl/algorithm>
+#endif
+#include <stl/hash_map>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+
+#include <com/sun/star/reflection/XIdlClass.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+#include <com/sun/star/reflection/XIdlField.hpp>
+#include <com/sun/star/reflection/XIdlMethod.hpp>
+
+using namespace std;
+using namespace osl;
+using namespace rtl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::container;
+
+
+namespace stoc_corefl
+{
+
+#ifdef TEST_LIST_CLASSES
+typedef list< OUString > ClassNameList;
+extern ClassNameList g_aClassNames;
+#endif
+
+//--------------------------------------------------------------------------------------------------
+Mutex & getMutexAccess();
+
+//--------------------------------------------------------------------------------------------------
+inline td_equals( typelib_TypeDescription * pTD,
+ typelib_TypeDescriptionReference * pType )
+{
+ return (pTD->pWeakRef == pType ||
+ (pTD->pTypeName->length == pType->pTypeName->length &&
+ rtl_ustr_compare( pTD->pTypeName->buffer, pType->pTypeName->buffer ) == 0));
+}
+//--------------------------------------------------------------------------------------------------
+inline typelib_TypeDescription * getTypeByName( const OUString & rName )
+{
+ typelib_TypeDescription * pTypeDescr = 0;
+ typelib_typedescription_getByName( &pTypeDescr, rName.pData );
+ if (! pTypeDescr->bComplete)
+ typelib_typedescription_complete( &pTypeDescr );
+ return pTypeDescr;
+}
+
+typedef std::hash_map< OUString, WeakReference< XIdlField >,
+ FctHashOUString, equal_to< OUString > > OUString2Field;
+typedef std::hash_map< OUString, WeakReference< XIdlMethod >,
+ FctHashOUString, equal_to< OUString > > OUString2Method;
+
+//==================================================================================================
+class IdlReflectionServiceImpl
+ : public OComponentHelper
+ , public XIdlReflection
+ , public XHierarchicalNameAccess
+ , public XServiceInfo
+{
+ Mutex _aComponentMutex;
+ Reference< XMultiServiceFactory > _xMgr;
+ Reference< XHierarchicalNameAccess > _xTDMgr;
+
+ // caching
+ LRU_CacheAnyByOUString _aElements;
+
+ inline Reference< XIdlClass > constructClass( typelib_TypeDescription * pTypeDescr );
+public:
+ Reference< XHierarchicalNameAccess > getTDMgr() const
+ { return _xTDMgr; }
+ Reference< XMultiServiceFactory > getSMgr() const
+ { return _xMgr; }
+
+ // ctor/ dtor
+ IdlReflectionServiceImpl( const Reference< XMultiServiceFactory > & xMgr );
+ virtual ~IdlReflectionServiceImpl();
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // some XComponent part from OComponentHelper
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // XIdlReflection
+ virtual Reference< XIdlClass > SAL_CALL forName( const OUString & rTypeName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XIdlClass > SAL_CALL getType( const Any & rObj ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XHierarchicalNameAccess
+ virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+
+ Reference< XIdlClass > forType( typelib_TypeDescription * pTypeDescr ) throw(::com::sun::star::uno::RuntimeException);
+ Reference< XIdlClass > forType( typelib_TypeDescriptionReference * pRef ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class IdlClassImpl
+ : public WeakImplHelper1< XIdlClass >
+{
+ IdlReflectionServiceImpl * _pReflection;
+
+ OUString _aName;
+ TypeClass _eTypeClass;
+
+ typelib_TypeDescription * _pTypeDescr;
+
+public:
+ typelib_TypeDescription * getTypeDescr() const
+ { return _pTypeDescr; }
+ IdlReflectionServiceImpl * getReflection() const
+ { return _pReflection; }
+ Reference< XMultiServiceFactory > getSMgr() const
+ { return _pReflection->getSMgr(); }
+ Reference< XHierarchicalNameAccess > getTDMgr() const
+ { return getReflection()->getTDMgr(); }
+
+ // Ctor
+ IdlClassImpl( IdlReflectionServiceImpl * pReflection,
+ const OUString & rName, typelib_TypeClass eTypeClass,
+ typelib_TypeDescription * pTypeDescr );
+ virtual ~IdlClassImpl();
+
+ // XIdlClassImpl default implementation
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL equals( const Reference< XIdlClass >& xType ) throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL createObject( Any & rObj ) throw(::com::sun::star::uno::RuntimeException);
+
+ // def impl ????
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getClasses() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XIdlClass > SAL_CALL getClass( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getInterfaces() throw(::com::sun::star::uno::RuntimeException);
+
+ // structs, interfaces
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses() throw(::com::sun::star::uno::RuntimeException);
+ // structs
+ virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException);
+ // interfaces
+ virtual Uik SAL_CALL getUik() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XIdlMethod > SAL_CALL getMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlMethod > > SAL_CALL getMethods() throw(::com::sun::star::uno::RuntimeException);
+ // array
+ virtual Reference< XIdlClass > SAL_CALL getComponentType() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XIdlArray > SAL_CALL getArray() throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class InterfaceIdlClassImpl
+ : public IdlClassImpl
+{
+ typedef pair< OUString, typelib_TypeDescription * > MemberInit;
+
+ Reference< XIdlClass > _xSuperClass;
+
+ MemberInit * _pSortedMemberInit; // first methods, then attributes
+ OUString2Field _aName2Field;
+ OUString2Method _aName2Method;
+ sal_Int32 _nMethods;
+ sal_Int32 _nAttributes;
+
+ void initMembers();
+
+public:
+ typelib_InterfaceTypeDescription * getTypeDescr() const
+ { return (typelib_InterfaceTypeDescription *)IdlClassImpl::getTypeDescr(); }
+
+ // ctor/ dtor
+ InterfaceIdlClassImpl( IdlReflectionServiceImpl * pReflection,
+ const OUString & rName, typelib_TypeClass eTypeClass,
+ typelib_TypeDescription * pTypeDescr )
+ : IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
+ , _pSortedMemberInit( 0 )
+ , _nMethods( 0 )
+ , _nAttributes( 0 )
+ {}
+ virtual ~InterfaceIdlClassImpl();
+
+ // IdlClassImpl modifications
+ virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses() throw(::com::sun::star::uno::RuntimeException);
+ virtual Uik SAL_CALL getUik() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XIdlMethod > SAL_CALL getMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlMethod > > SAL_CALL getMethods() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL createObject( Any & rObj ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class CompoundIdlClassImpl
+ : public IdlClassImpl
+{
+ Reference< XIdlClass > _xSuperClass;
+
+ Sequence< Reference< XIdlField > > * _pFields;
+ OUString2Field _aName2Field;
+
+public:
+ typelib_CompoundTypeDescription * getTypeDescr() const
+ { return (typelib_CompoundTypeDescription *)IdlClassImpl::getTypeDescr(); }
+
+ // ctor/ dtor
+ CompoundIdlClassImpl( IdlReflectionServiceImpl * pReflection,
+ const OUString & rName, typelib_TypeClass eTypeClass,
+ typelib_TypeDescription * pTypeDescr )
+ : IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
+ , _pFields( 0 )
+ {}
+ virtual ~CompoundIdlClassImpl();
+
+ // IdlClassImpl modifications
+ virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class ArrayIdlClassImpl
+ : public IdlClassImpl
+ , public XIdlArray
+{
+public:
+ typelib_IndirectTypeDescription * getTypeDescr() const
+ { return (typelib_IndirectTypeDescription *)IdlClassImpl::getTypeDescr(); }
+
+ // ctor
+ ArrayIdlClassImpl( IdlReflectionServiceImpl * pReflection,
+ const OUString & rName, typelib_TypeClass eTypeClass,
+ typelib_TypeDescription * pTypeDescr )
+ : IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
+ {}
+
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // IdlClassImpl modifications
+ virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass > & xType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XIdlClass > SAL_CALL getComponentType() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XIdlArray > SAL_CALL getArray() throw(::com::sun::star::uno::RuntimeException);
+
+ // XIdlArray
+ virtual void SAL_CALL realloc( Any & rArray, sal_Int32 nLen ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getLen( const Any & rArray ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual Any SAL_CALL get( const Any & rArray, sal_Int32 nIndex ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL set( Any & rArray, sal_Int32 nIndex, const Any & rNewValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class EnumIdlClassImpl
+ : public IdlClassImpl
+{
+ Sequence< Reference< XIdlField > > * _pFields;
+ OUString2Field _aName2Field;
+
+public:
+ typelib_EnumTypeDescription * getTypeDescr() const
+ { return (typelib_EnumTypeDescription *)IdlClassImpl::getTypeDescr(); }
+
+ // ctor/ dtor
+ EnumIdlClassImpl( IdlReflectionServiceImpl * pReflection,
+ const OUString & rName, typelib_TypeClass eTypeClass,
+ typelib_TypeDescription * pTypeDescr )
+ : IdlClassImpl( pReflection, rName, eTypeClass, pTypeDescr )
+ , _pFields( 0 )
+ {}
+ virtual ~EnumIdlClassImpl();
+
+ // IdlClassImpl modifications
+ virtual Reference< XIdlField > SAL_CALL getField( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlField > > SAL_CALL getFields() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL createObject( Any & rObj ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class IdlMemberImpl
+ : public WeakImplHelper1< XIdlMember >
+{
+ Mapping _aCpp2Uno;
+ Mapping _aUno2Cpp;
+
+ IdlReflectionServiceImpl * _pReflection;
+ OUString _aName;
+
+ typelib_TypeDescription * _pTypeDescr;
+ typelib_TypeDescription * _pDeclTypeDescr;
+
+protected:
+ Reference< XIdlClass > _xDeclClass;
+
+public:
+ IdlReflectionServiceImpl * getReflection() const
+ { return _pReflection; }
+ Reference< XMultiServiceFactory > getSMgr() const
+ { return _pReflection->getSMgr(); }
+ typelib_TypeDescription * getTypeDescr() const
+ { return _pTypeDescr; }
+ typelib_TypeDescription * getDeclTypeDescr() const
+ { return _pDeclTypeDescr; }
+
+ inline const Mapping & getCpp2Uno() throw(::com::sun::star::uno::RuntimeException);
+ inline const Mapping & getUno2Cpp() throw(::com::sun::star::uno::RuntimeException);
+ inline uno_Interface * mapToUno( const Any & rObj, typelib_InterfaceTypeDescription * pTo ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ctor/ dtor
+ IdlMemberImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
+ typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr );
+ virtual ~IdlMemberImpl();
+
+ // XIdlMember
+ virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+};
+//__________________________________________________________________________________________________
+inline const Mapping & IdlMemberImpl::getCpp2Uno()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _aCpp2Uno.is())
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _aCpp2Uno.is())
+ {
+ _aCpp2Uno = Mapping( OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ) );
+ OSL_ENSHURE( _aCpp2Uno.is(), "### cannot c++ to uno mapping!" );
+ if (! _aCpp2Uno.is())
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("cannot c++ to uno mapping!") ),
+ (XWeak *)(OWeakObject *)this );
+ }
+ }
+ }
+ return _aCpp2Uno;
+}
+//__________________________________________________________________________________________________
+inline const Mapping & IdlMemberImpl::getUno2Cpp()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _aUno2Cpp.is())
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _aUno2Cpp.is())
+ {
+ _aUno2Cpp = Mapping( OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ) );
+ OSL_ENSHURE( _aUno2Cpp.is(), "### cannot uno to c++ mapping!" );
+ if (! _aUno2Cpp.is())
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("cannot uno TO c++ mapping!") ),
+ (XWeak *)(OWeakObject *)this );
+ }
+ }
+ }
+ return _aUno2Cpp;
+}
+
+//--------------------------------------------------------------------------------------------------
+// coerces to type descr pTo else queries for it: the interface pointer is returned via rDest
+// ## type to XidlClass coercion possible
+inline sal_Bool extract(
+ const Any & rObj, typelib_InterfaceTypeDescription * pTo,
+ Reference< XInterface > & rDest,
+ IdlReflectionServiceImpl * pRefl )
+{
+ rDest.clear();
+ if (rObj.hasValue() && pTo)
+ {
+ if (rObj.getValueTypeClass() == TypeClass_INTERFACE)
+ {
+ return ::uno_type_assignData(
+ &rDest, ((typelib_TypeDescription *)pTo)->pWeakRef,
+ const_cast< void * >( rObj.getValue() ), rObj.getValueTypeRef(),
+ cpp_queryInterface, cpp_acquire, cpp_release );
+ }
+ else if (rObj.getValueTypeClass() == TypeClass_TYPE)
+ {
+ rDest = pRefl->forType( reinterpret_cast< const Type * >( rObj.getValue() )->getTypeLibType() );
+ return rDest.is();
+ }
+ }
+ return sal_False;
+}
+//--------------------------------------------------------------------------------------------------
+inline sal_Bool coerce_assign(
+ void * pDest, typelib_TypeDescription * pTD, const Any & rSource,
+ IdlReflectionServiceImpl * pRefl )
+{
+ if (rSource.hasValue())
+ {
+ if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
+ {
+ Reference< XInterface > xVal;
+ if (extract( rSource, (typelib_InterfaceTypeDescription *)pTD, xVal, pRefl ))
+ {
+ if (*(XInterface **)pDest)
+ (*(XInterface **)pDest)->release();
+ if (*(XInterface **)pDest = xVal.get())
+ (*(XInterface **)pDest)->acquire();
+ return sal_True;
+ }
+ }
+ else if (pTD->eTypeClass == typelib_TypeClass_ANY)
+ {
+ return uno_assignData(
+ pDest, pTD,
+ (void *)&rSource, pTD,
+ cpp_queryInterface, cpp_acquire, cpp_release );
+ }
+ else
+ {
+ return uno_type_assignData(
+ pDest, pTD->pWeakRef,
+ (void *)rSource.getValue(), rSource.getValueTypeRef(),
+ cpp_queryInterface, cpp_acquire, cpp_release );
+ }
+ }
+ return sal_False;
+}
+
+//__________________________________________________________________________________________________
+inline uno_Interface * IdlMemberImpl::mapToUno( const Any & rObj,
+ typelib_InterfaceTypeDescription * pTo )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference< XInterface > xObj;
+ if (extract( rObj, pTo, xObj, getReflection() ))
+ return (uno_Interface *)getCpp2Uno().mapInterface( xObj.get(), pTo );
+
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!") ),
+ (XWeak *)(OWeakObject *)this );
+ return 0; // dummy
+}
+
+}
+
+
diff --git a/stoc/source/corereflection/corefl.xml b/stoc/source/corereflection/corefl.xml
new file mode 100644
index 000000000000..657870225bc6
--- /dev/null
+++ b/stoc/source/corereflection/corefl.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Daniel Boelzle </Author>
+<Name> com.sun.star.comp.stoc.CoreReflection </Name>
+
+<Description>
+This service is the implementation of XIdlClassProvider.
+The service provides reflection and access to all uno types
+(interfaces, structs, enums, ...).
+</Description>
+
+<ModuleName> corefl </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> C++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> com.sun.star.reflection.CoreReflection </SupportedService>
+
+<ServiceDependency>
+</ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal </RuntimeModuleDependency>
+
+<Type> com.sun.star.reflection.XTypeDescription </Type>
+<Type> com.sun.star.reflection.XIdlReflection </Type>
+<Type> com.sun.star.reflection.XIdlClass </Type>
+<Type> com.sun.star.container.XHierarchicalNameAccess </Type>
+<Type> com.sun.star.lang.XComponent </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/stoc/source/corereflection/crarray.cxx b/stoc/source/corereflection/crarray.cxx
new file mode 100644
index 000000000000..fba501bc6f24
--- /dev/null
+++ b/stoc/source/corereflection/crarray.cxx
@@ -0,0 +1,262 @@
+/*************************************************************************
+ *
+ * $RCSfile: crarray.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_H_
+#include <typelib/typedescription.h>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+
+#include "base.hxx"
+
+
+namespace stoc_corefl
+{
+
+// XInterface
+//__________________________________________________________________________________________________
+Any ArrayIdlClassImpl::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( ::cppu::queryInterface( rType, static_cast< XIdlArray * >( this ) ) );
+ return (aRet.hasValue() ? aRet : IdlClassImpl::queryInterface( rType ));
+}
+//__________________________________________________________________________________________________
+void ArrayIdlClassImpl::acquire() throw()
+{
+ IdlClassImpl::acquire();
+}
+//__________________________________________________________________________________________________
+void ArrayIdlClassImpl::release() throw()
+{
+ IdlClassImpl::release();
+}
+
+// XTypeProvider
+//__________________________________________________________________________________________________
+Sequence< Type > ArrayIdlClassImpl::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< XIdlArray > *)0 ),
+ IdlClassImpl::getTypes() );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int8 > ArrayIdlClassImpl::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * s_pId = 0;
+ if (! s_pId)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pId)
+ {
+ static OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+}
+
+// XIdlArray
+//__________________________________________________________________________________________________
+void ArrayIdlClassImpl::realloc( Any & rArray, sal_Int32 nLen )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ TypeClass eTC = rArray.getValueTypeClass();
+ if (eTC != TypeClass_SEQUENCE && eTC != TypeClass_ARRAY)
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no sequence given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ }
+ if (nLen < 0)
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal length given!") ),
+ (XWeak *)(OWeakObject *)this, 1 );
+ }
+
+ uno_Sequence ** ppSeq = (uno_Sequence **)rArray.getValue();
+ uno_sequence_realloc( ppSeq, (typelib_TypeDescription *)getTypeDescr(),
+ nLen, cpp_acquire, cpp_release );
+ rArray.pData = ppSeq;
+}
+//__________________________________________________________________________________________________
+sal_Int32 ArrayIdlClassImpl::getLen( const Any & rArray )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ TypeClass eTC = rArray.getValueTypeClass();
+ if (eTC != TypeClass_SEQUENCE && eTC != TypeClass_ARRAY)
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no sequence given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ }
+
+ return (*(uno_Sequence **)rArray.getValue())->nElements;
+}
+//__________________________________________________________________________________________________
+Any ArrayIdlClassImpl::get( const Any & rArray, sal_Int32 nIndex )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
+{
+ TypeClass eTC = rArray.getValueTypeClass();
+ if (eTC != TypeClass_SEQUENCE && eTC != TypeClass_ARRAY)
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no sequence given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ }
+
+ uno_Sequence * pSeq = *(uno_Sequence **)rArray.getValue();
+ if (pSeq->nElements <= nIndex)
+ {
+ throw ArrayIndexOutOfBoundsException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal index given!") ),
+ (XWeak *)(OWeakObject *)this );
+ }
+
+ Any aRet;
+ typelib_TypeDescription * pElemTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElemTypeDescr, getTypeDescr()->pType );
+ uno_any_destruct( &aRet, cpp_release );
+ uno_any_construct( &aRet, &pSeq->elements[nIndex * pElemTypeDescr->nSize],
+ pElemTypeDescr, cpp_acquire );
+ TYPELIB_DANGER_RELEASE( pElemTypeDescr );
+ return aRet;
+}
+
+//__________________________________________________________________________________________________
+void ArrayIdlClassImpl::set( Any & rArray, sal_Int32 nIndex, const Any & rNewValue )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::ArrayIndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
+{
+ TypeClass eTC = rArray.getValueTypeClass();
+ if (eTC != TypeClass_SEQUENCE && eTC != TypeClass_ARRAY)
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no sequence given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ }
+
+ uno_Sequence * pSeq = *(uno_Sequence **)rArray.getValue();
+ if (pSeq->nElements <= nIndex)
+ {
+ throw ArrayIndexOutOfBoundsException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal index given!") ),
+ (XWeak *)(OWeakObject *)this );
+ }
+
+ uno_Sequence ** ppSeq = (uno_Sequence **)rArray.getValue();
+ uno_sequence_reference2One( ppSeq, (typelib_TypeDescription *)getTypeDescr(), cpp_acquire, cpp_release );
+ rArray.pData = ppSeq;
+ pSeq = *ppSeq;
+
+ typelib_TypeDescription * pElemTypeDescr = 0;
+ TYPELIB_DANGER_GET( &pElemTypeDescr, getTypeDescr()->pType );
+
+ if (! coerce_assign( &pSeq->elements[nIndex * pElemTypeDescr->nSize],
+ pElemTypeDescr, rNewValue, getReflection() ))
+ {
+ TYPELIB_DANGER_RELEASE( pElemTypeDescr );
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("sequence element is not assignable by given value!") ),
+ (XWeak *)(OWeakObject *)this, 2 );
+ }
+ TYPELIB_DANGER_RELEASE( pElemTypeDescr );
+}
+
+// ArrayIdlClassImpl
+//__________________________________________________________________________________________________
+sal_Bool ArrayIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (xType.is() &&
+ (equals( xType ) ||
+ (xType->getTypeClass() == getTypeClass() && // must be sequence|array
+ getComponentType()->isAssignableFrom( xType->getComponentType() ))));
+}
+//__________________________________________________________________________________________________
+Reference< XIdlClass > ArrayIdlClassImpl::getComponentType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getReflection()->forType( getTypeDescr()->pType );
+}
+//__________________________________________________________________________________________________
+Reference< XIdlArray > ArrayIdlClassImpl::getArray()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return this;
+}
+
+}
+
+
diff --git a/stoc/source/corereflection/crbase.cxx b/stoc/source/corereflection/crbase.cxx
new file mode 100644
index 000000000000..91250d0f4d4c
--- /dev/null
+++ b/stoc/source/corereflection/crbase.cxx
@@ -0,0 +1,318 @@
+/*************************************************************************
+ *
+ * $RCSfile: crbase.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _UNO_ANY2_H_
+#include <uno/any2.h>
+#endif
+
+#include "base.hxx"
+
+namespace stoc_corefl
+{
+
+#ifdef TEST_LIST_CLASSES
+ClassNameList g_aClassNames;
+#endif
+
+//--------------------------------------------------------------------------------------------------
+Mutex & getMutexAccess()
+{
+ static Mutex * s_pMutex = 0;
+ if (! s_pMutex)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pMutex)
+ {
+ static Mutex s_aMutex;
+ s_pMutex = &s_aMutex;
+ }
+ }
+ return *s_pMutex;
+}
+
+//__________________________________________________________________________________________________
+IdlClassImpl::IdlClassImpl( IdlReflectionServiceImpl * pReflection,
+ const OUString & rName, typelib_TypeClass eTypeClass,
+ typelib_TypeDescription * pTypeDescr )
+ : _pReflection( pReflection )
+ , _aName( rName )
+ , _eTypeClass( (TypeClass)eTypeClass )
+ , _pTypeDescr( pTypeDescr )
+{
+ if (_pReflection)
+ _pReflection->acquire();
+ if (_pTypeDescr)
+ {
+ typelib_typedescription_acquire( _pTypeDescr );
+ if (! _pTypeDescr->bComplete)
+ typelib_typedescription_complete( &_pTypeDescr );
+ }
+
+#ifdef TEST_LIST_CLASSES
+ ClassNameList::const_iterator iFind( find( g_aClassNames.begin(), g_aClassNames.end(), _aName ) );
+ OSL_ENSHURE( iFind == g_aClassNames.end(), "### idl class already exists!" );
+ g_aClassNames.push_front( _aName );
+#endif
+}
+//__________________________________________________________________________________________________
+IdlClassImpl::~IdlClassImpl()
+{
+ if (_pTypeDescr)
+ typelib_typedescription_release( _pTypeDescr );
+ if (_pReflection)
+ _pReflection->release();
+
+#ifdef TEST_LIST_CLASSES
+ ClassNameList::iterator iFind( find( g_aClassNames.begin(), g_aClassNames.end(), _aName ) );
+ OSL_ENSHURE( iFind != g_aClassNames.end(), "### idl class does not exist!" );
+ g_aClassNames.erase( iFind );
+#endif
+}
+
+// XIdlClassImpl default implementation
+//__________________________________________________________________________________________________
+TypeClass IdlClassImpl::getTypeClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _eTypeClass;
+}
+//__________________________________________________________________________________________________
+OUString IdlClassImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aName;
+}
+//__________________________________________________________________________________________________
+sal_Bool IdlClassImpl::equals( const Reference< XIdlClass >& xType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (xType.is() &&
+ (xType->getTypeClass() == _eTypeClass) && (xType->getName() == _aName));
+}
+
+static sal_Bool s_aAssignableFromTab[11][11] =
+{
+ /* from CH,BO,BY,SH,US,LO,UL,HY,UH,FL,DO */
+/* TypeClass_CHAR */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_BOOLEAN */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_BYTE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_UNSIGNED_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
+/* TypeClass_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+/* TypeClass_UNSIGNED_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+/* TypeClass_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
+/* TypeClass_UNSIGNED_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
+/* TypeClass_FLOAT */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
+/* TypeClass_DOUBLE */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
+};
+//__________________________________________________________________________________________________
+sal_Bool IdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ TypeClass eAssign = getTypeClass();
+ if (equals( xType ) || eAssign == TypeClass_ANY) // default shot
+ {
+ return sal_True;
+ }
+ else
+ {
+ TypeClass eFrom = xType->getTypeClass();
+ if (eAssign > TypeClass_VOID && eAssign < TypeClass_STRING &&
+ eFrom > TypeClass_VOID && eFrom < TypeClass_STRING)
+ {
+ return s_aAssignableFromTab[eAssign-1][eFrom-1];
+ }
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+void IdlClassImpl::createObject( Any & rObj )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ rObj.clear();
+ uno_any_destruct( &rObj, cpp_release );
+ uno_any_construct( &rObj, 0, getTypeDescr(), 0 );
+}
+
+// what TODO ????
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlClass > > IdlClassImpl::getClasses()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ OSL_ENSHURE( sal_False, "### unexpected use!" );
+ return Sequence< Reference< XIdlClass > >();
+}
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlClassImpl::getClass( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ OSL_ENSHURE( sal_False, "### unexpected use!" );
+ return Reference< XIdlClass >();
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlClass > > IdlClassImpl::getInterfaces()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+// OSL_ENSHURE( sal_False, "### unexpected use!" );
+ return Sequence< Reference< XIdlClass > >();
+}
+
+// structs, interfaces
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlClass > > IdlClassImpl::getSuperclasses() throw(::com::sun::star::uno::RuntimeException)
+{
+ return Sequence< Reference< XIdlClass > >();
+}
+// structs
+//__________________________________________________________________________________________________
+Reference< XIdlField > IdlClassImpl::getField( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return Reference< XIdlField >();
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlField > > IdlClassImpl::getFields()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return Sequence< Reference< XIdlField > >();
+}
+// interfaces
+//__________________________________________________________________________________________________
+Uik IdlClassImpl::getUik()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return Uik();
+}
+//__________________________________________________________________________________________________
+Reference< XIdlMethod > IdlClassImpl::getMethod( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return Reference< XIdlMethod >();
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlMethod > > IdlClassImpl::getMethods()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return Sequence< Reference< XIdlMethod > >();
+}
+// array
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlClassImpl::getComponentType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return Reference< XIdlClass >();
+}
+//__________________________________________________________________________________________________
+Reference< XIdlArray > IdlClassImpl::getArray()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return Reference< XIdlArray >();
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//__________________________________________________________________________________________________
+IdlMemberImpl::IdlMemberImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
+ typelib_TypeDescription * pTypeDescr,
+ typelib_TypeDescription * pDeclTypeDescr )
+ : _pReflection( pReflection )
+ , _aName( rName )
+ , _pTypeDescr( pTypeDescr )
+ , _pDeclTypeDescr( pDeclTypeDescr )
+{
+ _pReflection->acquire();
+ typelib_typedescription_acquire( _pTypeDescr );
+ typelib_typedescription_acquire( _pDeclTypeDescr );
+}
+//__________________________________________________________________________________________________
+IdlMemberImpl::~IdlMemberImpl()
+{
+ typelib_typedescription_release( _pDeclTypeDescr );
+ typelib_typedescription_release( _pTypeDescr );
+ _pReflection->release();
+}
+
+// XIdlMember
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlMemberImpl::getDeclaringClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _xDeclClass.is())
+ _xDeclClass = getReflection()->forType( getDeclTypeDescr() );
+ return _xDeclClass;
+}
+//__________________________________________________________________________________________________
+OUString IdlMemberImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aName;
+}
+
+}
+
+
diff --git a/stoc/source/corereflection/crcomp.cxx b/stoc/source/corereflection/crcomp.cxx
new file mode 100644
index 000000000000..4743f3d1c9ab
--- /dev/null
+++ b/stoc/source/corereflection/crcomp.cxx
@@ -0,0 +1,393 @@
+/*************************************************************************
+ *
+ * $RCSfile: crcomp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#include <com/sun/star/reflection/XIdlField.hpp>
+
+#include "base.hxx"
+
+
+namespace stoc_corefl
+{
+
+//==================================================================================================
+class IdlCompFieldImpl
+ : public IdlMemberImpl
+ , public XIdlField
+{
+ sal_Int32 _nOffset;
+
+public:
+ IdlCompFieldImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
+ typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr,
+ sal_Int32 nOffset )
+ : IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
+ , _nOffset( nOffset )
+ {}
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw ();
+ virtual void SAL_CALL release() throw ();
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // XIdlMember
+ virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ // XIdlField
+ virtual Reference< XIdlClass > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
+ virtual FieldAccessMode SAL_CALL getAccessMode() throw(::com::sun::star::uno::RuntimeException);
+ virtual Any SAL_CALL get( const Any & rObj ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL set( const Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
+};
+
+// XInterface
+//__________________________________________________________________________________________________
+Any IdlCompFieldImpl::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( ::cppu::queryInterface( rType, static_cast< XIdlField * >( this ) ) );
+ return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
+}
+//__________________________________________________________________________________________________
+void IdlCompFieldImpl::acquire() throw()
+{
+ IdlMemberImpl::acquire();
+}
+//__________________________________________________________________________________________________
+void IdlCompFieldImpl::release() throw()
+{
+ IdlMemberImpl::release();
+}
+
+// XTypeProvider
+//__________________________________________________________________________________________________
+Sequence< Type > IdlCompFieldImpl::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< XIdlField > *)0 ),
+ IdlMemberImpl::getTypes() );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int8 > IdlCompFieldImpl::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * s_pId = 0;
+ if (! s_pId)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pId)
+ {
+ static OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+}
+
+// XIdlMember
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlCompFieldImpl::getDeclaringClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _xDeclClass.is())
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _xDeclClass.is())
+ {
+ typelib_CompoundTypeDescription * pTD =
+ (typelib_CompoundTypeDescription *)getDeclTypeDescr();
+ while (pTD)
+ {
+ typelib_TypeDescriptionReference ** ppTypeRefs = pTD->ppTypeRefs;
+ for ( sal_Int32 nPos = pTD->nMembers; nPos--; )
+ {
+ if (td_equals( (typelib_TypeDescription *)getTypeDescr(), ppTypeRefs[nPos] ))
+ {
+ _xDeclClass = getReflection()->forType( (typelib_TypeDescription *)pTD );
+ return _xDeclClass;
+ }
+ }
+ pTD = pTD->pBaseTypeDescription;
+ }
+ }
+ }
+ return _xDeclClass;
+}
+//__________________________________________________________________________________________________
+OUString IdlCompFieldImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return IdlMemberImpl::getName();
+}
+
+// XIdlField
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlCompFieldImpl::getType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getReflection()->forType( getTypeDescr() );
+}
+//__________________________________________________________________________________________________
+FieldAccessMode IdlCompFieldImpl::getAccessMode()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return FieldAccessMode_READWRITE;
+}
+//__________________________________________________________________________________________________
+Any IdlCompFieldImpl::get( const Any & rObj )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ if (rObj.getValueTypeClass() == typelib_TypeClass_STRUCT ||
+ rObj.getValueTypeClass() == typelib_TypeClass_EXCEPTION)
+ {
+ typelib_TypeDescription * pObjTD = 0;
+ TYPELIB_DANGER_GET( &pObjTD, rObj.getValueTypeRef() );
+
+ typelib_TypeDescription * pTD = pObjTD;
+ typelib_TypeDescription * pDeclTD = getDeclTypeDescr();
+ while (pTD && !typelib_typedescription_equals( pTD, pDeclTD ))
+ pTD = (typelib_TypeDescription *)((typelib_CompoundTypeDescription *)pTD)->pBaseTypeDescription;
+
+ OSL_ENSHURE( pTD, "### illegal object type!" );
+ if (pTD)
+ {
+ TYPELIB_DANGER_RELEASE( pObjTD );
+ Any aRet;
+ uno_any_destruct( &aRet, cpp_release );
+ uno_any_construct( &aRet, (char *)rObj.getValue() + _nOffset, getTypeDescr(), cpp_acquire );
+ return aRet;
+ }
+ TYPELIB_DANGER_RELEASE( pObjTD );
+ }
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ return Any(); // dummy
+}
+//__________________________________________________________________________________________________
+void IdlCompFieldImpl::set( const Any & rObj, const Any & rValue )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
+{
+ if (rObj.getValueTypeClass() == typelib_TypeClass_STRUCT ||
+ rObj.getValueTypeClass() == typelib_TypeClass_EXCEPTION)
+ {
+ typelib_TypeDescription * pObjTD = 0;
+ TYPELIB_DANGER_GET( &pObjTD, rObj.getValueTypeRef() );
+
+ typelib_TypeDescription * pTD = pObjTD;
+ typelib_TypeDescription * pDeclTD = getDeclTypeDescr();
+ while (pTD && !typelib_typedescription_equals( pTD, pDeclTD ))
+ pTD = (typelib_TypeDescription *)((typelib_CompoundTypeDescription *)pTD)->pBaseTypeDescription;
+
+ OSL_ENSHURE( pTD, "### illegal object type!" );
+ if (pTD)
+ {
+ TYPELIB_DANGER_RELEASE( pObjTD );
+ if (coerce_assign( (char *)rObj.getValue() + _nOffset, getTypeDescr(), rValue, getReflection() ))
+ {
+ return;
+ }
+ else
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal value given!") ),
+ (XWeak *)(OWeakObject *)this, 1 );
+ }
+ }
+ TYPELIB_DANGER_RELEASE( pObjTD );
+ }
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//__________________________________________________________________________________________________
+CompoundIdlClassImpl::~CompoundIdlClassImpl()
+{
+ delete _pFields;
+}
+
+//__________________________________________________________________________________________________
+sal_Bool CompoundIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (xType.is())
+ {
+ TypeClass eTC = xType->getTypeClass();
+ if (eTC == TypeClass_STRUCT || eTC == TypeClass_EXCEPTION)
+ {
+ if (equals( xType ))
+ return sal_True;
+ else
+ {
+ const Sequence< Reference< XIdlClass > > & rSeq = xType->getSuperclasses();
+ if (rSeq.getLength())
+ {
+ OSL_ENSHURE( rSeq.getLength() == 1, "### unexpected len of super classes!" );
+ return isAssignableFrom( rSeq[0] );
+ }
+ }
+ }
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlClass > > CompoundIdlClassImpl::getSuperclasses()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _xSuperClass.is())
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _xSuperClass.is())
+ {
+ typelib_CompoundTypeDescription * pCompTypeDescr = getTypeDescr()->pBaseTypeDescription;
+ if (pCompTypeDescr)
+ _xSuperClass = getReflection()->forType( (typelib_TypeDescription *)pCompTypeDescr );
+ }
+ }
+ if (_xSuperClass.is())
+ return Sequence< Reference< XIdlClass > >( &_xSuperClass, 1 );
+ else
+ return Sequence< Reference< XIdlClass > >();
+}
+//__________________________________________________________________________________________________
+Reference< XIdlField > CompoundIdlClassImpl::getField( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pFields)
+ getFields(); // init fields
+
+ const OUString2Field::const_iterator iFind( _aName2Field.find( rName ) );
+ if (iFind != _aName2Field.end())
+ return Reference< XIdlField >( (*iFind).second );
+ else
+ return Reference< XIdlField >();
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlField > > CompoundIdlClassImpl::getFields()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _pFields)
+ {
+ sal_Int32 nAll = 0;
+ typelib_CompoundTypeDescription * pCompTypeDescr = getTypeDescr();
+ for ( ; pCompTypeDescr; pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
+ nAll += pCompTypeDescr->nMembers;
+
+ Sequence< Reference< XIdlField > > * pFields =
+ new Sequence< Reference< XIdlField > >( nAll );
+ Reference< XIdlField > * pSeq = pFields->getArray();
+
+ for ( pCompTypeDescr = getTypeDescr(); pCompTypeDescr;
+ pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
+ {
+ typelib_TypeDescriptionReference ** ppTypeRefs = pCompTypeDescr->ppTypeRefs;
+ rtl_uString ** ppNames = pCompTypeDescr->ppMemberNames;
+ sal_Int32 * pMemberOffsets = pCompTypeDescr->pMemberOffsets;
+
+ for ( sal_Int32 nPos = pCompTypeDescr->nMembers; nPos--; )
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, ppTypeRefs[nPos] );
+ OSL_ENSHURE( pTD, "### cannot get field in struct!" );
+ if (pTD)
+ {
+ OUString aName( ppNames[nPos] );
+ _aName2Field[aName] = pSeq[--nAll] = new IdlCompFieldImpl(
+ getReflection(), aName, pTD, IdlClassImpl::getTypeDescr(), pMemberOffsets[nPos] );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ }
+ }
+
+ _pFields = pFields;
+ }
+ return *_pFields;
+}
+
+}
+
+
diff --git a/stoc/source/corereflection/crefl.cxx b/stoc/source/corereflection/crefl.cxx
new file mode 100644
index 000000000000..7a280a6eae4e
--- /dev/null
+++ b/stoc/source/corereflection/crefl.cxx
@@ -0,0 +1,488 @@
+/*************************************************************************
+ *
+ * $RCSfile: crefl.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/reflection/XTypeDescription.hpp>
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+#include "base.hxx"
+
+
+namespace stoc_corefl
+{
+
+static const sal_Int32 CACHE_SIZE = 256;
+
+#define SERVICENAME "com.sun.star.reflection.CoreReflection"
+#define IMPLNAME "com.sun.star.comp.stoc.CoreReflection"
+
+//--------------------------------------------------------------------------------------------------
+inline static Sequence< OUString > getSupportedServiceNames()
+{
+ OUString aName( OUString( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) ) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//__________________________________________________________________________________________________
+IdlReflectionServiceImpl::IdlReflectionServiceImpl( const Reference< XMultiServiceFactory > & xMgr )
+ : OComponentHelper( _aComponentMutex )
+ , _xMgr( xMgr )
+ , _xTDMgr( xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.TypeDescriptionManager") ) ),
+ UNO_QUERY )
+ , _aElements( CACHE_SIZE )
+{
+ OSL_ENSHURE( _xTDMgr.is(), "### cannot get service \"com.sun.star.reflection.TypeDescriptionManager\"!" );
+}
+//__________________________________________________________________________________________________
+IdlReflectionServiceImpl::~IdlReflectionServiceImpl()
+{
+ TRACE( "> IdlReflectionServiceImpl dtor <\n" );
+}
+
+// XInterface
+//__________________________________________________________________________________________________
+Any IdlReflectionServiceImpl::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( ::cppu::queryInterface(
+ rType,
+ static_cast< XIdlReflection * >( this ),
+ static_cast< XHierarchicalNameAccess * >( this ),
+ static_cast< XServiceInfo * >( this ) ) );
+
+ return (aRet.hasValue() ? aRet : OComponentHelper::queryInterface( rType ));
+}
+//__________________________________________________________________________________________________
+void IdlReflectionServiceImpl::acquire() throw()
+{
+ OComponentHelper::acquire();
+}
+//__________________________________________________________________________________________________
+void IdlReflectionServiceImpl::release() throw()
+{
+ OComponentHelper::release();
+}
+
+// XTypeProvider
+//__________________________________________________________________________________________________
+Sequence< Type > IdlReflectionServiceImpl::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( _aComponentMutex );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< XIdlReflection > *)0 ),
+ ::getCppuType( (const Reference< XHierarchicalNameAccess > *)0 ),
+ ::getCppuType( (const Reference< XServiceInfo > *)0 ),
+ OComponentHelper::getTypes() );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int8 > IdlReflectionServiceImpl::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * s_pId = 0;
+ if (! s_pId)
+ {
+ MutexGuard aGuard( _aComponentMutex );
+ if (! s_pId)
+ {
+ static OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+}
+
+// XComponent
+//__________________________________________________________________________________________________
+void IdlReflectionServiceImpl::dispose()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ TRACE( "> disposing corereflection... <" );
+ OComponentHelper::dispose();
+
+ MutexGuard aGuard( _aComponentMutex );
+ _aElements.clear();
+ _xTDMgr.clear();
+ _xMgr.clear();
+#ifdef TEST_LIST_CLASSES
+ OSL_ENSHURE( g_aClassNames.size() == 0, "### idl classes still alive!" );
+ ClassNameList::const_iterator iPos( g_aClassNames.begin() );
+ while (iPos != g_aClassNames.end())
+ {
+ OUString aName( *iPos );
+ ++iPos;
+ }
+#endif
+}
+
+// XServiceInfo
+//__________________________________________________________________________________________________
+OUString IdlReflectionServiceImpl::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
+}
+//__________________________________________________________________________________________________
+sal_Bool IdlReflectionServiceImpl::supportsService( const OUString & rServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ {
+ if (pArray[nPos] == rServiceName)
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > IdlReflectionServiceImpl::getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return stoc_corefl::getSupportedServiceNames();
+}
+
+// XIdlReflection
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlReflectionServiceImpl::getType( const Any & rObj )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (rObj.hasValue() ? forType( rObj.getValueTypeRef() ) : Reference< XIdlClass >());
+}
+
+//__________________________________________________________________________________________________
+inline Reference< XIdlClass > IdlReflectionServiceImpl::constructClass(
+ typelib_TypeDescription * pTypeDescr )
+{
+ OSL_ENSHURE( pTypeDescr->eTypeClass != typelib_TypeClass_TYPEDEF, "### unexpected typedef!" );
+
+ switch (pTypeDescr->eTypeClass)
+ {
+ case typelib_TypeClass_VOID:
+ case typelib_TypeClass_CHAR:
+ case typelib_TypeClass_BOOLEAN:
+ case typelib_TypeClass_BYTE:
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ case typelib_TypeClass_FLOAT:
+ case typelib_TypeClass_DOUBLE:
+ case typelib_TypeClass_STRING:
+ case typelib_TypeClass_ANY:
+ return new IdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
+
+ case TypeClass_ENUM:
+ return new EnumIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
+
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_UNION:
+ case typelib_TypeClass_EXCEPTION:
+ return new CompoundIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
+
+ case typelib_TypeClass_ARRAY:
+ case typelib_TypeClass_SEQUENCE:
+ return new ArrayIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
+
+ case typelib_TypeClass_INTERFACE:
+ return new InterfaceIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
+
+ case typelib_TypeClass_TYPE:
+ return new IdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
+#ifdef DEBUG
+ case typelib_TypeClass_INTERFACE_METHOD:
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ case typelib_TypeClass_SERVICE:
+ case typelib_TypeClass_MODULE:
+ case typelib_TypeClass_UNKNOWN:
+ case typelib_TypeClass_TYPEDEF:
+ default:
+ OSL_TRACE( "### corereflection type unsupported: " );
+ OString aName( OUStringToOString( pTypeDescr->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( aName.getStr() );
+ OSL_TRACE( "\n" );
+#endif
+ }
+ return Reference< XIdlClass >();
+}
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlReflectionServiceImpl::forName( const OUString & rTypeName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference< XIdlClass > xRet;
+ Any aAny( _aElements.getValue( rTypeName ) );
+
+ if (aAny.hasValue())
+ {
+ if (aAny.getValueTypeClass() == TypeClass_INTERFACE)
+ xRet = *(const Reference< XIdlClass > *)aAny.getValue();
+ }
+ else
+ {
+ // try to get _type_ by name
+ typelib_TypeDescription * pTD = 0;
+ typelib_typedescription_getByName( &pTD, rTypeName.pData );
+ if (pTD)
+ {
+ if ((xRet = constructClass( pTD )).is())
+ _aElements.setValue( rTypeName, makeAny( xRet ) ); // update
+ typelib_typedescription_release( pTD );
+ }
+ }
+
+ return xRet;
+}
+
+// XHierarchicalNameAccess
+//__________________________________________________________________________________________________
+Any IdlReflectionServiceImpl::getByHierarchicalName( const OUString & rName )
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( _aElements.getValue( rName ) );
+ if (! aRet.hasValue())
+ {
+ // first look for constants exclusivly!
+ aRet = _xTDMgr->getByHierarchicalName( rName );
+ if (aRet.getValueTypeClass() == TypeClass_INTERFACE) // if no constant,
+ // i.e. XTypeDescription for a type
+ {
+ // type retrieved from tdmgr
+ OSL_ASSERT( (*(Reference< XInterface > *)aRet.getValue())->queryInterface(
+ ::getCppuType( (const Reference< XTypeDescription > *)0 ) ).hasValue() );
+
+ // if you are interested in a type then CALL forName()!!!
+ // this way is NOT recommended for types, because this method looks for constants first
+
+ // if td manager found some type, it will be in the cache (hopefully.. we just got it)
+ // so the second retrieving via c typelib callback chain should succeed...
+
+ // try to get _type_ by name
+ typelib_TypeDescription * pTD = 0;
+ typelib_typedescription_getByName( &pTD, rName.pData );
+
+ aRet.clear(); // kick XTypeDescription interface
+
+ if (pTD)
+ {
+ Reference< XIdlClass > xIdlClass( constructClass( pTD ) );
+ aRet.setValue( &xIdlClass, ::getCppuType( (const Reference< XIdlClass > *)0 ) );
+ typelib_typedescription_release( pTD );
+ }
+ }
+ // else is constant
+
+ // update
+ if (aRet.hasValue())
+ _aElements.setValue( rName, aRet );
+ else
+ {
+ throw NoSuchElementException( rName, Reference< XInterface >() );
+ }
+ }
+ return aRet;
+}
+//__________________________________________________________________________________________________
+sal_Bool IdlReflectionServiceImpl::hasByHierarchicalName( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ try
+ {
+ return getByHierarchicalName( rName ).hasValue();
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ return sal_False;
+}
+
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlReflectionServiceImpl::forType( typelib_TypeDescription * pTypeDescr )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference< XIdlClass > xRet;
+ OUString aName( pTypeDescr->pTypeName );
+ Any aAny( _aElements.getValue( aName ) );
+
+ if (aAny.hasValue())
+ {
+ if (aAny.getValueTypeClass() == TypeClass_INTERFACE)
+ xRet = *(const Reference< XIdlClass > *)aAny.getValue();
+ }
+ else
+ {
+ if (pTypeDescr && (xRet = constructClass( pTypeDescr )).is())
+ _aElements.setValue( aName, makeAny( xRet ) ); // update
+ }
+
+ return xRet;
+}
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlReflectionServiceImpl::forType( typelib_TypeDescriptionReference * pRef )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, pRef );
+ if (pTD)
+ {
+ Reference< XIdlClass > xRet = forType( pTD );
+ TYPELIB_DANGER_RELEASE( pTD );
+ return xRet;
+ }
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("IdlReflectionServiceImpl::forType() failed!") ),
+ (XWeak *)(OWeakObject *)this );
+ return Reference< XIdlClass >(); // dummy
+}
+
+//==================================================================================================
+Reference< XInterface > SAL_CALL IdlReflectionServiceImpl_create(
+ const Reference< XMultiServiceFactory > & xMgr )
+ throw(::com::sun::star::uno::Exception)
+{
+ return Reference< XInterface >( (XWeak *)(OWeakObject *)new IdlReflectionServiceImpl( xMgr ) );
+}
+
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL = stoc_corefl::getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
+ stoc_corefl::IdlReflectionServiceImpl_create,
+ stoc_corefl::getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
diff --git a/stoc/source/corereflection/crenum.cxx b/stoc/source/corereflection/crenum.cxx
new file mode 100644
index 000000000000..9cd809bb197a
--- /dev/null
+++ b/stoc/source/corereflection/crenum.cxx
@@ -0,0 +1,264 @@
+/*************************************************************************
+ *
+ * $RCSfile: crenum.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "base.hxx"
+
+namespace stoc_corefl
+{
+
+//==================================================================================================
+class IdlEnumFieldImpl
+ : public IdlMemberImpl
+ , public XIdlField
+{
+ sal_Int32 _nValue;
+
+public:
+ IdlEnumFieldImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
+ typelib_TypeDescription * pTypeDescr, sal_Int32 nValue )
+ : IdlMemberImpl( pReflection, rName, pTypeDescr, pTypeDescr )
+ , _nValue( nValue )
+ {}
+ virtual ~IdlEnumFieldImpl();
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // XIdlMember
+ virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ // XIdlField
+ virtual Reference< XIdlClass > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
+ virtual FieldAccessMode SAL_CALL getAccessMode() throw(::com::sun::star::uno::RuntimeException);
+ virtual Any SAL_CALL get( const Any & rObj ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL set( const Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
+};
+//__________________________________________________________________________________________________
+IdlEnumFieldImpl::~IdlEnumFieldImpl()
+{
+}
+
+// XInterface
+//__________________________________________________________________________________________________
+Any IdlEnumFieldImpl::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( ::cppu::queryInterface( rType, static_cast< XIdlField * >( this ) ) );
+ return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
+}
+//__________________________________________________________________________________________________
+void IdlEnumFieldImpl::acquire() throw()
+{
+ IdlMemberImpl::acquire();
+}
+//__________________________________________________________________________________________________
+void IdlEnumFieldImpl::release() throw()
+{
+ IdlMemberImpl::release();
+}
+
+// XTypeProvider
+//__________________________________________________________________________________________________
+Sequence< Type > IdlEnumFieldImpl::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< XIdlField > *)0 ),
+ IdlMemberImpl::getTypes() );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int8 > IdlEnumFieldImpl::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * s_pId = 0;
+ if (! s_pId)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pId)
+ {
+ static OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+}
+
+// XIdlMember
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlEnumFieldImpl::getDeclaringClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return IdlMemberImpl::getDeclaringClass();
+}
+//__________________________________________________________________________________________________
+OUString IdlEnumFieldImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return IdlMemberImpl::getName();
+}
+
+// XIdlField
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlEnumFieldImpl::getType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getDeclaringClass();
+}
+//__________________________________________________________________________________________________
+FieldAccessMode IdlEnumFieldImpl::getAccessMode()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return FieldAccessMode_READONLY;
+}
+//__________________________________________________________________________________________________
+Any IdlEnumFieldImpl::get( const Any & rObj )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ return Any( &_nValue, getTypeDescr() );
+}
+//__________________________________________________________________________________________________
+void IdlEnumFieldImpl::set( const Any & rObj, const Any & rValue )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
+{
+ throw IllegalAccessException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("enum field is constant!") ),
+ (XWeak *)(OWeakObject *)this );
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//__________________________________________________________________________________________________
+EnumIdlClassImpl::~EnumIdlClassImpl()
+{
+ delete _pFields;
+}
+
+// IdlClassImpl modifications
+//__________________________________________________________________________________________________
+Reference< XIdlField > EnumIdlClassImpl::getField( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pFields)
+ getFields(); // init members
+
+ const OUString2Field::const_iterator iFind( _aName2Field.find( rName ) );
+ if (iFind != _aName2Field.end())
+ return (*iFind).second;
+ else
+ return Reference< XIdlField >();
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlField > > EnumIdlClassImpl::getFields()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pFields)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _pFields)
+ {
+ sal_Int32 nFields = getTypeDescr()->nEnumValues;
+ Sequence< Reference< XIdlField > > * pFields =
+ new Sequence< Reference< XIdlField > >( nFields );
+ Reference< XIdlField > * pSeq = pFields->getArray();
+
+ while (nFields--)
+ {
+ OUString aName( getTypeDescr()->ppEnumNames[nFields] );
+ _aName2Field[aName] = pSeq[nFields] = new IdlEnumFieldImpl(
+ getReflection(), aName, IdlClassImpl::getTypeDescr(), getTypeDescr()->pEnumValues[nFields] );
+ }
+
+ _pFields = pFields;
+ }
+ }
+ return *_pFields;
+}
+//__________________________________________________________________________________________________
+void EnumIdlClassImpl::createObject( Any & rObj )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ int eVal = ((typelib_EnumTypeDescription *)IdlClassImpl::getTypeDescr())->nDefaultEnumValue;
+ rObj.setValue( &eVal, IdlClassImpl::getTypeDescr() );
+}
+
+}
+
+
diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx
new file mode 100644
index 000000000000..8d0ae2730660
--- /dev/null
+++ b/stoc/source/corereflection/criface.cxx
@@ -0,0 +1,1001 @@
+/*************************************************************************
+ *
+ * $RCSfile: criface.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <sal/config.h>
+#ifdef SAL_UNX
+#include <alloca.h>
+#endif
+#include <malloc.h>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
+#include <typelib/typedescription.hxx>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+
+#include "base.hxx"
+
+
+namespace stoc_corefl
+{
+
+//==================================================================================================
+class IdlAttributeFieldImpl
+ : public IdlMemberImpl
+ , public XIdlField
+{
+public:
+ typelib_InterfaceAttributeTypeDescription * getTypeDescr()
+ { return (typelib_InterfaceAttributeTypeDescription *)IdlMemberImpl::getTypeDescr(); }
+
+ IdlAttributeFieldImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
+ typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr )
+ : IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
+ {}
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // XIdlMember
+ virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ // XIdlField
+ virtual Reference< XIdlClass > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
+ virtual FieldAccessMode SAL_CALL getAccessMode() throw(::com::sun::star::uno::RuntimeException);
+ virtual Any SAL_CALL get( const Any & rObj ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL set( const Any & rObj, const Any & rValue ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
+};
+
+// XInterface
+//__________________________________________________________________________________________________
+Any IdlAttributeFieldImpl::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( ::cppu::queryInterface( rType, static_cast< XIdlField * >( this ) ) );
+ return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
+}
+//__________________________________________________________________________________________________
+void IdlAttributeFieldImpl::acquire() throw()
+{
+ IdlMemberImpl::acquire();
+}
+//__________________________________________________________________________________________________
+void IdlAttributeFieldImpl::release() throw()
+{
+ IdlMemberImpl::release();
+}
+
+// XTypeProvider
+//__________________________________________________________________________________________________
+Sequence< Type > IdlAttributeFieldImpl::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< XIdlField > *)0 ),
+ IdlMemberImpl::getTypes() );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int8 > IdlAttributeFieldImpl::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * s_pId = 0;
+ if (! s_pId)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pId)
+ {
+ static OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+}
+
+// XIdlMember
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlAttributeFieldImpl::getDeclaringClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _xDeclClass.is())
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _xDeclClass.is())
+ {
+ typelib_InterfaceTypeDescription * pTD =
+ (typelib_InterfaceTypeDescription *)getDeclTypeDescr();
+ while (pTD)
+ {
+ typelib_TypeDescriptionReference ** ppTypeRefs = pTD->ppMembers;
+ for ( sal_Int32 nPos = pTD->nMembers; nPos--; )
+ {
+ if (td_equals( (typelib_TypeDescription *)getTypeDescr(), ppTypeRefs[nPos] ))
+ {
+ _xDeclClass = getReflection()->forType( (typelib_TypeDescription *)pTD );
+ return _xDeclClass;
+ }
+ }
+ pTD = pTD->pBaseTypeDescription;
+ }
+ }
+ }
+ return _xDeclClass;
+}
+//__________________________________________________________________________________________________
+OUString IdlAttributeFieldImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return IdlMemberImpl::getName();
+}
+
+// XIdlField
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlAttributeFieldImpl::getType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getReflection()->forType( getTypeDescr()->pAttributeTypeRef );
+}
+//__________________________________________________________________________________________________
+FieldAccessMode IdlAttributeFieldImpl::getAccessMode()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (((typelib_InterfaceAttributeTypeDescription *)getTypeDescr())->bReadOnly
+ ? FieldAccessMode_READONLY : FieldAccessMode_READWRITE);
+}
+//__________________________________________________________________________________________________
+Any IdlAttributeFieldImpl::get( const Any & rObj )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ uno_Interface * pUnoI = mapToUno( rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() );
+ OSL_ENSHURE( pUnoI, "### illegal destination object given!" );
+ if (pUnoI)
+ {
+ TypeDescription aTD( getTypeDescr()->pAttributeTypeRef );
+ typelib_TypeDescription * pTD = aTD.get();
+
+ uno_Any aExc;
+ uno_Any * pExc = &aExc;
+ void * pReturn = alloca( pTD->nSize );
+
+ (*pUnoI->pDispatcher)( pUnoI, (typelib_TypeDescription *)getTypeDescr(), pReturn, 0, &pExc );
+ (*pUnoI->release)( pUnoI );
+
+ Any aRet;
+ if (pExc)
+ {
+ // DBO TODO: throw original exception generically
+ uno_any_destruct( pExc, 0 );
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("exception occured during get of attribute!") ),
+ *(const Reference< XInterface > *)rObj.getValue() );
+ }
+ else
+ {
+ uno_any_destruct( &aRet, cpp_release );
+ uno_any_constructAndConvert( &aRet, pReturn, pTD, getUno2Cpp().get() );
+ uno_destructData( pReturn, pTD, 0 );
+ }
+ return aRet;
+ }
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal object given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ return Any(); // dummy
+}
+//__________________________________________________________________________________________________
+void IdlAttributeFieldImpl::set( const Any & rObj, const Any & rValue )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
+{
+ if (getTypeDescr()->bReadOnly)
+ {
+ throw IllegalAccessException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("cannot set readonly attribute!") ),
+ (XWeak *)(OWeakObject *)this );
+ }
+
+ uno_Interface * pUnoI = mapToUno( rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() );
+ OSL_ENSHURE( pUnoI, "### illegal destination object given!" );
+ if (pUnoI)
+ {
+ TypeDescription aTD( getTypeDescr()->pAttributeTypeRef );
+ typelib_TypeDescription * pTD = aTD.get();
+
+ // construct uno value to be set
+ void * pArgs[1];
+ void * pArg = pArgs[0] = alloca( pTD->nSize );
+
+ sal_Bool bAssign;
+ if (pTD->eTypeClass == typelib_TypeClass_ANY)
+ {
+ uno_copyAndConvertData( pArg, SAL_CONST_CAST( Any *, &rValue ),
+ pTD, getCpp2Uno().get() );
+ bAssign = sal_True;
+ }
+ else if (typelib_typedescriptionreference_equals( rValue.getValueTypeRef(), pTD->pWeakRef ))
+ {
+ uno_copyAndConvertData( pArg, SAL_CONST_CAST( void *, rValue.getValue() ),
+ pTD, getCpp2Uno().get() );
+ bAssign = sal_True;
+ }
+ else if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
+ {
+ Reference< XInterface > xObj;
+ if (bAssign = extract( rValue, (typelib_InterfaceTypeDescription *)pTD,
+ xObj, getReflection() ))
+ {
+ *(void **)pArg = getCpp2Uno().mapInterface(
+ xObj.get(), (typelib_InterfaceTypeDescription *)pTD );
+ }
+ }
+ else
+ {
+ typelib_TypeDescription * pValueTD = 0;
+ TYPELIB_DANGER_GET( &pValueTD, rValue.getValueTypeRef() );
+ // construct temp uno val to do proper assignment: todo opt
+ void * pTemp = alloca( pValueTD->nSize );
+ uno_copyAndConvertData(
+ pTemp, (void *)rValue.getValue(), pValueTD, getCpp2Uno().get() );
+ uno_constructData(
+ pArg, pTD );
+ // assignment does simple conversion
+ bAssign = uno_assignData(
+ pArg, pTD, pTemp, pValueTD, 0, 0, 0 );
+ uno_destructData(
+ pTemp, pValueTD, 0 );
+ TYPELIB_DANGER_RELEASE( pValueTD );
+ }
+
+ if (bAssign)
+ {
+ uno_Any aExc;
+ uno_Any * pExc = &aExc;
+ (*pUnoI->pDispatcher)( pUnoI, (typelib_TypeDescription *)getTypeDescr(), 0, pArgs, &pExc );
+ (*pUnoI->release)( pUnoI );
+
+ uno_destructData( pArg, pTD, 0 );
+ if (pExc)
+ {
+ // DBO TODO: throw original exception generically
+ uno_any_destruct( pExc, 0 );
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("exception occured during get of attribute!") ),
+ *(const Reference< XInterface > *)rObj.getValue() );
+ }
+ return;
+ }
+ (*pUnoI->release)( pUnoI );
+
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal value given!") ),
+ *(const Reference< XInterface > *)rObj.getValue(), 1 );
+ }
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal destination object given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//==================================================================================================
+class IdlInterfaceMethodImpl
+ : public IdlMemberImpl
+ , public XIdlMethod
+{
+ Sequence< Reference< XIdlClass > > * _pExceptionTypes;
+ Sequence< Reference< XIdlClass > > * _pParamTypes;
+ Sequence< ParamInfo > * _pParamInfos;
+
+public:
+ typelib_InterfaceMethodTypeDescription * getTypeDescr()
+ { return (typelib_InterfaceMethodTypeDescription *)IdlMemberImpl::getTypeDescr(); }
+
+ IdlInterfaceMethodImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
+ typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr )
+ : IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
+ , _pExceptionTypes( 0 )
+ , _pParamTypes( 0 )
+ , _pParamInfos( 0 )
+ {}
+ virtual ~IdlInterfaceMethodImpl();
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // XIdlMember
+ virtual Reference< XIdlClass > SAL_CALL getDeclaringClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ // XIdlMethod
+ virtual Reference< XIdlClass > SAL_CALL getReturnType() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getParameterTypes() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< ParamInfo > SAL_CALL getParameterInfos() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XIdlClass > > SAL_CALL getExceptionTypes() throw(::com::sun::star::uno::RuntimeException);
+ virtual MethodMode SAL_CALL getMode() throw(::com::sun::star::uno::RuntimeException);
+ virtual Any SAL_CALL invoke( const Any & rObj, Sequence< Any > & rArgs ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
+};
+//__________________________________________________________________________________________________
+IdlInterfaceMethodImpl::~IdlInterfaceMethodImpl()
+{
+ delete _pParamInfos;
+ delete _pParamTypes;
+ delete _pExceptionTypes;
+}
+
+// XInterface
+//__________________________________________________________________________________________________
+Any IdlInterfaceMethodImpl::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( ::cppu::queryInterface( rType, static_cast< XIdlMethod * >( this ) ) );
+ return (aRet.hasValue() ? aRet : IdlMemberImpl::queryInterface( rType ));
+}
+//__________________________________________________________________________________________________
+void IdlInterfaceMethodImpl::acquire() throw()
+{
+ IdlMemberImpl::acquire();
+}
+//__________________________________________________________________________________________________
+void IdlInterfaceMethodImpl::release() throw()
+{
+ IdlMemberImpl::release();
+}
+
+// XTypeProvider
+//__________________________________________________________________________________________________
+Sequence< Type > IdlInterfaceMethodImpl::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< XIdlMethod > *)0 ),
+ IdlMemberImpl::getTypes() );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int8 > IdlInterfaceMethodImpl::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * s_pId = 0;
+ if (! s_pId)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! s_pId)
+ {
+ static OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+}
+
+// XIdlMember
+//__________________________________________________________________________________________________
+Reference< XIdlClass > IdlInterfaceMethodImpl::getDeclaringClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _xDeclClass.is())
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _xDeclClass.is())
+ {
+ typelib_InterfaceTypeDescription * pTD =
+ (typelib_InterfaceTypeDescription *)getDeclTypeDescr();
+ while (pTD)
+ {
+ typelib_TypeDescriptionReference ** ppTypeRefs = pTD->ppMembers;
+ for ( sal_Int32 nPos = pTD->nMembers; nPos--; )
+ {
+ if (td_equals( (typelib_TypeDescription *)getTypeDescr(), ppTypeRefs[nPos] ))
+ {
+ _xDeclClass = getReflection()->forType( (typelib_TypeDescription *)pTD );
+ return _xDeclClass;
+ }
+ }
+ pTD = pTD->pBaseTypeDescription;
+ }
+ }
+ }
+ return _xDeclClass;
+}
+//__________________________________________________________________________________________________
+OUString IdlInterfaceMethodImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return IdlMemberImpl::getName();
+}
+
+// XIdlMethod
+//__________________________________________________________________________________________________
+Reference< XIdlClass > SAL_CALL IdlInterfaceMethodImpl::getReturnType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getReflection()->forType( getTypeDescr()->pReturnTypeRef );
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pExceptionTypes)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _pExceptionTypes)
+ {
+ sal_Int32 nExc = getTypeDescr()->nExceptions;
+ Sequence< Reference< XIdlClass > > * pTempExceptionTypes =
+ new Sequence< Reference< XIdlClass > >( nExc );
+ Reference< XIdlClass > * pExceptionTypes = pTempExceptionTypes->getArray();
+
+ typelib_TypeDescriptionReference ** ppExc = getTypeDescr()->ppExceptions;
+ IdlReflectionServiceImpl * pRefl = getReflection();
+
+ while (nExc--)
+ pExceptionTypes[nExc] = pRefl->forType( ppExc[nExc] );
+
+ _pExceptionTypes = pTempExceptionTypes;
+ }
+ }
+ return *_pExceptionTypes;
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pParamTypes)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _pParamTypes)
+ {
+ sal_Int32 nParams = getTypeDescr()->nParams;
+ Sequence< Reference< XIdlClass > > * pTempParamTypes =
+ new Sequence< Reference< XIdlClass > >( nParams );
+ Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
+
+ typelib_MethodParameter * pTypelibParams = getTypeDescr()->pParams;
+ IdlReflectionServiceImpl * pRefl = getReflection();
+
+ while (nParams--)
+ pParamTypes[nParams] = pRefl->forType( pTypelibParams[nParams].pTypeRef );
+
+ _pParamTypes = pTempParamTypes;
+ }
+ }
+ return *_pParamTypes;
+}
+//__________________________________________________________________________________________________
+Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pParamInfos)
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _pParamInfos)
+ {
+ sal_Int32 nParams = getTypeDescr()->nParams;
+ Sequence< ParamInfo > * pTempParamInfos = new Sequence< ParamInfo >( nParams );
+ ParamInfo * pParamInfos = pTempParamInfos->getArray();
+
+ typelib_MethodParameter * pTypelibParams = getTypeDescr()->pParams;
+
+ if (_pParamTypes) // use param types
+ {
+ const Reference< XIdlClass > * pParamTypes = _pParamTypes->getConstArray();
+
+ while (nParams--)
+ {
+ const typelib_MethodParameter & rParam = pTypelibParams[nParams];
+ ParamInfo & rInfo = pParamInfos[nParams];
+ rInfo.aName = rParam.pName;
+ if (rParam.bIn)
+ rInfo.aMode = (rParam.bOut ? ParamMode_INOUT : ParamMode_IN);
+ else
+ rInfo.aMode = ParamMode_OUT;
+ rInfo.aType = pParamTypes[nParams];
+ }
+ }
+ else // make also param types sequence if not already initialized
+ {
+ Sequence< Reference< XIdlClass > > * pTempParamTypes =
+ new Sequence< Reference< XIdlClass > >( nParams );
+ Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
+
+ IdlReflectionServiceImpl * pRefl = getReflection();
+
+ while (nParams--)
+ {
+ const typelib_MethodParameter & rParam = pTypelibParams[nParams];
+ ParamInfo & rInfo = pParamInfos[nParams];
+ rInfo.aName = rParam.pName;
+ if (rParam.bIn)
+ rInfo.aMode = (rParam.bOut ? ParamMode_INOUT : ParamMode_IN);
+ else
+ rInfo.aMode = ParamMode_OUT;
+ rInfo.aType = pParamTypes[nParams] = pRefl->forType( rParam.pTypeRef );
+ }
+
+ _pParamTypes = pTempParamTypes;
+ }
+
+ _pParamInfos = pTempParamInfos;
+ }
+ }
+ return *_pParamInfos;
+}
+//__________________________________________________________________________________________________
+MethodMode SAL_CALL IdlInterfaceMethodImpl::getMode()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (getTypeDescr()->bOneWay ? MethodMode_ONEWAY : MethodMode_TWOWAY);
+}
+//__________________________________________________________________________________________________
+Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > & rArgs )
+ throw(::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::reflection::InvocationTargetException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ if (rObj.getValueTypeClass() == TypeClass_INTERFACE)
+ {
+ // acquire()/ release()
+ if (rtl_ustr_ascii_compare( ((typelib_TypeDescription *)getTypeDescr())->pTypeName->buffer,
+ "com.sun.star.uno.XInterface::acquire" ) == 0)
+ {
+ (*(const Reference< XInterface > *)rObj.getValue())->acquire();
+ return Any();
+ }
+ else if (rtl_ustr_ascii_compare( ((typelib_TypeDescription *)getTypeDescr())->pTypeName->buffer,
+ "com.sun.star.uno.XInterface::release" ) == 0)
+ {
+ (*(const Reference< XInterface > *)rObj.getValue())->release();
+ return Any();
+ }
+ }
+
+ uno_Interface * pUnoI = mapToUno( rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() );
+ OSL_ENSHURE( pUnoI, "### illegal destination object given!" );
+ if (pUnoI)
+ {
+ sal_Int32 nParams = getTypeDescr()->nParams;
+ if (rArgs.getLength() != nParams)
+ {
+ (*pUnoI->release)( pUnoI );
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("arguments len differ!") ),
+ *(const Reference< XInterface > *)rObj.getValue(), 1 );
+ }
+
+ Any * pCppArgs = rArgs.getArray();
+ typelib_MethodParameter * pParams = getTypeDescr()->pParams;
+ typelib_TypeDescription * pReturnType = 0;
+ TYPELIB_DANGER_GET( &pReturnType, getTypeDescr()->pReturnTypeRef );
+
+ void * pUnoReturn = alloca( pReturnType->nSize );
+ void ** ppUnoArgs = (void **)alloca( sizeof(void *) * nParams *2 );
+ typelib_TypeDescription ** ppParamTypes = (typelib_TypeDescription **)(ppUnoArgs + nParams);
+
+ // convert arguments
+ for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
+ {
+ ppParamTypes[nPos] = 0;
+ TYPELIB_DANGER_GET( ppParamTypes + nPos, pParams[nPos].pTypeRef );
+ typelib_TypeDescription * pTD = ppParamTypes[nPos];
+
+ ppUnoArgs[nPos] = alloca( pTD->nSize );
+ if (pParams[nPos].bIn)
+ {
+ sal_Bool bAssign;
+ if (typelib_typedescriptionreference_equals( pCppArgs[nPos].getValueTypeRef(), pTD->pWeakRef ))
+ {
+ uno_type_copyAndConvertData(
+ ppUnoArgs[nPos], (void *)pCppArgs[nPos].getValue(),
+ pCppArgs[nPos].getValueTypeRef(), getCpp2Uno().get() );
+ bAssign = sal_True;
+ }
+ else if (pTD->eTypeClass == typelib_TypeClass_ANY)
+ {
+ uno_type_any_constructAndConvert(
+ (uno_Any *)ppUnoArgs[nPos], (void *)pCppArgs[nPos].getValue(),
+ pCppArgs[nPos].getValueTypeRef(), getCpp2Uno().get() );
+ bAssign = sal_True;
+ }
+ else if (pCppArgs[nPos].getValueTypeClass() == TypeClass_INTERFACE &&
+ pTD->eTypeClass == typelib_TypeClass_INTERFACE)
+ {
+ Reference< XInterface > xDest;
+ if (bAssign = extract( pCppArgs[nPos], (typelib_InterfaceTypeDescription *)pTD,
+ xDest, getReflection() ))
+ {
+ *(void **)ppUnoArgs[nPos] = getCpp2Uno().mapInterface(
+ xDest.get(), (typelib_InterfaceTypeDescription *)pTD );
+ }
+ }
+ else
+ {
+ typelib_TypeDescription * pValueTD = 0;
+ TYPELIB_DANGER_GET( &pValueTD, pCppArgs[nPos].getValueTypeRef() );
+ // construct temp uno val to do proper assignment: todo opt
+ void * pTemp = alloca( pValueTD->nSize );
+ uno_copyAndConvertData(
+ pTemp, (void *)pCppArgs[nPos].getValue(), pValueTD, getCpp2Uno().get() );
+ uno_constructData(
+ ppUnoArgs[nPos], pTD );
+ // assignment does simple conversion
+ bAssign = uno_assignData(
+ ppUnoArgs[nPos], pTD, pTemp, pValueTD, 0, 0, 0 );
+ uno_destructData(
+ pTemp, pValueTD, 0 );
+ TYPELIB_DANGER_RELEASE( pValueTD );
+ }
+
+ if (! bAssign)
+ {
+ IllegalArgumentException aExc(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("cannot coerce argument type during corereflection call!") ),
+ *(const Reference< XInterface > *)rObj.getValue(), nPos );
+
+ // cleanup
+ while (nPos--)
+ {
+ if (pParams[nPos].bIn)
+ uno_destructData( ppUnoArgs[nPos], ppParamTypes[nPos], 0 );
+ TYPELIB_DANGER_RELEASE( ppParamTypes[nPos] );
+ }
+ TYPELIB_DANGER_RELEASE( pReturnType );
+ (*pUnoI->release)( pUnoI );
+
+ throw aExc;
+ }
+ }
+ }
+
+ uno_Any aUnoExc;
+ uno_Any * pUnoExc = &aUnoExc;
+
+ (*pUnoI->pDispatcher)(
+ pUnoI, (typelib_TypeDescription *)getTypeDescr(), pUnoReturn, ppUnoArgs, &pUnoExc );
+ (*pUnoI->release)( pUnoI );
+
+ Any aRet;
+ if (pUnoExc)
+ {
+ // cleanup
+ while (nParams--)
+ {
+ if (pParams[nParams].bIn)
+ uno_destructData( ppUnoArgs[nParams], ppParamTypes[nParams], 0 );
+ TYPELIB_DANGER_RELEASE( ppParamTypes[nParams] );
+ }
+ TYPELIB_DANGER_RELEASE( pReturnType );
+
+ InvocationTargetException aExc;
+ aExc.Context = *(const Reference< XInterface > *)rObj.getValue();
+ aExc.Message = OUString( RTL_CONSTASCII_USTRINGPARAM("exception occured during invocation!") );
+ uno_any_destruct( &aExc.TargetException, cpp_release );
+ uno_type_copyAndConvertData(
+ &aExc.TargetException, pUnoExc, ::getCppuType( (const Any *)0 ).getTypeLibType(), getUno2Cpp().get() );
+ uno_any_destruct( pUnoExc, 0 );
+ throw aExc;
+ }
+ else
+ {
+ // reconvert arguments and cleanup
+ while (nParams--)
+ {
+ if (pParams[nParams].bOut) // write back
+ {
+ uno_any_destruct( &pCppArgs[nParams], cpp_release );
+ uno_any_constructAndConvert(
+ &pCppArgs[nParams], ppUnoArgs[nParams], ppParamTypes[nParams], getUno2Cpp().get() );
+ }
+ uno_destructData( ppUnoArgs[nParams], ppParamTypes[nParams], 0 );
+ TYPELIB_DANGER_RELEASE( ppParamTypes[nParams] );
+ }
+ uno_any_destruct( &aRet, cpp_release );
+ uno_any_constructAndConvert( &aRet, pUnoReturn, pReturnType, getUno2Cpp().get() );
+ uno_destructData( pUnoReturn, pReturnType, 0 );
+ TYPELIB_DANGER_RELEASE( pReturnType );
+ }
+ return aRet;
+ }
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal destination object given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ return Any(); // dummy
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//__________________________________________________________________________________________________
+InterfaceIdlClassImpl::~InterfaceIdlClassImpl()
+{
+ for ( sal_Int32 nPos = _nMethods + _nAttributes; nPos--; )
+ typelib_typedescription_release( _pSortedMemberInit[nPos].second );
+
+ delete [] _pSortedMemberInit;
+}
+
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlClass > > InterfaceIdlClassImpl::getSuperclasses()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _xSuperClass.is())
+ {
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _xSuperClass.is())
+ {
+ typelib_InterfaceTypeDescription * pInterfaceTypeDescr = getTypeDescr()->pBaseTypeDescription;
+ if (pInterfaceTypeDescr)
+ _xSuperClass = getReflection()->forType( (typelib_TypeDescription *)pInterfaceTypeDescr );
+ }
+ }
+
+ if (_xSuperClass.is())
+ return Sequence< Reference< XIdlClass > >( &_xSuperClass, 1 );
+ else
+ return Sequence< Reference< XIdlClass > >();
+}
+//__________________________________________________________________________________________________
+void InterfaceIdlClassImpl::initMembers()
+{
+ sal_Int32 nAll = getTypeDescr()->nAllMembers;
+ MemberInit * pSortedMemberInit = new MemberInit[nAll];
+ typelib_TypeDescriptionReference ** ppAllMembers = getTypeDescr()->ppAllMembers;
+
+ for ( sal_Int32 nPos = 0; nPos < nAll; ++nPos )
+ {
+ sal_Int32 nIndex;
+ if (ppAllMembers[nPos]->eTypeClass == typelib_TypeClass_INTERFACE_METHOD)
+ {
+ // methods to front
+ nIndex = _nMethods;
+ ++_nMethods;
+ }
+ else
+ {
+ ++_nAttributes;
+ nIndex = (nAll - _nAttributes);
+ // attributes at the back
+ }
+
+ typelib_TypeDescription * pTD = 0;
+ typelib_typedescriptionreference_getDescription( &pTD, ppAllMembers[nPos] );
+ OSL_ENSHURE( pTD, "### cannot get type description!" );
+ pSortedMemberInit[nIndex].first = ((typelib_InterfaceMemberTypeDescription *)pTD)->pMemberName;
+ pSortedMemberInit[nIndex].second = pTD;
+ }
+
+ _pSortedMemberInit = pSortedMemberInit;
+}
+//__________________________________________________________________________________________________
+sal_Bool InterfaceIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (xType.is() && xType->getTypeClass() == TypeClass_INTERFACE)
+ {
+ if (equals( xType ))
+ return sal_True;
+ else
+ {
+ const Sequence< Reference< XIdlClass > > & rSeq = xType->getSuperclasses();
+ if (rSeq.getLength())
+ {
+ OSL_ENSHURE( rSeq.getLength() == 1, "### unexpected len of super classes!" );
+ return isAssignableFrom( rSeq[0] );
+ }
+ }
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+Uik InterfaceIdlClassImpl::getUik()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return *(Uik *)&getTypeDescr()->aUik;
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlMethod > > InterfaceIdlClassImpl::getMethods()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _pSortedMemberInit)
+ initMembers();
+
+ // create methods sequence
+ Sequence< Reference< XIdlMethod > > aRet( _nMethods );
+ Reference< XIdlMethod > * pRet = aRet.getArray();
+ for ( sal_Int32 nPos = _nMethods; nPos--; )
+ {
+
+ /*_aName2Method[_pSortedMemberInit[nPos].first] = */pRet[nPos] = new IdlInterfaceMethodImpl(
+ getReflection(), _pSortedMemberInit[nPos].first,
+ _pSortedMemberInit[nPos].second, IdlClassImpl::getTypeDescr() );
+ }
+ return aRet;
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XIdlField > > InterfaceIdlClassImpl::getFields()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _pSortedMemberInit)
+ initMembers();
+
+ // create fields sequence
+ Sequence< Reference< XIdlField > > aRet( _nAttributes );
+ Reference< XIdlField > * pRet = aRet.getArray();
+ for ( sal_Int32 nPos = _nAttributes; nPos--; )
+ {
+ /*_aName2Field[_pSortedMemberInit[_nMethods+nPos].first] = */pRet[_nAttributes-nPos-1] =
+ new IdlAttributeFieldImpl(
+ getReflection(), _pSortedMemberInit[_nMethods+nPos].first,
+ _pSortedMemberInit[_nMethods+nPos].second, IdlClassImpl::getTypeDescr() );
+ }
+ return aRet;
+}
+//__________________________________________________________________________________________________
+Reference< XIdlMethod > InterfaceIdlClassImpl::getMethod( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _pSortedMemberInit)
+ initMembers();
+
+ Reference< XIdlMethod > xRet;
+
+ // try weak map
+ const OUString2Method::const_iterator iFind( _aName2Method.find( rName ) );
+ if (iFind != _aName2Method.end())
+ xRet = (*iFind).second; // harden ref
+
+ if (! xRet.is())
+ {
+ for ( sal_Int32 nPos = _nMethods; nPos--; )
+ {
+ if (_pSortedMemberInit[nPos].first == rName)
+ {
+ _aName2Method[rName] = xRet = new IdlInterfaceMethodImpl(
+ getReflection(), rName,
+ _pSortedMemberInit[nPos].second, IdlClassImpl::getTypeDescr() );
+ break;
+ }
+ }
+ }
+ return xRet;
+}
+//__________________________________________________________________________________________________
+Reference< XIdlField > InterfaceIdlClassImpl::getField( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( getMutexAccess() );
+ if (! _pSortedMemberInit)
+ initMembers();
+
+ Reference< XIdlField > xRet;
+
+ // try weak map
+ const OUString2Field::const_iterator iFind( _aName2Field.find( rName ) );
+ if (iFind != _aName2Field.end())
+ xRet = (*iFind).second; // harden ref
+
+ if (! xRet.is())
+ {
+ for ( sal_Int32 nPos = _nAttributes; nPos--; )
+ {
+ if (_pSortedMemberInit[_nMethods+nPos].first == rName)
+ {
+ _aName2Field[rName] = xRet = new IdlAttributeFieldImpl(
+ getReflection(), rName,
+ _pSortedMemberInit[_nMethods+nPos].second, IdlClassImpl::getTypeDescr() );
+ break;
+ }
+ }
+ }
+ return xRet;
+}
+//__________________________________________________________________________________________________
+void InterfaceIdlClassImpl::createObject( Any & rObj )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ // interfaces cannot be constructed
+ rObj.clear();
+}
+
+}
+
+
diff --git a/stoc/source/corereflection/lrucache.hxx b/stoc/source/corereflection/lrucache.hxx
new file mode 100644
index 000000000000..4111f80973b3
--- /dev/null
+++ b/stoc/source/corereflection/lrucache.hxx
@@ -0,0 +1,282 @@
+/*************************************************************************
+ *
+ * $RCSfile: lrucache.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _LRU_CACHE_HXX_
+#define _LRU_CACHE_HXX_
+
+// __CACHE_DIAGNOSE forces cache size to 4 and works only for OUString keys
+// #define __CACHE_DIAGNOSE 1
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+#include <stl/hash_map>
+
+
+/** Implementation of a least recently used (lru) cache.
+ <br>
+ @author Daniel Boelzle
+*/
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+class LRU_Cache
+{
+ struct CacheEntry
+ {
+ t_Key aKey;
+ t_Val aVal;
+ CacheEntry * pPred;
+ CacheEntry * pSucc;
+ };
+ typedef ::std::hash_map< t_Key, CacheEntry *, t_KeyHash, t_KeyEqual > t_Key2Element;
+
+ mutable ::osl::Mutex _aCacheMutex;
+ sal_Int32 _nCachedElements;
+ t_Key2Element _aKey2Element;
+
+ CacheEntry * _pBlock;
+ mutable CacheEntry * _pHead;
+ mutable CacheEntry * _pTail;
+ inline void toFront( CacheEntry * pEntry ) const;
+
+public:
+ /** Constructor:
+ <br>
+ @param nCachedElements number of elements to be cached; default param set to 128
+ */
+ inline LRU_Cache( sal_Int32 nCachedElements = 128 );
+ /** Destructor: releases all cached elements and keys.
+ <br>
+ */
+ inline ~LRU_Cache();
+
+ /** Retrieves a value from the cache. Returns default constructed value,
+ if none was found.
+ <br>
+ @param rKey a key
+ @return value
+ */
+ inline t_Val getValue( const t_Key & rKey ) const;
+ /** Sets a value to be cached for given key.
+ <br>
+ @param rKey a key
+ @param rValue a value
+ */
+ inline void setValue( const t_Key & rKey, const t_Val & rValue );
+ /** Tests whether a value is cached for given key.
+ <br>
+ @param rKey a key
+ @return true, if value is cached
+ */
+ inline sal_Bool hasValue( const t_Key & rKey ) const;
+ /** Clears the cache, thus releasing all cached elements and keys.
+ <br>
+ */
+ inline void clear();
+};
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::LRU_Cache( sal_Int32 nCachedElements )
+#ifdef __CACHE_DIAGNOSE
+ : _nCachedElements( 4 )
+#else
+ : _nCachedElements( nCachedElements )
+#endif
+ , _pBlock( 0 )
+{
+ if (_nCachedElements > 0)
+ {
+ _pBlock = new CacheEntry[_nCachedElements];
+ _pHead = _pBlock;
+ _pTail = _pBlock + _nCachedElements -1;
+ for ( sal_Int32 nPos = _nCachedElements; nPos--; )
+ {
+ _pBlock[nPos].pPred = _pBlock + nPos -1;
+ _pBlock[nPos].pSucc = _pBlock + nPos +1;
+ }
+ }
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::~LRU_Cache()
+{
+ delete [] _pBlock;
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::toFront( CacheEntry * pEntry ) const
+{
+ if (pEntry != _pHead)
+ {
+ // cut out element
+ if (pEntry == _pTail)
+ {
+ _pTail = pEntry->pPred;
+ }
+ else
+ {
+ pEntry->pSucc->pPred = pEntry->pPred;
+ pEntry->pPred->pSucc = pEntry->pSucc;
+ }
+ // push to front
+ _pHead->pPred = pEntry;
+ pEntry->pSucc = _pHead;
+ _pHead = pEntry;
+ }
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline sal_Bool LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::hasValue( const t_Key & rKey ) const
+{
+ ::osl::MutexGuard aGuard( _aCacheMutex );
+ const t_Key2Element::const_iterator iFind( _aKey2Element.find( rKey ) );
+ return (iFind != _aKey2Element.end());
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline t_Val LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::getValue( const t_Key & rKey ) const
+{
+ ::osl::MutexGuard aGuard( _aCacheMutex );
+ const t_Key2Element::const_iterator iFind( _aKey2Element.find( rKey ) );
+ if (iFind != _aKey2Element.end())
+ {
+ CacheEntry * pEntry = (*iFind).second;
+ toFront( pEntry );
+#ifdef __CACHE_DIAGNOSE
+ OSL_TRACE( "> retrieved element \"" );
+ OSL_TRACE( ::rtl::OUStringToOString( pEntry->aKey, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ OSL_TRACE( "\" from cache <\n" );
+#endif
+ return pEntry->aVal;
+ }
+ return t_Val();
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::setValue(
+ const t_Key & rKey, const t_Val & rValue )
+{
+ if (_nCachedElements > 0)
+ {
+ ::osl::MutexGuard aGuard( _aCacheMutex );
+ const t_Key2Element::const_iterator iFind( _aKey2Element.find( rKey ) );
+
+ CacheEntry * pEntry;
+ if (iFind == _aKey2Element.end())
+ {
+ pEntry = _pTail; // erase last element
+#ifdef __CACHE_DIAGNOSE
+ if (pEntry->aKey.getLength())
+ {
+ OSL_TRACE( "> kicking element \"" );
+ OSL_TRACE( ::rtl::OUStringToOString( pEntry->aKey, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ OSL_TRACE( "\" from cache <\n" );
+ }
+#endif
+ _aKey2Element.erase( pEntry->aKey );
+ _aKey2Element[ pEntry->aKey = rKey ] = pEntry;
+ }
+ else
+ {
+ pEntry = (*iFind).second;
+#ifdef __CACHE_DIAGNOSE
+ OSL_TRACE( "> replacing element \"" );
+ OSL_TRACE( ::rtl::OUStringToOString( pEntry->aKey, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ OSL_TRACE( "\" in cache <\n" );
+#endif
+ }
+ pEntry->aVal = rValue;
+ toFront( pEntry );
+ }
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::clear()
+{
+ ::osl::MutexGuard aGuard( _aCacheMutex );
+ _aKey2Element.clear();
+ for ( sal_Int32 nPos = _nCachedElements; nPos--; )
+ {
+ _pBlock[nPos].aKey = t_Key();
+ _pBlock[nPos].aVal = t_Val();
+ }
+#ifdef __CACHE_DIAGNOSE
+ OSL_TRACE( "> cleared cache <\n" );
+#endif
+}
+
+//==================================================================================================
+struct FctHashOUString : public ::std::unary_function< const ::rtl::OUString &, size_t >
+{
+ size_t operator()( const ::rtl::OUString & rKey ) const
+ { return rKey.hashCode(); }
+};
+
+/** Template instance for OUString keys, Any values.<br>
+*/
+typedef LRU_Cache< ::rtl::OUString, ::com::sun::star::uno::Any,
+ FctHashOUString, ::std::equal_to< ::rtl::OUString > >
+ LRU_CacheAnyByOUString;
+
+
+#endif
diff --git a/stoc/source/corereflection/makefile.mk b/stoc/source/corereflection/makefile.mk
new file mode 100644
index 000000000000..4a9421865067
--- /dev/null
+++ b/stoc/source/corereflection/makefile.mk
@@ -0,0 +1,110 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= corefl
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+SLOFILES= \
+ $(SLO)$/crefl.obj \
+ $(SLO)$/crbase.obj \
+ $(SLO)$/crarray.obj \
+ $(SLO)$/crcomp.obj \
+ $(SLO)$/criface.obj \
+ $(SLO)$/crenum.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/source/cppumaker.mk b/stoc/source/cppumaker.mk
new file mode 100644
index 000000000000..50b331fcaebd
--- /dev/null
+++ b/stoc/source/cppumaker.mk
@@ -0,0 +1,77 @@
+#*************************************************************************
+#
+# $RCSfile: cppumaker.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb
+
+CPPUMAKERFLAGS =
+
+.IF "$(BOOTSTRAP_SERVICE)" == "TRUE"
+UNOUCROUT= $(OUT)$/inc$/bootstrap
+INCPRE+= $(OUT)$/inc$/bootstrap
+.ELSE
+.IF "$(COM)" == "MSC"
+CPPUMAKERFLAGS = -L
+.ENDIF
+UNOUCROUT= $(OUT)$/inc$/light
+INCPRE+= $(OUT)$/inc$/light
+.ENDIF
+
diff --git a/stoc/source/defaultregistry/defaultregistry.cxx b/stoc/source/defaultregistry/defaultregistry.cxx
new file mode 100644
index 000000000000..5e5ba13ae124
--- /dev/null
+++ b/stoc/source/defaultregistry/defaultregistry.cxx
@@ -0,0 +1,1440 @@
+/*************************************************************************
+ *
+ * $RCSfile: defaultregistry.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_HXX_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+#ifndef _REGISTRY_REGISTRY_HXX_
+#include <registry/registry.hxx>
+#endif
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::lang;
+using namespace cppu;
+using namespace vos;
+using namespace osl;
+using namespace rtl;
+
+
+#define NESTED_SERVICENAME "com.sun.star.registry.NestedRegistry"
+#define NESTED_IMPLNAME "com.sun.star.comp.stoc.NestedRegistry"
+
+namespace stoc_defreg
+{
+
+//*************************************************************************
+// NestedRegistryImpl
+//*************************************************************************
+class NestedKeyImpl;
+
+class NestedRegistryImpl : public WeakAggImplHelper3 < XSimpleRegistry, XInitialization, XServiceInfo >
+{
+public:
+ NestedRegistryImpl( const Reference<XMultiServiceFactory> & rXSMgr );
+
+ NestedRegistryImpl( const Reference<XMultiServiceFactory> & rXSMgr,
+ Reference<XSimpleRegistry>& localReg,
+ Reference<XSimpleRegistry>& systemReg );
+
+ ~NestedRegistryImpl();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+ static OUString SAL_CALL getImplementationName_Static( );
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( );
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
+ throw(Exception, RuntimeException);
+
+ // XSimpleRegistry
+ virtual OUString SAL_CALL getURL() throw(RuntimeException);
+ virtual void SAL_CALL open( const OUString& rURL, sal_Bool bReadOnly, sal_Bool bCreate ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Bool SAL_CALL isValid( ) throw(RuntimeException);
+ virtual void SAL_CALL close( ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL destroy( ) throw(InvalidRegistryException, RuntimeException);
+ virtual Reference< XRegistryKey > SAL_CALL getRootKey( ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL mergeKey( const OUString& aKeyName, const OUString& aUrl ) throw(InvalidRegistryException, MergeConflictException, RuntimeException);
+
+ friend NestedKeyImpl;
+protected:
+ Mutex m_mutex;
+ sal_uInt32 m_state;
+ Reference<XSimpleRegistry> m_localReg;
+ Reference<XSimpleRegistry> m_defaultReg;
+
+private:
+ Reference<XMultiServiceFactory> m_xSMgr;
+};
+
+//*************************************************************************
+// class NestedKeyImpl the implenetation of interface XRegistryKey
+//*************************************************************************
+class NestedKeyImpl : public WeakImplHelper1< XRegistryKey >
+{
+public:
+ NestedKeyImpl( NestedRegistryImpl* pDefaultRegistry,
+ Reference<XRegistryKey>& localKey,
+ Reference<XRegistryKey>& defaultKey);
+
+ NestedKeyImpl( const OUString& aKeyName,
+ NestedKeyImpl* pKey);
+
+ ~NestedKeyImpl();
+
+ // XRegistryKey
+ virtual OUString SAL_CALL getKeyName() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Bool SAL_CALL isValid( ) throw(RuntimeException);
+ virtual RegistryKeyType SAL_CALL getKeyType( const OUString& rKeyName ) throw(InvalidRegistryException, RuntimeException);
+ virtual RegistryValueType SAL_CALL getValueType( ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Int32 SAL_CALL getLongValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setLongValue( sal_Int32 value ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< sal_Int32 > SAL_CALL getLongListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setLongListValue( const ::com::sun::star::uno::Sequence< sal_Int32 >& seqValue ) throw(InvalidRegistryException, RuntimeException);
+ virtual OUString SAL_CALL getAsciiValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setAsciiValue( const OUString& value ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getAsciiListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setAsciiListValue( const ::com::sun::star::uno::Sequence< OUString >& seqValue ) throw(InvalidRegistryException, RuntimeException);
+ virtual OUString SAL_CALL getStringValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setStringValue( const OUString& value ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getStringListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setStringListValue( const ::com::sun::star::uno::Sequence< OUString >& seqValue ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getBinaryValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setBinaryValue( const ::com::sun::star::uno::Sequence< sal_Int8 >& value ) throw(InvalidRegistryException, RuntimeException);
+ virtual Reference< XRegistryKey > SAL_CALL openKey( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException);
+ virtual Reference< XRegistryKey > SAL_CALL createKey( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL closeKey( ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL deleteKey( const OUString& rKeyName ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< Reference< XRegistryKey > > SAL_CALL openKeys( ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getKeyNames( ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Bool SAL_CALL createLink( const OUString& aLinkName, const OUString& aLinkTarget ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL deleteLink( const OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException);
+ virtual OUString SAL_CALL getLinkTarget( const OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException);
+ virtual OUString SAL_CALL getResolvedName( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException);
+
+protected:
+ void computeChanges();
+ OUString computeName(const OUString& name);
+
+ OUString m_name;
+ sal_uInt32 m_state;
+ NestedRegistryImpl* m_pRegistry;
+ Reference<XRegistryKey> m_localKey;
+ Reference<XRegistryKey> m_defaultKey;
+};
+
+
+//*************************************************************************
+NestedKeyImpl::NestedKeyImpl( NestedRegistryImpl* pDefaultRegistry,
+ Reference<XRegistryKey>& localKey,
+ Reference<XRegistryKey>& defaultKey )
+ : m_pRegistry(pDefaultRegistry)
+{
+ m_pRegistry->acquire();
+
+ m_localKey = localKey;
+ m_defaultKey = defaultKey;
+
+ if (m_localKey.is())
+ {
+ m_name = m_localKey->getKeyName();
+ } else
+ if (m_defaultKey.is())
+ {
+ m_name = m_defaultKey->getKeyName();
+ }
+
+ m_state = m_pRegistry->m_state;
+}
+
+//*************************************************************************
+NestedKeyImpl::NestedKeyImpl( const OUString& rKeyName,
+ NestedKeyImpl* pKey)
+ : m_pRegistry(pKey->m_pRegistry)
+{
+ m_pRegistry->acquire();
+
+ if (pKey->m_localKey.is() && pKey->m_localKey->isValid())
+ {
+ m_localKey = pKey->m_localKey->openKey(rKeyName);
+ }
+ if (pKey->m_defaultKey.is() && pKey->m_defaultKey->isValid())
+ {
+ m_defaultKey = pKey->m_defaultKey->openKey(rKeyName);
+ }
+
+ if (m_localKey.is())
+ {
+ m_name = m_localKey->getKeyName();
+ } else
+ if (m_defaultKey.is())
+ {
+ m_name = m_defaultKey->getKeyName();
+ }
+
+ m_state = m_pRegistry->m_state;
+}
+
+//*************************************************************************
+NestedKeyImpl::~NestedKeyImpl()
+{
+ if ( m_pRegistry )
+ m_pRegistry->release();
+}
+
+//*************************************************************************
+void NestedKeyImpl::computeChanges()
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( m_state != m_pRegistry->m_state )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+
+ Reference<XRegistryKey> tmpKey = rootKey->openKey(m_name);
+
+ if ( tmpKey.is() )
+ {
+ m_localKey = rootKey->openKey(m_name);
+ }
+
+ m_state = m_pRegistry->m_state;
+ }
+}
+
+//*************************************************************************
+// NestedKey_Impl::computeName()
+//
+OUString NestedKeyImpl::computeName(const OUString& name)
+{
+ OUString resLocalName, resDefaultName;
+
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ try
+ {
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ resLocalName = m_localKey->getResolvedName(name);
+ } else
+ {
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ return m_defaultKey->getResolvedName(name);
+ }
+
+ if ( resLocalName.getLength() > 0 && m_pRegistry->m_defaultReg->isValid() )
+ {
+ Reference<XRegistryKey> localRoot(m_pRegistry->m_localReg->getRootKey());
+ Reference<XRegistryKey> defaultRoot(m_pRegistry->m_defaultReg->getRootKey());
+
+ resDefaultName = defaultRoot->getResolvedName(resLocalName);
+
+ sal_uInt32 count = 100;
+
+ while (resLocalName != resDefaultName && count > 0)
+ {
+ count--;
+
+ if (resLocalName.getLength() == 0 || resDefaultName.getLength() == 0)
+ throw InvalidRegistryException();
+
+ resLocalName = localRoot->getResolvedName(resDefaultName);
+ resDefaultName = defaultRoot->getResolvedName(resLocalName);
+ }
+ }
+ }
+ catch(InvalidRegistryException& )
+ {
+ }
+
+ return resLocalName;
+}
+
+//*************************************************************************
+OUString SAL_CALL NestedKeyImpl::getKeyName() throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ return m_name;
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL NestedKeyImpl::isReadOnly( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ return m_localKey->isReadOnly();
+ else
+ throw InvalidRegistryException();
+
+ return sal_False;
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL NestedKeyImpl::isValid( ) throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ return ((m_localKey.is() && m_localKey->isValid()) ||
+ (m_defaultKey.is() && m_defaultKey->isValid()) );
+}
+
+//*************************************************************************
+RegistryKeyType SAL_CALL NestedKeyImpl::getKeyType( const OUString& rKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ return m_localKey->getKeyType(rKeyName);
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ return m_defaultKey->getKeyType(rKeyName);
+ }
+
+ return RegistryKeyType_KEY;
+}
+
+//*************************************************************************
+RegistryValueType SAL_CALL NestedKeyImpl::getValueType( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ return m_localKey->getValueType();
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ return m_defaultKey->getValueType();
+ }
+
+ return RegistryValueType_NOT_DEFINED;
+}
+
+//*************************************************************************
+sal_Int32 SAL_CALL NestedKeyImpl::getLongValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ return m_localKey->getLongValue();
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ return m_defaultKey->getLongValue();
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return 0;
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::setLongValue( sal_Int32 value )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ m_localKey->setLongValue(value);
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+ m_localKey = rootKey->createKey(m_name);
+ m_localKey->setLongValue(value);
+ m_state = m_pRegistry->m_state++;
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+}
+
+//*************************************************************************
+Sequence< sal_Int32 > SAL_CALL NestedKeyImpl::getLongListValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ return m_localKey->getLongListValue();
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ return m_defaultKey->getLongListValue();
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return Sequence<sal_Int32>();
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::setLongListValue( const Sequence< sal_Int32 >& seqValue )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ m_localKey->setLongListValue(seqValue);
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+ m_localKey = rootKey->createKey(m_name);
+ m_localKey->setLongListValue(seqValue);
+ m_state = m_pRegistry->m_state++;
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+}
+
+//*************************************************************************
+OUString SAL_CALL NestedKeyImpl::getAsciiValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ return m_localKey->getAsciiValue();
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ return m_defaultKey->getAsciiValue();
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return OUString();
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::setAsciiValue( const OUString& value )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ m_localKey->setAsciiValue(value);
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+ m_localKey = rootKey->createKey(m_name);
+ m_localKey->setAsciiValue(value);
+ m_state = m_pRegistry->m_state++;
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+}
+
+//*************************************************************************
+Sequence< OUString > SAL_CALL NestedKeyImpl::getAsciiListValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ return m_localKey->getAsciiListValue();
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ return m_defaultKey->getAsciiListValue();
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return Sequence<OUString>();
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::setAsciiListValue( const Sequence< OUString >& seqValue )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ m_localKey->setAsciiListValue(seqValue);
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+ m_localKey = rootKey->createKey(m_name);
+ m_localKey->setAsciiListValue(seqValue);
+ m_state = m_pRegistry->m_state++;
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+}
+
+//*************************************************************************
+OUString SAL_CALL NestedKeyImpl::getStringValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ return m_localKey->getStringValue();
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ return m_defaultKey->getStringValue();
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return OUString();
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::setStringValue( const OUString& value )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ m_localKey->setStringValue(value);
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+ m_localKey = rootKey->createKey(m_name);
+ m_localKey->setStringValue(value);
+ m_state = m_pRegistry->m_state++;
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+}
+
+//*************************************************************************
+Sequence< OUString > SAL_CALL NestedKeyImpl::getStringListValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ return m_localKey->getStringListValue();
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ return m_defaultKey->getStringListValue();
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return Sequence<OUString>();
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::setStringListValue( const Sequence< OUString >& seqValue )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ m_localKey->setStringListValue(seqValue);
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+ m_localKey = rootKey->createKey(m_name);
+ m_localKey->setStringListValue(seqValue);
+ m_state = m_pRegistry->m_state++;
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+}
+
+//*************************************************************************
+Sequence< sal_Int8 > SAL_CALL NestedKeyImpl::getBinaryValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ return m_localKey->getBinaryValue();
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ return m_defaultKey->getBinaryValue();
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return Sequence<sal_Int8>();
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::setBinaryValue( const Sequence< sal_Int8 >& value )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ computeChanges();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ m_localKey->setBinaryValue(value);
+ } else
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+ m_localKey = rootKey->createKey(m_name);
+ m_localKey->setBinaryValue(value);
+ m_state = m_pRegistry->m_state++;
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+}
+
+//*************************************************************************
+Reference< XRegistryKey > SAL_CALL NestedKeyImpl::openKey( const OUString& aKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_localKey.is() && !m_defaultKey.is() )
+ {
+ throw InvalidRegistryException();
+ }
+
+ OUString resolvedName = computeName(aKeyName);
+
+ if ( resolvedName.getLength() == 0 )
+ throw InvalidRegistryException();
+
+ Reference<XRegistryKey> localKey, defaultKey;
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ localKey = m_pRegistry->m_localReg->getRootKey()->openKey(resolvedName);
+ }
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ defaultKey = m_pRegistry->m_defaultReg->getRootKey()->openKey(resolvedName);
+ }
+
+ if ( localKey.is() || defaultKey.is() )
+ {
+ return ((XRegistryKey*)new NestedKeyImpl(m_pRegistry, localKey, defaultKey));
+ } else
+ {
+ return Reference<XRegistryKey>();
+ }
+}
+
+//*************************************************************************
+Reference< XRegistryKey > SAL_CALL NestedKeyImpl::createKey( const OUString& aKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( (!m_localKey.is() && !m_defaultKey.is()) ||
+ (m_localKey.is() && m_localKey->isReadOnly()) )
+ {
+ throw InvalidRegistryException();
+ }
+
+ OUString resolvedName = computeName(aKeyName);
+
+ if ( resolvedName.getLength() == 0 )
+ throw InvalidRegistryException();
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ Reference<XRegistryKey> localKey, defaultKey;
+
+ localKey = m_pRegistry->m_localReg->getRootKey()->createKey(resolvedName);
+ if ( localKey.is() )
+ {
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ defaultKey = m_pRegistry->m_defaultReg->getRootKey()->openKey(resolvedName);
+ }
+
+ m_state = m_pRegistry->m_state++;
+
+ return ((XRegistryKey*)new NestedKeyImpl(m_pRegistry, localKey, defaultKey));
+ }
+ } else
+ {
+ Reference<XRegistryKey> localKey, defaultKey;
+
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+ m_localKey = rootKey->createKey(m_name);
+
+ localKey = m_pRegistry->m_localReg->getRootKey()->createKey(resolvedName);
+
+ if ( localKey.is() )
+ {
+ defaultKey = m_pRegistry->m_defaultReg->getRootKey()->openKey(resolvedName);
+
+ m_state = m_pRegistry->m_state++;
+
+ return ((XRegistryKey*)new NestedKeyImpl(m_pRegistry, localKey, defaultKey));
+ }
+ }
+ }
+
+ return Reference<XRegistryKey>();
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::closeKey( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ m_localKey->closeKey();
+ }
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ m_defaultKey->closeKey();
+ }
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::deleteKey( const OUString& rKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( m_localKey.is() && m_localKey->isValid() &&
+ !m_localKey->isReadOnly() )
+ {
+ OUString resolvedName = computeName(rKeyName);
+
+ if ( resolvedName.getLength() == 0 )
+ {
+ throw InvalidRegistryException();
+ }
+
+ m_pRegistry->m_localReg->getRootKey()->deleteKey(resolvedName);
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+}
+
+//*************************************************************************
+Sequence< Reference< XRegistryKey > > SAL_CALL NestedKeyImpl::openKeys( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_localKey.is() && !m_defaultKey.is() )
+ {
+ throw InvalidRegistryException();
+ }
+
+ Sequence<OUString> localSeq, defaultSeq;
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ localSeq = m_localKey->getKeyNames();
+ }
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ defaultSeq = m_defaultKey->getKeyNames();
+ }
+
+ sal_uInt32 local = localSeq.getLength();
+ sal_uInt32 def = defaultSeq.getLength();
+ sal_uInt32 len = 0;
+
+ sal_uInt32 i, j;
+ for (i=0; i < local; i++)
+ {
+ for (j=0 ; j < def; j++)
+ {
+ if ( localSeq.getConstArray()[i] == defaultSeq.getConstArray()[j] )
+ {
+ len++;
+ break;
+ }
+ }
+ }
+
+ Sequence< Reference<XRegistryKey> > retSeq(local + def - len);
+ sal_Bool insert = sal_True;
+ OUString name;
+ sal_Int32 lastIndex;
+
+ for (i=0; i < local; i++)
+ {
+ name = localSeq.getConstArray()[i];
+ lastIndex = name.lastIndexOf('/');
+ name = name.copy(lastIndex);
+ retSeq.getArray()[i] =
+ (XRegistryKey*)new NestedKeyImpl(name, this);
+ }
+
+ sal_uInt32 k = local;
+ for (i=0; i < def; i++)
+ {
+ insert = sal_True;
+
+ for (j=0 ; j < local; j++)
+ {
+ if ( retSeq.getConstArray()[j]->getKeyName()
+ == defaultSeq.getConstArray()[i] )
+ {
+ insert = sal_False;
+ break;
+ }
+ }
+
+ if ( insert )
+ {
+ name = defaultSeq.getConstArray()[i];
+ lastIndex = name.lastIndexOf('/');
+ name = name.copy(lastIndex);
+ retSeq.getArray()[k++] =
+ (XRegistryKey*)new NestedKeyImpl(name, this);
+ }
+ }
+
+ return retSeq;
+}
+
+//*************************************************************************
+Sequence< OUString > SAL_CALL NestedKeyImpl::getKeyNames( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_localKey.is() && !m_defaultKey.is() )
+ {
+ throw InvalidRegistryException();
+ }
+
+ Sequence<OUString> localSeq, defaultSeq;
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ localSeq = m_localKey->getKeyNames();
+ }
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ defaultSeq = m_defaultKey->getKeyNames();
+ }
+
+ sal_uInt32 local = localSeq.getLength();
+ sal_uInt32 def = defaultSeq.getLength();
+ sal_uInt32 len = 0;
+
+ sal_uInt32 i, j;
+ for (i=0; i < local; i++)
+ {
+ for (j=0 ; j < def; j++)
+ {
+ if ( localSeq.getConstArray()[i] == defaultSeq.getConstArray()[j] )
+ {
+ len++;
+ break;
+ }
+ }
+ }
+
+ Sequence<OUString> retSeq(local + def - len);
+ sal_Bool insert = sal_True;
+
+ for (i=0; i < local; i++)
+ {
+ retSeq.getArray()[i] = localSeq.getConstArray()[i];
+ }
+
+ sal_uInt32 k = local;
+ for (i=0; i < def; i++)
+ {
+ insert = sal_True;
+
+ for (j=0 ; j < local; j++)
+ {
+ if ( retSeq.getConstArray()[j] == defaultSeq.getConstArray()[i] )
+ {
+ insert = sal_False;
+ break;
+ }
+ }
+
+ if ( insert )
+ retSeq.getArray()[k++] = defaultSeq.getConstArray()[i];
+ }
+
+ return retSeq;
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL NestedKeyImpl::createLink( const OUString& aLinkName, const OUString& aLinkTarget )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+
+ sal_Bool isCreated = False;
+ if ( !m_localKey.is() && !m_defaultKey.is() )
+ {
+ throw InvalidRegistryException();
+ }
+
+ OUString linkName;
+ OUString resolvedName;
+ sal_Int32 lastIndex = aLinkName.lastIndexOf('/');
+
+ if ( lastIndex > 0 )
+ {
+ linkName = aLinkName.copy(0, lastIndex);
+
+ resolvedName = computeName(linkName);
+
+ if ( resolvedName.getLength() == 0 )
+ {
+ throw InvalidRegistryException();
+ }
+
+ resolvedName = resolvedName + aLinkName.copy(lastIndex);
+ } else
+ {
+ if ( lastIndex == 0 )
+ resolvedName = m_name + aLinkName;
+ else
+ resolvedName = m_name + OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + aLinkName;
+ }
+
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ isCreated = m_pRegistry->m_localReg->getRootKey()->createLink(resolvedName, aLinkTarget);
+ } else
+ {
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ {
+ Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey());
+ m_localKey = rootKey->createKey(m_name);
+
+ isCreated = m_pRegistry->m_localReg->getRootKey()->createLink(resolvedName, aLinkTarget);
+ }
+ }
+
+ if ( isCreated )
+ m_state = m_pRegistry->m_state++;
+
+ return isCreated;
+}
+
+//*************************************************************************
+void SAL_CALL NestedKeyImpl::deleteLink( const OUString& rLinkName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_localKey.is() && !m_defaultKey.is() )
+ {
+ throw InvalidRegistryException();
+ }
+
+ OUString linkName;
+ OUString resolvedName;
+ sal_Int32 lastIndex = rLinkName.lastIndexOf('/');
+
+ if ( lastIndex > 0 )
+ {
+ linkName = rLinkName.copy(0, lastIndex);
+
+ resolvedName = computeName(linkName);
+
+ if ( resolvedName.getLength() == 0 )
+ {
+ throw InvalidRegistryException();
+ }
+
+ resolvedName = resolvedName + rLinkName.copy(lastIndex);
+ } else
+ {
+ if ( lastIndex == 0 )
+ resolvedName = m_name + rLinkName;
+ else
+ resolvedName = m_name + OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + rLinkName;
+ }
+
+ if ( m_localKey.is() && m_localKey->isValid() &&
+ !m_localKey->isReadOnly() )
+ {
+ m_pRegistry->m_localReg->getRootKey()->deleteLink(resolvedName);
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+}
+
+//*************************************************************************
+OUString SAL_CALL NestedKeyImpl::getLinkTarget( const OUString& rLinkName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_localKey.is() && !m_defaultKey.is() )
+ {
+ throw InvalidRegistryException();
+ }
+
+ OUString linkName;
+ OUString resolvedName;
+ sal_Int32 lastIndex = rLinkName.lastIndexOf('/');
+
+ if ( lastIndex > 0 )
+ {
+ linkName = rLinkName.copy(0, lastIndex);
+
+ resolvedName = computeName(linkName);
+
+ if ( resolvedName.getLength() == 0 )
+ {
+ throw InvalidRegistryException();
+ }
+
+ resolvedName = resolvedName + rLinkName.copy(lastIndex);
+ } else
+ {
+ if ( lastIndex == 0 )
+ resolvedName = m_name + rLinkName;
+ else
+ resolvedName = m_name + OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + rLinkName;
+ }
+
+ OUString linkTarget;
+ if ( m_localKey.is() && m_localKey->isValid() )
+ {
+ try
+ {
+ linkTarget = m_pRegistry->m_localReg->getRootKey()->getLinkTarget(resolvedName);
+ return linkTarget;
+ }
+ catch(InvalidRegistryException& )
+ {
+ }
+ }
+
+ if ( m_defaultKey.is() && m_defaultKey->isValid() )
+ linkTarget = m_pRegistry->m_defaultReg->getRootKey()->getLinkTarget(resolvedName);
+
+ return linkTarget;
+}
+
+//*************************************************************************
+OUString SAL_CALL NestedKeyImpl::getResolvedName( const OUString& aKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_localKey.is() && !m_defaultKey.is() )
+ {
+ throw InvalidRegistryException();
+ }
+
+ OUString resolvedName = computeName(aKeyName);
+
+ if ( resolvedName.getLength() == 0 )
+ {
+ throw InvalidRegistryException();
+ }
+
+ return resolvedName;
+}
+
+//*************************************************************************
+//
+// DefaultRegistry Implementation
+//
+//*************************************************************************
+NestedRegistryImpl::NestedRegistryImpl( const Reference<XMultiServiceFactory> & rSMgr )
+ : m_state(0)
+ , m_xSMgr(rSMgr)
+{
+}
+
+NestedRegistryImpl::NestedRegistryImpl( const Reference<XMultiServiceFactory> & rSMgr,
+ Reference<XSimpleRegistry>& localReg,
+ Reference<XSimpleRegistry>& defaultReg)
+ : m_state(0)
+ , m_localReg(localReg)
+ , m_defaultReg(defaultReg)
+ , m_xSMgr(rSMgr)
+{
+}
+
+//*************************************************************************
+NestedRegistryImpl::~NestedRegistryImpl()
+{
+}
+
+//*************************************************************************
+OUString SAL_CALL NestedRegistryImpl::getImplementationName( )
+ throw(RuntimeException)
+{
+ return OUString::createFromAscii( NESTED_IMPLNAME );
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL NestedRegistryImpl::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL NestedRegistryImpl::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL NestedRegistryImpl::getSupportedServiceNames_Static( )
+{
+ OUString aStr( OUString::createFromAscii( NESTED_SERVICENAME ) );
+ return Sequence< OUString >( &aStr, 1 );
+}
+
+//*************************************************************************
+void SAL_CALL NestedRegistryImpl::initialize( const Sequence< Any >& aArguments )
+ throw( Exception, RuntimeException )
+{
+ Guard< Mutex > aGuard( m_mutex );
+ if ( (aArguments.getLength() == 2) &&
+ (aArguments[0].getValueType().getTypeClass() == TypeClass_INTERFACE) &&
+ (aArguments[1].getValueType().getTypeClass() == TypeClass_INTERFACE) )
+ {
+ aArguments[0] >>= m_localReg;
+ aArguments[1] >>= m_defaultReg;
+ if ( m_localReg == m_defaultReg )
+ m_defaultReg = Reference< XSimpleRegistry >();
+ }
+}
+
+//*************************************************************************
+OUString SAL_CALL NestedRegistryImpl::getURL() throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ try
+ {
+ if ( m_localReg.is() && m_localReg->isValid() )
+ return m_localReg->getURL();
+ }
+ catch(InvalidRegistryException& )
+ {
+ }
+
+ return OUString();
+}
+
+//*************************************************************************
+void SAL_CALL NestedRegistryImpl::open( const OUString& rURL, sal_Bool bReadOnly, sal_Bool bCreate )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ throw InvalidRegistryException();
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL NestedRegistryImpl::isValid( ) throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ try
+ {
+ if ( (m_localReg.is() && m_localReg->isValid()) ||
+ (m_defaultReg.is() && m_defaultReg->isValid()) )
+ return sal_True;
+ }
+ catch(InvalidRegistryException& )
+ {
+ }
+
+ return sal_False;
+}
+
+//*************************************************************************
+void SAL_CALL NestedRegistryImpl::close( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ throw InvalidRegistryException();
+}
+
+//*************************************************************************
+void SAL_CALL NestedRegistryImpl::destroy( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ throw InvalidRegistryException();
+}
+
+//*************************************************************************
+Reference< XRegistryKey > SAL_CALL NestedRegistryImpl::getRootKey( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Reference<XRegistryKey> tmpKey;
+
+ Guard< Mutex > aGuard( m_mutex );
+ if ( m_localReg.is() && m_localReg->isValid() )
+ {
+ Reference<XRegistryKey> localKey, defaultKey;
+
+ localKey = m_localReg->getRootKey();
+
+ if ( localKey.is() )
+ {
+ if ( m_defaultReg.is() && m_defaultReg->isValid() )
+ {
+ defaultKey = m_defaultReg->getRootKey();
+ }
+
+ return ((XRegistryKey*)new NestedKeyImpl(this, localKey, defaultKey));
+ }
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return Reference<XRegistryKey>();
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL NestedRegistryImpl::isReadOnly( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ try
+ {
+ if ( m_localReg.is() && m_localReg->isValid() )
+ return m_localReg->isReadOnly();
+ }
+ catch(InvalidRegistryException& )
+ {
+ }
+
+ return sal_False;
+}
+
+//*************************************************************************
+void SAL_CALL NestedRegistryImpl::mergeKey( const OUString& aKeyName, const OUString& aUrl )
+ throw(InvalidRegistryException, MergeConflictException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ if ( m_localReg.is() && m_localReg->isValid() )
+ {
+ m_localReg->mergeKey(aKeyName, aUrl);
+
+ m_state++;
+ }
+}
+
+//*************************************************************************
+Reference<XInterface> SAL_CALL NestedRegistry_CreateInstance( const Reference<XMultiServiceFactory>& rSMgr )
+ throw(Exception)
+{
+ Reference<XInterface> xRet;
+ XSimpleRegistry *pRegistry = (XSimpleRegistry*) new NestedRegistryImpl(rSMgr);
+
+ if (pRegistry)
+ {
+ xRet = Reference<XInterface>::query(pRegistry);
+ }
+
+ return xRet;
+}
+
+} // namespace stco_defreg
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ // NestedRegistry
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii( "/" NESTED_IMPLNAME "/UNO/SERVICES" ) ) );
+
+ Sequence< OUString > & rSNL = ::stoc_defreg::NestedRegistryImpl::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+ if ( rtl_str_compare( pImplName, NESTED_IMPLNAME ) == 0 )
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ ::stoc_defreg::NestedRegistry_CreateInstance,
+ ::stoc_defreg::NestedRegistryImpl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
+
diff --git a/stoc/source/defaultregistry/makefile.mk b/stoc/source/defaultregistry/makefile.mk
new file mode 100644
index 000000000000..af0e7cd2f347
--- /dev/null
+++ b/stoc/source/defaultregistry/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= defreg
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+BOOTSTRAP_SERVICE=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/defaultregistry.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx
new file mode 100644
index 000000000000..357d9d2184e6
--- /dev/null
+++ b/stoc/source/implementationregistration/implreg.cxx
@@ -0,0 +1,1750 @@
+/*************************************************************************
+ *
+ * $RCSfile: implreg.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stl/list>
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE3_HXX
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+#include <uno/mapping.hxx>
+#include <vos/thread.hxx>
+#include <vos/conditn.hxx>
+
+#include <rtl/ustring.hxx>
+
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/loader/XImplementationLoader.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#if defined(SAL_W32) || defined(SAL_OS2)
+#include <io.h>
+#endif
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::loader;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace cppu;
+using namespace rtl;
+using namespace vos;
+
+namespace stoc_impreg
+{
+
+#define IMPLEMENTATION_NAME "com.sun.star.comp.stoc.ImplementationRegistration"
+#define SERVICE_NAME "com.sun.star.registry.ImplementationRegistration"
+
+//*************************************************************************
+// static getTempName()
+//
+// Shouldn't this whole routine be rewritten ???? (jbu)
+
+static OUString getTempName()
+{
+ OUString uTmpPath;
+ OString tmpPath;
+ sal_Char tmpPattern[512];
+ sal_Char *pTmpName = NULL;
+
+ OStartupInfo StartupInfo;
+
+ if (StartupInfo.getEnvironment(OUString(RTL_CONSTASCII_USTRINGPARAM("TMP")), uTmpPath) != OStartupInfo::E_None)
+ {
+ if (StartupInfo.getEnvironment(OUString(RTL_CONSTASCII_USTRINGPARAM("TEMP")), uTmpPath) != OStartupInfo::E_None)
+ {
+#if defined(WIN32) || defined(WNT) || defined(OS2)
+ tmpPath = OString("c:\\temp");
+#else
+ tmpPath = OString("/tmp");
+#endif
+ }
+ }
+
+ if (uTmpPath.getLength())
+ {
+ tmpPath = OUStringToOString(uTmpPath, osl_getThreadTextEncoding());
+ }
+
+#if defined(WIN32) || defined(WNT)
+ strcpy(tmpPattern, tmpPath.getStr());
+ strcat(tmpPattern, "\\reg_XXXXXX");
+ pTmpName = mktemp(tmpPattern);
+#endif
+
+#ifdef __OS2__
+ strcpy(tmpPattern, tempnam(NULL, "reg_"));
+ pTmpName = tmpPattern;
+#endif
+
+#ifdef UNX
+ strcpy(tmpPattern, tmpPath.getStr());
+ strcat(tmpPattern, "/reg_XXXXXX");
+ pTmpName = mktemp(tmpPattern);
+#endif
+
+ return OStringToOUString(pTmpName, osl_getThreadTextEncoding());
+}
+
+//*************************************************************************
+// static deleteAllLinkReferences()
+//
+static void deleteAllLinkReferences(const Reference < XSimpleRegistry >& xReg,
+ const Reference < XRegistryKey >& xSource)
+{
+ try
+ {
+ Reference < XRegistryKey > xKey = xSource->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/REGISTRY_LINKS") ) );
+
+ if (xKey.is() && (xKey->getValueType() == RegistryValueType_ASCIILIST))
+ {
+ Sequence<OUString> linkNames = xKey->getAsciiListValue();
+
+ if (linkNames.getLength())
+ {
+ const OUString* pLinkNames = linkNames.getConstArray();
+
+ OUString aLinkName;
+ OUString aLinkParent;
+ Reference < XRegistryKey > xLinkParent;
+ const sal_Unicode* pTmpName = NULL;
+ const sal_Unicode* pShortName = NULL;
+ sal_Int32 sEnd = 0;
+
+ for (sal_Int32 i = 0; i < linkNames.getLength(); i++)
+ {
+ aLinkName = pLinkNames[i];
+
+ pTmpName = aLinkName.getStr();
+
+ if (pTmpName[0] != L'/')
+ continue;
+
+ sal_Int32 nIndex = rtl_ustr_indexOfChar( pTmpName, '%' );
+ if ( nIndex == -1 )
+ pShortName = 0;
+ else
+ pShortName = pTmpName+nIndex;
+
+ while (pShortName && pShortName[1] == L'%')
+ {
+ nIndex = rtl_ustr_indexOfChar( pShortName+2, '%' );
+ if ( nIndex == -1 )
+ pShortName = 0;
+ else
+ pShortName += nIndex+2;
+ }
+
+ if (pShortName)
+ {
+ aLinkName = aLinkName.copy(0, pShortName - pTmpName);
+ }
+
+ xReg->getRootKey()->deleteLink(aLinkName);
+
+ sEnd = rtl_ustr_lastIndexOfChar( aLinkName.getStr(), '/' );
+
+ aLinkParent = aLinkName.copy(0, sEnd);
+
+ while(aLinkParent.len())
+ {
+ xLinkParent = xReg->getRootKey()->openKey(aLinkParent);
+
+ if (xLinkParent.is() && (xLinkParent->getKeyNames().getLength() == 0))
+ {
+ aLinkName = aLinkParent;
+
+ xReg->getRootKey()->deleteKey(aLinkParent);
+
+ sEnd = rtl_ustr_lastIndexOfChar( aLinkName.getStr(), '/' );
+
+ aLinkParent = aLinkName.copy(0, sEnd);
+ } else
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+}
+
+//*************************************************************************
+// static prepareLink
+//
+static void prepareLink( const Reference < XSimpleRegistry > & xDest,
+ const Reference < XRegistryKey > & xSource,
+ const OUString& link)
+{
+ try
+ {
+ OUString linkRefName = xSource->getKeyName();
+ OUString linkName(link);
+ sal_Bool isRelativ = False;
+
+ const sal_Unicode* pTmpName = link.getStr();
+ const sal_Unicode* pShortName;
+ sal_Int32 nIndex = rtl_ustr_indexOfChar( pTmpName, '%' );
+ if ( nIndex == -1 )
+ pShortName = 0;
+ else
+ pShortName = pTmpName+nIndex;
+
+ if (pTmpName[0] != L'/')
+ isRelativ = sal_True;
+
+ while (pShortName && pShortName[1] == L'%')
+ {
+ nIndex = rtl_ustr_indexOfChar( pShortName+2, '%' );
+ if ( nIndex == -1 )
+ pShortName = 0;
+ else
+ pShortName += nIndex+2;
+ }
+
+ if (pShortName)
+ {
+ linkRefName = linkRefName + link.copy(pShortName - pTmpName + 1);
+ linkName = link.copy(0, pShortName - pTmpName);
+ }
+
+ if (isRelativ)
+ xSource->createLink(linkName, linkRefName);
+ else
+ xDest->getRootKey()->createLink(linkName, linkRefName);
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+}
+
+//*************************************************************************
+// static searchImplForLink
+//
+static OUString searchImplForLink(const Reference < XRegistryKey > & xRootKey,
+ const OUString& linkName,
+ const OUString& implName)
+{
+ OUString ret;
+
+ try
+ {
+ Reference < XRegistryKey > xKey = xRootKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/IMPLEMENTATIONS") ) );
+
+ if (xKey.is())
+ {
+ Sequence< Reference < XRegistryKey > > subKeys = xKey->openKeys();
+
+ const Reference < XRegistryKey > * pSubKeys = subKeys.getConstArray();
+ Reference < XRegistryKey > xImplKey;
+
+ for (sal_Int32 i = 0; i < subKeys.getLength(); i++)
+ {
+ xImplKey = pSubKeys[i];
+
+ try
+ {
+ if (xImplKey->getKeyType( OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO") ) + linkName) == RegistryKeyType_LINK)
+ {
+ OUString oldImplName = xImplKey->getKeyName().copy(strlen("/IMPLEMENTATIONS/"));
+ if (implName != oldImplName)
+ {
+ ret = oldImplName;
+ break;
+ }
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+ }
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// static searchLinkTargetForImpl
+//
+static OUString searchLinkTargetForImpl(const Reference < XRegistryKey >& xRootKey,
+ const OUString& linkName,
+ const OUString& implName)
+{
+ OUString ret;
+
+ try
+ {
+ Reference < XRegistryKey > xKey = xRootKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/IMPLEMENTATIONS") ) );
+
+ if (xKey.is())
+ {
+ Sequence< Reference < XRegistryKey > > subKeys = xKey->openKeys();
+
+ const Reference < XRegistryKey >* pSubKeys = subKeys.getConstArray();
+ Reference < XRegistryKey > xImplKey;
+
+ for (sal_Int32 i = 0; i < subKeys.getLength(); i++)
+ {
+ xImplKey = pSubKeys[i];
+
+ OUString tmpImplName = xImplKey->getKeyName().copy(strlen("/IMPLEMENTATIONS/"));
+ if (tmpImplName == implName &&
+ xImplKey->getKeyType(OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO") ) + linkName) == RegistryKeyType_LINK)
+ {
+ return xImplKey->getLinkTarget(OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO") ) + linkName);
+ }
+ }
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// static createUniqueSubEntry
+//
+static void createUniqueSubEntry(const Reference < XRegistryKey > & xSuperKey,
+ const OUString& value)
+{
+ if (xSuperKey.is())
+ {
+ try
+ {
+ if (xSuperKey->getValueType() == RegistryValueType_ASCIILIST)
+ {
+ sal_Int32 entryNum = 1;
+ sal_Int32 length = 0;
+ sal_Bool bReady = sal_False;
+
+ Sequence<OUString> implEntries = xSuperKey->getAsciiListValue();
+ length = implEntries.getLength();
+
+ for (sal_Int32 i = 0; !bReady && (i < length); i++)
+ {
+ bReady = (implEntries.getConstArray()[i] == value);
+ }
+
+ if (bReady)
+ {
+ Sequence<OUString> implEntriesNew(length);
+ implEntriesNew.getArray()[0] = value;
+
+ for (sal_Int32 i=0, j=1; i < length; i++)
+ {
+ if (implEntries.getConstArray()[i] != value)
+ implEntriesNew.getArray()[j++] = implEntries.getConstArray()[i];
+ }
+ xSuperKey->setAsciiListValue(implEntriesNew);
+ } else
+ {
+ Sequence<OUString> implEntriesNew(length+1);
+ implEntriesNew.getArray()[0] = value;
+
+ for (sal_Int32 i = 0; i < length; i++)
+ {
+ implEntriesNew.getArray()[i+1] = implEntries.getConstArray()[i];
+ }
+ xSuperKey->setAsciiListValue(implEntriesNew);
+ }
+ } else
+ {
+ Sequence<OUString> implEntriesNew(1);
+
+ implEntriesNew.getArray()[0] = value;
+
+ xSuperKey->setAsciiListValue(implEntriesNew);
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+ }
+}
+
+//*************************************************************************
+// static deleteSubEntry
+//
+static sal_Bool deleteSubEntry(const Reference < XRegistryKey >& xSuperKey, const OUString& value)
+{
+ if (xSuperKey.is())
+ {
+ try
+ {
+ if (xSuperKey->getValueType() == RegistryValueType_ASCIILIST)
+ {
+ Sequence<OUString> implEntries = xSuperKey->getAsciiListValue();
+ sal_Int32 length = implEntries.getLength();
+ sal_Int32 equals = 0;
+ sal_Bool hasNoImplementations = sal_False;
+
+ for (sal_Int32 i = 0; i < length; i++)
+ {
+ if (implEntries.getConstArray()[i] == value)
+ equals++;
+ }
+
+ if (equals == length)
+ {
+ hasNoImplementations = sal_True;
+ } else
+ {
+ Sequence<OUString> implEntriesNew(length - equals);
+
+ sal_Int32 j = 0;
+ for (sal_Int32 i = 0; i < length; i++)
+ {
+ if (implEntries.getConstArray()[i] != value)
+ {
+ implEntriesNew.getArray()[j++] = implEntries.getConstArray()[i];
+ }
+ }
+ xSuperKey->setAsciiListValue(implEntriesNew);
+ }
+
+ if (hasNoImplementations)
+ {
+ return sal_True;
+ }
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+ }
+
+ return sal_False;
+}
+
+//*************************************************************************
+// static prepareUserLink
+//
+static sal_Bool prepareUserLink(const Reference < XSimpleRegistry >& xDest,
+ const OUString& linkName,
+ const OUString& linkTarget,
+ const OUString& implName)
+{
+ sal_Bool ret = sal_False;
+
+ Reference < XRegistryKey > xRootKey;
+
+ try
+ {
+ xRootKey = xDest->getRootKey();
+
+ if (xRootKey->getKeyType(linkName) == RegistryKeyType_LINK)
+ {
+ OUString oldImplName(searchImplForLink(xRootKey, linkName, implName));
+
+ if (oldImplName.len())
+ {
+ createUniqueSubEntry(xDest->getRootKey()->createKey(
+ linkName + OUString( RTL_CONSTASCII_USTRINGPARAM(":old") ) ), oldImplName);
+ }
+ }
+ }
+ catch (InvalidRegistryException&)
+ {
+ }
+
+ try
+ {
+ if (xRootKey->isValid())
+ {
+ ret = xRootKey->createLink(linkName, linkTarget);
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// static deleteUserLink
+//
+static void deletePathIfPossible(const Reference < XRegistryKey >& xRootKey,
+ const OUString& path)
+{
+ try
+ {
+ Sequence<OUString> keyNames(xRootKey->openKey(path)->getKeyNames());
+
+ if (keyNames.getLength() == 0 &&
+ xRootKey->openKey(path)->getValueType() == RegistryValueType_NOT_DEFINED)
+ {
+ xRootKey->deleteKey(path);
+
+ OUString tmpPath(path);
+ OUString newPath = tmpPath.copy(0, tmpPath.lastIndexOf('/')).getStr();
+
+ if (newPath.len() > 1)
+ deletePathIfPossible(xRootKey, newPath);
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+}
+
+
+//*************************************************************************
+// static deleteUserLink
+//
+static sal_Bool deleteUserLink(const Reference < XRegistryKey >& xRootKey,
+ const OUString& linkName,
+ const OUString& linkTarget,
+ const OUString& implName)
+{
+ sal_Bool ret = sal_False;
+
+ try
+ {
+ sal_Bool bClean = sal_False;
+
+ if (xRootKey->getKeyType(linkName) == RegistryKeyType_LINK)
+ {
+ OUString tmpTarget = xRootKey->getLinkTarget(linkName);
+
+ if (tmpTarget == linkTarget)
+ {
+ xRootKey->deleteLink(linkName);
+ }
+ }
+
+ Reference < XRegistryKey > xOldKey = xRootKey->openKey(
+ linkName + OUString( RTL_CONSTASCII_USTRINGPARAM(":old") ));
+ if (xOldKey.is())
+ {
+ sal_Bool hasNoImplementations = sal_False;
+
+ if (xOldKey->getValueType() == RegistryValueType_ASCIILIST)
+ {
+ Sequence<OUString> implEntries = xOldKey->getAsciiListValue();
+ sal_Int32 length = implEntries.getLength();
+ sal_Int32 equals = 0;
+
+ for (sal_Int32 i = 0; i < length; i++)
+ {
+ if (implEntries.getConstArray()[i] == implName)
+ equals++;
+ }
+
+ if (equals == length)
+ {
+ hasNoImplementations = sal_True;
+ } else
+ {
+ OUString oldImpl;
+
+ if (length > equals + 1)
+ {
+ Sequence<OUString> implEntriesNew(length - equals - 1);
+
+ sal_Int32 j = 0;
+ sal_Bool first = sal_True;
+ for (sal_Int32 i = 0; i < length; i++)
+ {
+ if (implEntries.getConstArray()[i] != implName)
+ {
+ if (first)
+ {
+ oldImpl = implEntries.getConstArray()[i];
+ first = sal_False;
+ } else
+ {
+ implEntriesNew.getArray()[j++] = implEntries.getConstArray()[i];
+ }
+ }
+ }
+
+ xOldKey->setAsciiListValue(implEntriesNew);
+ } else
+ {
+ oldImpl = implEntries.getConstArray()[0];
+
+ xOldKey->closeKey();
+ xRootKey->deleteKey(xOldKey->getKeyName());
+ }
+
+ OUString oldTarget = searchLinkTargetForImpl(xRootKey, linkName, oldImpl);
+ if (oldTarget.len())
+ {
+ xRootKey->createLink(linkName, oldTarget);
+ }
+ }
+
+ if (hasNoImplementations)
+ {
+ bClean = sal_True;
+ hasNoImplementations = sal_False;
+ xOldKey->closeKey();
+ xRootKey->deleteKey(xOldKey->getKeyName());
+ }
+ }
+ } else
+ {
+ bClean = sal_True;
+ }
+
+ if (bClean)
+ {
+ OUString tmpName(linkName);
+ OUString path = tmpName.copy(0, tmpName.lastIndexOf('/')).getStr();
+ deletePathIfPossible(xRootKey, path);
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// static prepareUserKeys
+//
+static sal_Bool prepareUserKeys(const Reference < XSimpleRegistry >& xDest,
+ const Reference < XRegistryKey >& xUnoKey,
+ const Reference < XRegistryKey >& xKey,
+ const OUString& implName,
+ sal_Bool bRegister)
+{
+ sal_Bool ret = sal_False;
+ sal_Bool hasSubKeys = sal_False;
+
+ try
+ {
+ Sequence<OUString> keyNames = xKey->getKeyNames();
+
+ OUString relativKey;
+ if (keyNames.getLength())
+ relativKey = keyNames.getConstArray()[0].copy(xKey->getKeyName().len()+1);
+
+ if (keyNames.getLength() == 1 &&
+ xKey->getKeyType(relativKey) == RegistryKeyType_LINK)
+ {
+ hasSubKeys = sal_True;
+
+ OUString linkTarget = xKey->getLinkTarget(relativKey);
+ OUString linkName(xKey->getKeyName().copy(xUnoKey->getKeyName().len()));
+
+ linkName = linkName + OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + relativKey;
+
+ if (bRegister)
+ {
+ prepareUserLink(xDest, linkName, linkTarget, implName);
+ } else
+ {
+ deleteUserLink(xDest->getRootKey(), linkName, linkTarget, implName);
+ }
+ } else
+ {
+ Sequence< Reference < XRegistryKey> > subKeys = xKey->openKeys();
+
+ if (subKeys.getLength())
+ {
+ hasSubKeys = sal_True;
+ const Reference < XRegistryKey > * pSubKeys = subKeys.getConstArray();
+
+ for (sal_Int32 i = 0; i < subKeys.getLength(); i++)
+ {
+ ret = prepareUserKeys(xDest, xUnoKey, pSubKeys[i], implName, bRegister);
+ }
+ }
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ try
+ {
+ if (hasSubKeys)
+ {
+ return ret;
+ }
+
+ OUString keyName(xKey->getKeyName().copy(xUnoKey->getKeyName().len()));
+
+ Reference < XRegistryKey > xRootKey = xDest->getRootKey();
+ if (bRegister)
+ {
+ createUniqueSubEntry(xRootKey->createKey(keyName), implName);
+ } else
+ {
+ if (deleteSubEntry(xRootKey->openKey(keyName), implName))
+ {
+ xRootKey->deleteKey(keyName);
+
+ OUString tmpName(keyName);
+ OUString path = tmpName.copy(0, tmpName.lastIndexOf('/')).getStr();
+ deletePathIfPossible(xRootKey, path);
+ }
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// static deleteAllImplementations
+//
+static void deleteAllImplementations( const Reference < XSimpleRegistry >& xReg,
+ const Reference < XRegistryKey >& xSource,
+ const OUString& locationUrl,
+ std::list<OUString> & implNames)
+{
+ try
+ {
+ Sequence < Reference < XRegistryKey > > subKeys = xSource->openKeys();
+
+ if (subKeys.getLength() > 0)
+ {
+ const Reference < XRegistryKey> * pSubKeys = subKeys.getConstArray();
+ Reference < XRegistryKey > xImplKey;
+ sal_Bool hasLocationUrl = sal_False;
+
+ for (sal_Int32 i = 0; i < subKeys.getLength(); i++)
+ {
+ xImplKey = pSubKeys[i];
+ Reference < XRegistryKey > xKey = xImplKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/LOCATION") ) );;
+
+ if (xKey.is() && (xKey->getValueType() == RegistryValueType_ASCII))
+ {
+ if (xKey->getAsciiValue() == locationUrl)
+ {
+ hasLocationUrl = sal_True;
+
+ OUString implName(xImplKey->getKeyName().getStr() + 1);
+ sal_Int32 firstDot = implName.search(L'/');
+
+ if (firstDot >= 0)
+ implName = implName.copy(firstDot + 1);
+
+ implNames.push_back(implName);
+
+ deleteAllLinkReferences(xReg, xImplKey);
+
+ xKey = xImplKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO")));
+ if (xKey.is())
+ {
+ Sequence< Reference < XRegistryKey > > subKeys = xKey->openKeys();
+
+ if (subKeys.getLength())
+ {
+ const Reference < XRegistryKey > * pSubKeys = subKeys.getConstArray();
+
+ for (sal_Int32 i = 0; i < subKeys.getLength(); i++)
+ {
+ if (pSubKeys[i]->getKeyName() != (xImplKey->getKeyName() + OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVCIES") )) &&
+ pSubKeys[i]->getKeyName() != (xImplKey->getKeyName() + OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/REGISTRY_LINKS") )) &&
+ pSubKeys[i]->getKeyName() != (xImplKey->getKeyName() + OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") )) &&
+ pSubKeys[i]->getKeyName() != (xImplKey->getKeyName() + OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/LOCATION") )))
+ {
+ prepareUserKeys(xReg, xKey, pSubKeys[i], implName, sal_False);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (hasLocationUrl)
+ {
+ hasLocationUrl = sal_False;
+ xImplKey->closeKey();
+ xReg->getRootKey()->deleteKey(xImplKey->getKeyName());
+ }
+ }
+
+ subKeys = xSource->openKeys();
+ if (subKeys.getLength() == 0)
+ {
+ xSource->closeKey();
+ xReg->getRootKey()->deleteKey(xSource->getKeyName());
+ }
+ } else
+ {
+ xSource->closeKey();
+ xReg->getRootKey()->deleteKey(xSource->getKeyName());
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+}
+
+//*************************************************************************
+// static deleteAllServiceEntries
+//
+static void deleteAllServiceEntries( const Reference < XSimpleRegistry >& xReg,
+ const Reference < XRegistryKey >& xSource,
+ const OUString& implName)
+{
+ try
+ {
+ Sequence< Reference < XRegistryKey > > subKeys = xSource->openKeys();
+
+ if (subKeys.getLength() > 0)
+ {
+ const Reference < XRegistryKey > * pSubKeys = subKeys.getConstArray();
+ Reference < XRegistryKey > xServiceKey;
+ sal_Bool hasNoImplementations = sal_False;
+
+ for (sal_Int32 i = 0; i < subKeys.getLength(); i++)
+ {
+ xServiceKey = pSubKeys[i];
+
+ if (xServiceKey->getValueType() == RegistryValueType_ASCIILIST)
+ {
+ Sequence<OUString> implEntries = xServiceKey->getAsciiListValue();
+ sal_Int32 length = implEntries.getLength();
+ sal_Int32 equals = 0;
+
+ for (sal_Int32 i = 0; i < length; i++)
+ {
+ if (implEntries.getConstArray()[i] == implName)
+ equals++;
+ }
+
+ if (equals == length)
+ {
+ hasNoImplementations = sal_True;
+ } else
+ {
+ if (equals > 0)
+ {
+ Sequence<OUString> implEntriesNew(length-equals);
+
+ sal_Int32 j = 0;
+ for (sal_Int32 i = 0; i < length; i++)
+ {
+ if (implEntries.getConstArray()[i] != implName)
+ {
+ implEntriesNew.getArray()[j++] = implEntries.getConstArray()[i];
+ }
+ }
+
+ xServiceKey->setAsciiListValue(implEntriesNew);
+ }
+ }
+ }
+
+ if (hasNoImplementations)
+ {
+ hasNoImplementations = sal_False;
+ xServiceKey->closeKey();
+ xReg->getRootKey()->deleteKey(xServiceKey->getKeyName());
+ }
+ }
+
+ subKeys = xSource->openKeys();
+ if (subKeys.getLength() == 0)
+ {
+ xSource->closeKey();
+ xReg->getRootKey()->deleteKey(xSource->getKeyName());
+ }
+ } else
+ {
+ xSource->closeKey();
+ xReg->getRootKey()->deleteKey(xSource->getKeyName());
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+}
+
+
+//*************************************************************************
+// static prepareRegistry
+//
+static sal_Bool prepareRegistry(const Reference < XSimpleRegistry >& xDest,
+ const Reference < XRegistryKey >& xSource,
+ const OUString& implementationLoaderUrl,
+ const OUString& locationUrl)
+{
+ sal_Bool ret = sal_False;
+
+ try
+ {
+ Sequence< Reference < XRegistryKey > > subKeys = xSource->openKeys();
+
+ if (!subKeys.getLength())
+ {
+ return ret;
+ }
+
+
+ const Reference < XRegistryKey >* pSubKeys = subKeys.getConstArray();
+ Reference < XRegistryKey > xImplKey;
+
+ for (sal_Int32 i = 0; i < subKeys.getLength(); i++)
+ {
+ xImplKey = pSubKeys[i];
+
+ Reference < XRegistryKey > xKey = xImplKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) );
+
+ if (xKey.is())
+ {
+ // update entries in SERVICES section
+ Sequence< Reference < XRegistryKey > > serviceKeys = xKey->openKeys();
+ OUString implName;
+
+ if (serviceKeys.getLength())
+ {
+ const Reference < XRegistryKey > * pServiceKeys = serviceKeys.getConstArray();
+
+ implName = OUString(xImplKey->getKeyName().getStr() + 1);
+ sal_Int32 firstDot = implName.search(L'/');
+
+ if (firstDot >= 0)
+ implName = implName.copy(firstDot + 1);
+
+ sal_Int32 offset = xKey->getKeyName().len() + 1;
+
+ for (sal_Int32 i = 0; i < serviceKeys.getLength(); i++)
+ {
+ OUString serviceName = pServiceKeys[i]->getKeyName().copy(offset);
+
+ createUniqueSubEntry(
+ xDest->getRootKey()->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/SERVICES/") ) + serviceName ),
+ implName);
+ }
+
+ ret = sal_True;
+ }
+
+ xKey = xImplKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO") ));
+ if (xKey.is())
+ {
+ Sequence< Reference < XRegistryKey > > subKeys = xKey->openKeys();
+
+ if (subKeys.getLength())
+ {
+ const Reference < XRegistryKey > * pSubKeys = subKeys.getConstArray();
+
+ for (sal_Int32 i = 0; i < subKeys.getLength(); i++)
+ {
+ if (pSubKeys[i]->getKeyName() != (xImplKey->getKeyName() + OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVCIES") )) &&
+ pSubKeys[i]->getKeyName() != (xImplKey->getKeyName() + OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/REGISTRY_LINKS") )))
+ {
+ prepareUserKeys(xDest, xKey, pSubKeys[i], implName, sal_True);
+ }
+ }
+ }
+ }
+
+ // update LOCATION entry
+ xKey = xImplKey->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/LOCATION") ) );
+
+ if (xKey.is())
+ {
+ xKey->setAsciiValue(locationUrl);
+ }
+
+ // update ACTIVATOR entry
+ xKey = xImplKey->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") ) );
+
+ if (xKey.is())
+ {
+ xKey->setAsciiValue(implementationLoaderUrl);
+ }
+
+ // update DATA entry
+ //xKey = xImplKey->createKey("/DATA");
+
+ xKey = xImplKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/REGISTRY_LINKS") ) );
+
+ if (xKey.is() && (xKey->getValueType() == RegistryValueType_ASCIILIST))
+ {
+ // update link entries in REGISTRY_LINKS section
+ Sequence<OUString> linkNames = xKey->getAsciiListValue();
+
+ if (linkNames.getLength())
+ {
+ const OUString* pLinkNames = linkNames.getConstArray();
+
+ for (sal_Int32 i = 0; i < linkNames.getLength(); i++)
+ {
+ prepareLink(xDest, xImplKey, pLinkNames[i]);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ return ret;
+}
+
+
+static void findImplementations( const Reference < XRegistryKey > & xSource,
+ std::list <OUString>& implNames)
+{
+ sal_Bool isImplKey = sal_False;
+
+ try
+ {
+ Reference < XRegistryKey > xKey = xSource->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") ) );
+
+ if (xKey.is() && (xKey->getKeyNames().getLength() > 0))
+ {
+ isImplKey = sal_True;
+
+ OUString implName = OUString(xSource->getKeyName().getStr() + 1).replace(L'/', L'.').getStr();
+ sal_Int32 firstDot = implName.search(L'.');
+
+ if (firstDot >= 0)
+ implName = implName.copy(firstDot + 1);
+
+ implNames.push_back(implName);
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ if (isImplKey) return;
+
+ try
+ {
+ Sequence< Reference < XRegistryKey > > subKeys = xSource->openKeys();
+
+ if (subKeys.getLength() > 0)
+ {
+ const Reference < XRegistryKey >* pSubKeys = subKeys.getConstArray();
+
+ for (sal_Int32 i = 0; i < subKeys.getLength(); i++)
+ {
+ findImplementations(pSubKeys[i], implNames);
+ }
+
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+}
+
+
+
+
+
+
+
+
+//*************************************************************************
+// class ImplementationRegistration the implenetation of interface
+// XImplementationRegistration
+//
+class ImplementationRegistration
+ : public WeakImplHelper3< XImplementationRegistration, XServiceInfo, XInitialization >
+{
+public:
+ ImplementationRegistration( const Reference < XMultiServiceFactory > & rSMgr );
+ ~ImplementationRegistration();
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName() throw();
+ sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw();
+ Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw();
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static(void) throw();
+
+ // Methoden von XImplementationRegistration
+ virtual void SAL_CALL registerImplementation(
+ const OUString& implementationLoader,
+ const OUString& location,
+ const Reference < XSimpleRegistry > & xReg)
+ throw( CannotRegisterImplementationException, RuntimeException );
+
+ virtual sal_Bool SAL_CALL revokeImplementation(
+ const OUString& location,
+ const Reference < XSimpleRegistry >& xReg)
+ throw( RuntimeException );
+
+ virtual Sequence< OUString > SAL_CALL getImplementations(
+ const OUString& implementationLoader,
+ const OUString& location)
+ throw( RuntimeException );
+ virtual Sequence< OUString > SAL_CALL checkInstantiation(
+ const OUString& implementationName)
+ throw( RuntimeException );
+
+public: // XInitialization
+ virtual void SAL_CALL initialize(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+private: // helper methods
+
+ static sal_Bool doRegistration( const Reference < XMultiServiceFactory >& xSMgr,
+ const Reference < XImplementationLoader >& xAct,
+ const Reference < XSimpleRegistry >& xDest,
+ const OUString& implementationLoaderUrl,
+ const OUString& locationUrl,
+ sal_Bool bRegister);
+
+ Reference< XSimpleRegistry > getRegistryFromServiceManager();
+
+ static Reference< XSimpleRegistry > createTemporarySimpleRegistry( const Reference < XMultiServiceFactory > & r );
+
+private: // members
+ Reference < XMultiServiceFactory > m_xSMgr;
+};
+
+//*************************************************************************
+// ImplementationRegistration()
+//
+ImplementationRegistration::ImplementationRegistration( const Reference < XMultiServiceFactory > & rSMgr )
+ : m_xSMgr( rSMgr )
+{
+}
+
+//*************************************************************************
+// ~ImplementationRegistration()
+//
+ImplementationRegistration::~ImplementationRegistration()
+{
+}
+
+
+// XServiceInfo
+OUString ImplementationRegistration::getImplementationName() throw()
+{
+ return OUString::createFromAscii( IMPLEMENTATION_NAME );
+}
+
+// XServiceInfo
+sal_Bool ImplementationRegistration::supportsService(const OUString& ServiceName) throw()
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+// XServiceInfo
+Sequence< OUString > ImplementationRegistration::getSupportedServiceNames(void) throw()
+{
+ return getSupportedServiceNames_Static();
+}
+
+// ORegistryServiceManager_Static
+Sequence< OUString > ImplementationRegistration::getSupportedServiceNames_Static(void) throw ()
+{
+ OUString aServiceName( OUString::createFromAscii( SERVICE_NAME ) );
+ Sequence< OUString > aSNS( &aServiceName, 1 );
+ return aSNS;
+}
+
+
+Reference< XSimpleRegistry > ImplementationRegistration::getRegistryFromServiceManager()
+{
+ Reference < XPropertySet > xPropSet =
+ Reference< XPropertySet >::query (m_xSMgr );
+ Reference < XSimpleRegistry > xRegistry;
+
+ if( xPropSet.is() ) {
+
+ try { // the implementation does not support XIntrospectionAccess !
+
+ Any aAny = xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Registry") ) );
+
+ if( aAny.getValueType().getTypeClass() == TypeClass_INTERFACE ) {
+ aAny >>= xRegistry;
+ }
+ }
+ catch( UnknownPropertyException e ) {
+ // empty reference is error signal !
+ }
+ }
+
+ return xRegistry;
+}
+
+
+//************************************************************************
+// XInitialization
+//
+void ImplementationRegistration::initialize(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArgs )
+ throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+
+ if( aArgs.getLength() != 4 ) {
+ throw IllegalArgumentException();
+ }
+
+ Reference< XImplementationLoader > rLoader;
+ OUString loaderServiceName;
+ OUString locationUrl;
+ Reference< XSimpleRegistry > rReg;
+
+ // 1st argument : An instance of an implementation loader
+ if( aArgs.getConstArray()[0].getValueType().getTypeClass() == TypeClass_INTERFACE ) {
+ aArgs.getConstArray()[0] >>= rLoader;
+ }
+ if( !rLoader.is()) {
+ throw IllegalArgumentException();
+ }
+
+ // 2nd argument : The service name of the loader. This name is written into the registry
+ if( aArgs.getConstArray()[1].getValueType().getTypeClass() == TypeClass_STRING ) {
+ aArgs.getConstArray()[1] >>= loaderServiceName;
+ }
+ if( ! loaderServiceName.getLength() ) {
+ throw IllegalArgumentException();
+ }
+
+ // 3rd argument : The file name of the dll, that contains the loader
+ if( aArgs.getConstArray()[2].getValueType().getTypeClass() == TypeClass_STRING ) {
+ aArgs.getConstArray()[2] >>= locationUrl;
+ }
+ if( ! locationUrl.getLength() ) {
+ throw IllegalArgumentException();
+ }
+
+ // 4th argument : The registry, the service should be written to
+ if( aArgs.getConstArray()[3].getValueType().getTypeClass() == TypeClass_INTERFACE ) {
+ aArgs.getConstArray()[3] >>= rReg;
+ }
+
+ if( !rReg.is() ) {
+ rReg = getRegistryFromServiceManager();
+ if( !rReg.is() ) {
+ throw IllegalArgumentException();
+ }
+ }
+
+
+ // TODO : SimpleRegistry in doRegistration von hand anziehen !
+ if (!doRegistration(m_xSMgr, rLoader , rReg, loaderServiceName , locationUrl, sal_True)) {
+ throw Exception();
+ }
+
+ // ------------------------------------------------------------
+}
+
+
+
+//*************************************************************************
+// virtual function registerImplementation of XImplementationRegistration
+//
+void ImplementationRegistration::registerImplementation(
+ const OUString& implementationLoaderUrl,
+ const OUString& locationUrl,
+ const Reference < XSimpleRegistry > & xReg)
+ throw( CannotRegisterImplementationException, RuntimeException )
+{
+ OUString implLoaderUrl(implementationLoaderUrl);
+ OUString activatorName;
+
+ if (implementationLoaderUrl.len() > 0)
+ {
+ OUString tmpActivator(implementationLoaderUrl.getStr());
+ activatorName = tmpActivator.getToken(0, L':').getStr();
+ } else
+ {
+ // check locationUrl to find out what kind of loader is needed
+ // set iimplLoaderUrl
+ }
+
+ if( m_xSMgr.is() ) {
+ Reference < XImplementationLoader > xAct( m_xSMgr->createInstance(activatorName) , UNO_QUERY );
+ if (xAct.is())
+ {
+ Reference < XSimpleRegistry > xRegistry;
+
+ if (xReg.is())
+ {
+ // registry supplied by user
+ xRegistry = xReg;
+ }
+ else
+ {
+ xRegistry = getRegistryFromServiceManager();
+ }
+
+ if ( xRegistry.is())
+ {
+ if (!doRegistration(m_xSMgr, xAct, xRegistry, implLoaderUrl, locationUrl, sal_True))
+ throw CannotRegisterImplementationException();
+
+ return;
+ }
+ }
+ }
+
+ throw CannotRegisterImplementationException();
+}
+
+//*************************************************************************
+// virtual function revokeImplementation of XImplementationRegistration
+//
+sal_Bool ImplementationRegistration::revokeImplementation(const OUString& location,
+ const Reference < XSimpleRegistry >& xReg)
+ throw ( RuntimeException )
+{
+ sal_Bool ret = sal_False;
+
+ Reference < XSimpleRegistry > xRegistry;
+
+ if (xReg.is()) {
+ xRegistry = xReg;
+ }
+ else {
+ Reference < XPropertySet > xPropSet = Reference< XPropertySet >::query( m_xSMgr );
+ if( xPropSet.is() ) {
+ try {
+ Any aAny = xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Registry") ) );
+
+ if( aAny.getValueType().getTypeClass() == TypeClass_INTERFACE )
+ {
+ aAny >>= xRegistry;
+ }
+ }
+ catch ( UnknownPropertyException e ) {
+ }
+ }
+ }
+
+ if (xRegistry.is())
+ {
+ ret = doRegistration(m_xSMgr, Reference< XImplementationLoader > (), xRegistry, OUString(), location, sal_False);
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// virtual function getImplementations of XImplementationRegistration
+//
+Sequence< OUString > ImplementationRegistration::getImplementations(
+ const OUString & implementationLoaderUrl,
+ const OUString & locationUrl)
+ throw ( RuntimeException )
+{
+ OUString implLoaderUrl(implementationLoaderUrl);
+ OUString activatorName;
+
+ if (implementationLoaderUrl.len() > 0)
+ {
+ OUString tmpActivator(implementationLoaderUrl.getStr());
+ activatorName = tmpActivator.getToken(0, L':').getStr();
+ } else
+ {
+ // check locationUrl to find out what kind of loader is needed
+ // set implLoaderUrl
+ }
+
+ if( m_xSMgr.is() ) {
+
+ Reference < XImplementationLoader > xAct( m_xSMgr->createInstance( activatorName ), UNO_QUERY );
+
+ if (xAct.is())
+ {
+
+ Reference < XSimpleRegistry > xReg = createTemporarySimpleRegistry( m_xSMgr);
+
+ if (xReg.is())
+ {
+ try
+ {
+ OUString aTempName = getTempName();
+
+ xReg->open(aTempName, sal_False, sal_True);
+ Reference < XRegistryKey > xImpl;
+
+ { // only necessary for deleting the temporary variable of rootkey
+ xImpl = xReg->getRootKey()->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/IMPLEMENTATIONS") ) );
+ }
+ if (xAct->writeRegistryInfo(xImpl, implementationLoaderUrl, locationUrl))
+ {
+ std::list <OUString> implNames;
+
+ findImplementations(xImpl, implNames);
+
+ if (!implNames.empty())
+ {
+ std::list<OUString>::const_iterator iter = implNames.begin();
+
+ Sequence<OUString> seqImpl(implNames.size());
+ OUString *pImplNames = seqImpl.getArray();
+
+ sal_Int32 index = 0;
+ while (iter != implNames.end())
+ {
+ pImplNames[index] = *iter;
+ index++;
+ ++iter;
+ }
+
+ xImpl->closeKey();
+ xReg->destroy();
+ return seqImpl;
+ }
+ }
+
+ xImpl->closeKey();
+ xReg->destroy();
+ }
+ catch(MergeConflictException&)
+ {
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+ }
+ }
+ }
+
+ return Sequence<OUString>();
+}
+
+//*************************************************************************
+// virtual function checkInstantiation of XImplementationRegistration
+//
+Sequence< OUString > ImplementationRegistration::checkInstantiation(const OUString& implementationName)
+ throw ( RuntimeException )
+{
+ VOS_ENSHURE( sal_False, "ImplementationRegistration::checkInstantiation not implemented" );
+ return Sequence<OUString>();
+}
+
+//*************************************************************************
+// helper function doRegistration
+//
+sal_Bool ImplementationRegistration::doRegistration(
+ const Reference< XMultiServiceFactory > & xSMgr,
+ const Reference < XImplementationLoader > & xAct,
+ const Reference < XSimpleRegistry >& xDest,
+ const OUString& implementationLoaderUrl,
+ const OUString& locationUrl,
+ sal_Bool bRegister)
+{
+ sal_Bool ret = sal_False;
+
+ if (!bRegister)
+ {
+ // deregister
+ try
+ {
+ if( xDest.is() )
+ {
+ std::list<OUString> aNames;
+
+ Reference < XRegistryKey > xRootKey( xDest->getRootKey() );
+
+ Reference < XRegistryKey > xKey = xRootKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/IMPLEMENTATIONS") ) );
+ if (xKey.is())
+ {
+ deleteAllImplementations(xDest, xKey, locationUrl, aNames);
+ ret = sal_True;
+ }
+
+
+ xKey = xRootKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/SERVICES") ) );
+ if (xKey.is())
+ {
+ std::list<OUString>::const_iterator iter = aNames.begin();
+
+ while (iter != aNames.end())
+ {
+ deleteAllServiceEntries(xDest, xKey, *iter);
+ ++iter;
+ }
+ }
+
+ if (xRootKey.is())
+ xRootKey->closeKey();
+ if (xKey.is())
+ xKey->closeKey();
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+ } else
+ {
+ Reference < XSimpleRegistry > xReg = createTemporarySimpleRegistry( xSMgr );
+ Reference < XRegistryKey > xSourceKey;
+
+ if (xAct.is() && xReg.is() && xDest.is())
+ {
+ OUString aTempName = getTempName();
+ try
+ {
+ xReg->open(aTempName, sal_False, sal_True);
+
+ { // only necessary for deleting the temporary variable of rootkey
+ xSourceKey = xReg->getRootKey()->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/IMPLEMENTATIONS") ) );
+ }
+
+ if (xAct->writeRegistryInfo(xSourceKey, implementationLoaderUrl, locationUrl))
+ {
+ if (prepareRegistry(xDest, xSourceKey, implementationLoaderUrl, locationUrl))
+ {
+ // Release Source key and registry.
+ xSourceKey->closeKey();
+ xReg->close();
+
+ xDest->mergeKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/") ), aTempName );
+
+ ret = sal_True;
+ }
+ }
+
+ // Cleanup Source registry.
+ if ( xSourceKey->isValid() )
+ xSourceKey->closeKey();
+ if ( xReg->isValid() )
+ xReg->destroy();
+ else
+ {
+ xReg->open( aTempName, sal_False, sal_True );
+ xReg->destroy();
+ }
+ }
+ catch(MergeConflictException&)
+ {
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+ catch(CannotRegisterImplementationException&)
+ {
+ // destroy temp registry
+ if ( xSourceKey->isValid() )
+ xSourceKey->closeKey();
+ if ( xReg->isValid() )
+ xReg->destroy();
+ else
+ {
+ xReg->open( aTempName, sal_False, sal_True );
+ xReg->destroy();
+ }
+ // and throw again
+ throw;
+ }
+ }
+ }
+
+ return ret;
+}
+
+
+
+Reference< XSimpleRegistry > ImplementationRegistration::createTemporarySimpleRegistry(
+ const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+{
+
+ Reference < XSimpleRegistry > xReg = Reference< XSimpleRegistry >::query(
+ rSMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.SimpleRegistry") ) ) );
+ OSL_ASSERT( xReg.is() );
+// if( ! xReg.is() ) {
+// // use as fallback ( bootstrap )
+
+// Reference< XInterface > r = ::cppu::__loadLibComponentFactory(
+// "simreg",
+// "com.sun.star.comp.stoc.SimpleRegistry",
+// rSMgr ,
+// Reference < XRegistryKey >() )->createInstance();
+
+// xReg = Reference< XSimpleRegistry > ( r , UNO_QUERY );
+// }
+
+ return xReg;
+}
+
+
+
+//*************************************************************************
+static Reference<XInterface> SAL_CALL ImplementationRegistration_CreateInstance( const Reference<XMultiServiceFactory> & rSMgr ) throw(Exception)
+{
+ return (XImplementationRegistration *)new ImplementationRegistration(rSMgr);
+}
+
+}
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
+
+ const Sequence< OUString > & rSNL =
+ ::stoc_impreg::ImplementationRegistration::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ ::stoc_impreg::ImplementationRegistration_CreateInstance,
+ ::stoc_impreg::ImplementationRegistration::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
diff --git a/stoc/source/implementationregistration/makefile.mk b/stoc/source/implementationregistration/makefile.mk
new file mode 100644
index 000000000000..1df1a699dfe3
--- /dev/null
+++ b/stoc/source/implementationregistration/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= impreg
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+BOOTSTRAP_SERVICE=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/implreg.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/stoc/source/inspect/insp.xml b/stoc/source/inspect/insp.xml
new file mode 100644
index 000000000000..2f7bc5b8cc60
--- /dev/null
+++ b/stoc/source/inspect/insp.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Juergen Schmidt </Author>
+
+<Name> com.sun.star.comp.stoc.Introspection </Name>
+
+<Description>
+ This component implements XIntrospection. The method XIntrospection::inspect(any object)
+ returns an XIntrospectionAccess that provides information about the methods, properties
+ and listeners supported by the inspected object. Matching pairs of getName/setName()
+ methods will also be offered as property "Name".
+</Description>
+
+<ModuleName> insp </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> com.sun.star.beans.Introspection </SupportedService>
+
+<ServiceDependency> com.sun.star.reflection.CoreReflection </ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> vos </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu1 </RuntimeModuleDependency>
+<RuntimeModuleDependency> vos1$(COM) </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal1 </RuntimeModuleDependency>
+
+<Type> com.sun.star.beans.XIntrospection </Type>
+<Type> com.sun.star.beans.XIntrospectionAccess </Type>
+<Type> com.sun.star.beans.XPropertySet </Type>
+<Type> com.sun.star.beans.XFastPropertySet </Type>
+<Type> com.sun.star.beans.XMaterialHolder </Type>
+<Type> com.sun.star.beans.XExactName </Type>
+<Type> com.sun.star.beans.PropertyAttribute </Type>
+<Type> com.sun.star.beans.PropertyConcept </Type>
+<Type> com.sun.star.beans.MethodConcept </Type>
+<Type> com.sun.star.lang.XEventListener </Type>
+<Type> com.sun.star.lang.XInitialization </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.container.XEnumerationAccess </Type>
+<Type> com.sun.star.container.XNameContainer </Type>
+<Type> com.sun.star.container.XIndexContainer </Type>
+<Type> com.sun.star.reflection.XIdlReflection </Type>
+<Type> com.sun.star.reflection.XIdlClassProvider </Type>
+<Type> com.sun.star.reflection.XIdlClass </Type>
+<Type> com.sun.star.reflection.XIdlArray </Type>
+<Type> com.sun.star.reflection.FieldAccessMode </Type>
+
+</COMPONENTDESCRIPTION>
diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx
new file mode 100644
index 000000000000..2a838d534e22
--- /dev/null
+++ b/stoc/source/inspect/introspection.cxx
@@ -0,0 +1,3023 @@
+/*************************************************************************
+ *
+ * $RCSfile: introspection.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+// Schalter fuer Introspection-Caching
+#ifndef OS2
+#define USE_INTROSPECTION_CACHE
+#endif
+
+#ifdef USE_INTROSPECTION_CACHE
+#define INTROSPECTION_CACHE_MAX_SIZE 100
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _VOS_MODULE_HXX_
+#include <vos/module.hxx>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/typeprovider.hxx>
+
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+#include <com/sun/star/reflection/XIdlClassProvider.hpp>
+#include <com/sun/star/reflection/XIdlClass.hpp>
+#include <com/sun/star/beans/UnknownPropertyException.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
+#include <com/sun/star/beans/XMaterialHolder.hpp>
+#include <com/sun/star/beans/XExactName.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertyConcept.hpp>
+#include <com/sun/star/beans/MethodConcept.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+#include <rtl/ustrbuf.hxx>
+#include <rtl/strbuf.hxx>
+#include <stl/hash_map>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::container;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::beans::PropertyAttribute;
+using namespace com::sun::star::beans::PropertyConcept;
+using namespace com::sun::star::beans::MethodConcept;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+#define IMPLEMENTATION_NAME "com.sun.star.comp.stoc.Introspection"
+#define SERVICE_NAME "com.sun.star.beans.Introspection"
+
+namespace stoc_inspect
+{
+
+typedef WeakImplHelper3< XIntrospectionAccess, XMaterialHolder, XExactName > IntrospectionAccessHelper;
+
+
+//==================================================================================================
+
+// Spezial-Wert fuer Method-Concept, um "normale" Funktionen kennzeichnen zu koennen
+#define MethodConcept_NORMAL_IMPL 0x80000000
+
+
+// Methode zur Feststellung, ob eine Klasse von einer anderen abgeleitet ist
+sal_Bool isDerivedFrom( Reference<XIdlClass> xToTestClass, Reference<XIdlClass> xDerivedFromClass )
+{
+ Sequence< Reference<XIdlClass> > aClassesSeq = xToTestClass->getSuperclasses();
+ const Reference<XIdlClass>* pClassesArray = aClassesSeq.getConstArray();
+ sal_Int32 nSuperClassCount = aClassesSeq.getLength();
+ sal_Int32 i;
+ for( i = 0 ; i < nSuperClassCount ; i++ )
+ {
+ const Reference<XIdlClass>& rxClass = pClassesArray[i];
+ if( xDerivedFromClass->equals( rxClass ) )
+ {
+ // Treffer
+ return sal_True;
+ }
+ else
+ {
+ // Rekursiv weitersuchen
+ return isDerivedFrom( rxClass, xDerivedFromClass );
+ }
+ }
+ return sal_False;
+}
+
+//========================================================================
+
+// *** Klassifizierung der Properties (kein enum, um Sequence verwenden zu koennen) ***
+// Properties aus einem PropertySet-Interface
+#define MAP_PROPERTY_SET 0
+// Properties aus Fields
+#define MAP_FIELD 1
+// Properties, die durch get/set-Methoden beschrieben werden
+#define MAP_GETSET 2
+// Properties, die nur eine set-Methode haben
+#define MAP_SETONLY 3
+
+
+// Schrittweite, in der die Groesse der Sequences angepasst wird
+#define ARRAY_SIZE_STEP 20
+
+
+
+//**************************************
+//*** IntrospectionAccessStatic_Impl ***
+//**************************************
+// Entspricht dem alten IntrospectionAccessImpl, bildet jetzt den statischen
+// Anteil des neuen Instanz-bezogenen ImplIntrospectionAccess
+
+// ACHTUNG !!! Von Hand refcounten !!!
+
+
+// Hashtable fuer die Suche nach Namen
+struct hashName_Impl
+{
+ size_t operator()(const OUString Str) const
+ {
+ return (size_t)Str.hashCode();
+ }
+};
+
+struct eqName_Impl
+{
+ sal_Bool operator()(const OUString Str1, const OUString Str2) const
+ {
+ return ( Str1 == Str2 );
+ }
+};
+
+typedef NAMESPACE_STD(hash_map)
+<
+ OUString,
+ sal_Int32,
+ hashName_Impl,
+ eqName_Impl
+>
+IntrospectionNameMap;
+
+
+// Hashtable zur Zuordnung der exakten Namen zu den zu Lower-Case
+// konvertierten Namen, dient zur Unterstützung von XExactName
+typedef NAMESPACE_STD(hash_map)
+<
+ OUString,
+ OUString,
+ hashName_Impl,
+ eqName_Impl
+>
+LowerToExactNameMap;
+
+
+class IntrospectionAccessStatic_Impl
+{
+ friend class ImplIntrospection;
+ friend class ImplIntrospectionAccess;
+
+ // CoreReflection halten
+ Reference< XIdlReflection > mxCoreReflection;
+
+ // InterfaceSequences, um Zusatz-Infos zu einer Property speichern zu koennen.
+ // z.B. das Field bei MAP_FIELD, die get/set-Methoden bei MAP_GETSET usw.
+ Sequence< Reference<XInterface> > aInterfaceSeq1;
+ Sequence< Reference<XInterface> > aInterfaceSeq2;
+
+ // Hashtables fuer die Namen
+ IntrospectionNameMap maPropertyNameMap;
+ IntrospectionNameMap maMethodNameMap;
+ LowerToExactNameMap maLowerToExactNameMap;
+
+ // Sequence aller Properties, auch zum Liefern aus getProperties()
+ Sequence<Property> maAllPropertySeq;
+
+ // Mapping der Properties auf Zugriffs-Arten
+ Sequence<sal_Int16> maMapTypeSeq;
+
+ // Klassifizierung der gefundenen Methoden
+ Sequence<sal_Int32> maPropertyConceptSeq;
+
+ // Anzahl der Properties
+ sal_Int32 mnPropCount;
+
+ // Anzahl der Properties, die den jeweiligen Konzepten zugeordnet sind
+ //sal_Int32 mnDangerousPropCount;
+ sal_Int32 mnPropertySetPropCount;
+ sal_Int32 mnAttributePropCount;
+ sal_Int32 mnMethodPropCount;
+
+ // Flag, ob ein FastPropertySet unterstuetzt wird
+ sal_Bool mbFastPropSet;
+
+ // Original-Handles eines FastPropertySets
+ sal_Int32* mpOrgPropertyHandleArray;
+
+ // MethodSequence, die alle Methoden aufnimmt
+ Sequence< Reference<XIdlMethod> > maAllMethodSeq;
+
+ // Klassifizierung der gefundenen Methoden
+ Sequence<sal_Int32> maMethodConceptSeq;
+
+ // Anzahl der Methoden
+ sal_Int32 mnMethCount;
+
+ // Sequence der Listener, die angemeldet werden koennen
+ Sequence< Type > maSupportedListenerSeq;
+
+ // BaseInit (soll spaeter in der Applikation erfolgen!)
+ void BaseInit( void );
+
+ // Hilfs-Methoden zur Groessen-Anpassung der Sequences
+ void checkPropertyArraysSize
+ (
+ Property*& rpAllPropArray,
+ sal_Int16*& rpMapTypeArray,
+ sal_Int32*& rpPropertyConceptArray,
+ sal_Int32 iNextIndex
+ );
+ void checkInterfaceArraySize( Sequence< Reference<XInterface> >& rSeq, Reference<XInterface>*& rpInterfaceArray,
+ sal_Int32 iNextIndex );
+
+ // RefCount
+ sal_Int32 nRefCount;
+
+
+public:
+ IntrospectionAccessStatic_Impl( Reference< XIdlReflection > xCoreReflection_ );
+ ~IntrospectionAccessStatic_Impl()
+ {
+ delete mpOrgPropertyHandleArray;
+ }
+ sal_Int32 getPropertyIndex( const OUString& aPropertyName ) const;
+ sal_Int32 getMethodIndex( const OUString& aMethodName ) const;
+
+ void acquire() { nRefCount++; }
+ void release()
+ {
+ nRefCount--;
+ if( nRefCount <= 0 )
+ delete this;
+ }
+
+ // Methoden von XIntrospectionAccess (ALT, jetzt nur Impl)
+ void setPropertyValue(const Any& obj, const OUString& aPropertyName, const Any& aValue) const;
+ Any getPropertyValue(const Any& obj, const OUString& aPropertyName) const;
+ void setPropertyValueByIndex(const Any& obj, sal_Int32 nIndex, const Any& aValue) const;
+ Any getPropertyValueByIndex(const Any& obj, sal_Int32 nIndex) const;
+
+ Sequence<Property> getProperties(void) const { return maAllPropertySeq; }
+ Sequence< Reference<XIdlMethod> > getMethods(void) const { return maAllMethodSeq; }
+ Sequence< Type > getSupportedListeners(void) const { return maSupportedListenerSeq; }
+ Sequence<sal_Int32> getPropertyConcepts(void) const { return maPropertyConceptSeq; }
+ Sequence<sal_Int32> getMethodConcepts(void) const { return maMethodConceptSeq; }
+};
+
+
+// Ctor
+IntrospectionAccessStatic_Impl::IntrospectionAccessStatic_Impl( Reference< XIdlReflection > xCoreReflection_ )
+ : mxCoreReflection( xCoreReflection_ )
+{
+ aInterfaceSeq1.realloc( ARRAY_SIZE_STEP );
+ aInterfaceSeq2.realloc( ARRAY_SIZE_STEP );
+
+ // Property-Daten
+ maAllPropertySeq.realloc( ARRAY_SIZE_STEP );
+ maMapTypeSeq.realloc( ARRAY_SIZE_STEP );
+ maPropertyConceptSeq.realloc( ARRAY_SIZE_STEP );
+
+ mbFastPropSet = sal_False;
+ mpOrgPropertyHandleArray = NULL;
+
+ mnPropCount = 0L;
+ //mnDangerousPropCount = 0L;
+ mnPropertySetPropCount = 0L;
+ mnAttributePropCount = 0L;
+ mnMethodPropCount = 0L;
+
+ // Method-Daten
+ mnMethCount = 0L;
+
+ // Eigenens RefCounting
+ nRefCount = 0L;
+}
+
+// Von Hand refcounten !!!
+
+
+sal_Int32 IntrospectionAccessStatic_Impl::getPropertyIndex( const OUString& aPropertyName ) const
+{
+ sal_Int32 iHashResult = -1;
+ IntrospectionAccessStatic_Impl* pThis = (IntrospectionAccessStatic_Impl*)this;
+ IntrospectionNameMap::iterator aIt = pThis->maPropertyNameMap.find( aPropertyName );
+ if( !( aIt == pThis->maPropertyNameMap.end() ) )
+ iHashResult = (*aIt).second;
+ return iHashResult;
+}
+
+sal_Int32 IntrospectionAccessStatic_Impl::getMethodIndex( const OUString& aMethodName ) const
+{
+ sal_Int32 iHashResult = -1;
+ IntrospectionAccessStatic_Impl* pThis = (IntrospectionAccessStatic_Impl*)this;
+ IntrospectionNameMap::iterator aIt = pThis->maMethodNameMap.find( aMethodName );
+ if( !( aIt == pThis->maMethodNameMap.end() ) )
+ iHashResult = (*aIt).second;
+ return iHashResult;
+}
+
+void IntrospectionAccessStatic_Impl::setPropertyValue( const Any& obj, const OUString& aPropertyName, const Any& aValue ) const
+{
+ sal_Int32 i = getPropertyIndex( aPropertyName );
+ if( i != -1 )
+ setPropertyValueByIndex( obj, (sal_Int32)i, aValue );
+ else
+ throw UnknownPropertyException();
+}
+
+void IntrospectionAccessStatic_Impl::setPropertyValueByIndex(const Any& obj, sal_Int32 nSequenceIndex, const Any& aValue) const
+{
+ // Handelt es sich bei dem uebergebenen Objekt ueberhaupt um was passendes?
+ TypeClass eObjType = obj.getValueType().getTypeClass();
+
+ Reference<XInterface> xInterface;
+ if( eObjType == TypeClass_INTERFACE )
+ {
+ xInterface = *( Reference<XInterface>*)obj.getValue();
+ }
+ else if( nSequenceIndex >= mnPropCount || ( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) )
+ {
+ throw IllegalArgumentException();
+ return;
+ }
+
+ // Flags pruefen
+ const Property* pProps = maAllPropertySeq.getConstArray();
+ if( (pProps[ nSequenceIndex ].Attributes & READONLY) != 0 )
+ {
+ throw UnknownPropertyException();
+ return;
+ }
+
+ const sal_Int16* pMapTypeArray = maMapTypeSeq.getConstArray();
+ switch( pMapTypeArray[ nSequenceIndex ] )
+ {
+ case MAP_PROPERTY_SET:
+ {
+ // Property besorgen
+ const Property& rProp = maAllPropertySeq.getConstArray()[ nSequenceIndex ];
+
+ // Interface-Parameter auf den richtigen Typ bringen
+ sal_Bool bUseCopy = sal_False;
+ Any aRealValue;
+
+ TypeClass eValType = aValue.getValueType().getTypeClass();
+ if( eValType == TypeClass_INTERFACE )
+ {
+ Type aPropType = rProp.Type;
+ OUString aTypeName( aPropType.getTypeName() );
+ Reference< XIdlClass > xPropClass = mxCoreReflection->forName( aTypeName );
+ //Reference<XIdlClass> xPropClass = rProp.Type;
+ if( xPropClass.is() && xPropClass->getTypeClass() == TypeClass_INTERFACE )
+ {
+ Reference<XInterface> valInterface = *(Reference<XInterface>*)aValue.getValue();
+ if( valInterface.is() )
+ {
+ //Any queryInterface( const Type& rType );
+ aRealValue = valInterface->queryInterface( aPropType );
+ if( aRealValue.hasValue() )
+ bUseCopy = sal_True;
+ }
+ }
+ }
+
+ // Haben wir ein FastPropertySet und ein gueltiges Handle?
+ // ACHTUNG: An dieser Stelle wird ausgenutzt, dass das PropertySet
+ // zu Beginn des Introspection-Vorgangs abgefragt wird.
+ sal_Int32 nOrgHandle;
+ if( mbFastPropSet && ( nOrgHandle = mpOrgPropertyHandleArray[ nSequenceIndex ] ) != -1 )
+ {
+ // PropertySet-Interface holen
+ Reference<XFastPropertySet> xFastPropSet =
+ Reference<XFastPropertySet>::query( xInterface );
+ if( xFastPropSet.is() )
+ {
+ xFastPropSet->setFastPropertyValue( nOrgHandle, bUseCopy ? aRealValue : aValue );
+ }
+ else
+ {
+ // throw UnknownPropertyException
+ }
+ }
+ // sonst eben das normale nehmen
+ else
+ {
+ // PropertySet-Interface holen
+ Reference<XPropertySet> xPropSet =
+ Reference<XPropertySet>::query( xInterface );
+ if( xPropSet.is() )
+ {
+ xPropSet->setPropertyValue( rProp.Name, bUseCopy ? aRealValue : aValue );
+ }
+ else
+ {
+ // throw UnknownPropertyException
+ }
+ }
+ }
+ break;
+
+ case MAP_FIELD:
+ {
+ Reference<XIdlField> xField = (XIdlField*)(aInterfaceSeq1.getConstArray()[ nSequenceIndex ].get());
+ if( xField.is() )
+ {
+ xField->set( obj, aValue );
+ // IllegalArgumentException
+ // NullPointerException
+ }
+ else
+ {
+ // throw IllegalArgumentException();
+ }
+ }
+ break;
+
+ case MAP_GETSET:
+ case MAP_SETONLY:
+ {
+ // set-Methode holen
+ Reference<XIdlMethod> xMethod = (XIdlMethod*)(aInterfaceSeq2.getConstArray()[ nSequenceIndex ].get());
+ if( xMethod.is() )
+ {
+ Sequence<Any> args( 1 );
+ args.getArray()[0] = aValue;
+ xMethod->invoke( obj, args );
+ }
+ else
+ {
+ // throw IllegalArgumentException();
+ }
+ }
+ break;
+ }
+}
+
+Any IntrospectionAccessStatic_Impl::getPropertyValue( const Any& obj, const OUString& aPropertyName ) const
+{
+ sal_Int32 i = getPropertyIndex( aPropertyName );
+ if( i != -1 )
+ return getPropertyValueByIndex( obj, i );
+
+ throw UnknownPropertyException();
+ return Any();
+}
+
+Any IntrospectionAccessStatic_Impl::getPropertyValueByIndex(const Any& obj, sal_Int32 nSequenceIndex) const
+{
+ Any aRet;
+
+ // Handelt es sich bei dem uebergebenen Objekt ueberhaupt um was passendes?
+ TypeClass eObjType = obj.getValueType().getTypeClass();
+
+ Reference<XInterface> xInterface;
+ if( eObjType == TypeClass_INTERFACE )
+ {
+ xInterface = *(Reference<XInterface>*)obj.getValue();
+ }
+ else if( nSequenceIndex >= mnPropCount || ( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) )
+ {
+ // throw IllegalArgumentException();
+ return aRet;
+ }
+
+ const sal_Int16* pMapTypeArray = maMapTypeSeq.getConstArray();
+ switch( pMapTypeArray[ nSequenceIndex ] )
+ {
+ case MAP_PROPERTY_SET:
+ {
+ // Property besorgen
+ const Property& rProp = maAllPropertySeq.getConstArray()[ nSequenceIndex ];
+
+ // Haben wir ein FastPropertySet und ein gueltiges Handle?
+ // ACHTUNG: An dieser Stelle wird ausgenutzt, dass das PropertySet
+ // zu Beginn des Introspection-Vorgangs abgefragt wird.
+ sal_Int32 nOrgHandle;
+ if( mbFastPropSet && ( nOrgHandle = mpOrgPropertyHandleArray[ nSequenceIndex ] ) != -1 )
+ {
+ // PropertySet-Interface holen
+ Reference<XFastPropertySet> xFastPropSet =
+ Reference<XFastPropertySet>::query( xInterface );
+ if( xFastPropSet.is() )
+ {
+ aRet = xFastPropSet->getFastPropertyValue( nOrgHandle);
+ }
+ else
+ {
+ // throw UnknownPropertyException
+ return aRet;
+ }
+ }
+ // sonst eben das normale nehmen
+ else
+ {
+ // PropertySet-Interface holen
+ Reference<XPropertySet> xPropSet =
+ Reference<XPropertySet>::query( xInterface );
+ if( xPropSet.is() )
+ {
+ aRet = xPropSet->getPropertyValue( rProp.Name );
+ }
+ else
+ {
+ // throw UnknownPropertyException
+ return aRet;
+ }
+ }
+ }
+ break;
+
+ case MAP_FIELD:
+ {
+ Reference<XIdlField> xField = (XIdlField*)(aInterfaceSeq1.getConstArray()[ nSequenceIndex ].get());
+ if( xField.is() )
+ {
+ aRet = xField->get( obj );
+ // IllegalArgumentException
+ // NullPointerException
+ }
+ else
+ {
+ // throw IllegalArgumentException();
+ return aRet;
+ }
+ }
+ break;
+
+ case MAP_GETSET:
+ {
+ // get-Methode holen
+ Reference<XIdlMethod> xMethod = (XIdlMethod*)(aInterfaceSeq1.getConstArray()[ nSequenceIndex ].get());
+ if( xMethod.is() )
+ {
+ Sequence<Any> args;
+ aRet = xMethod->invoke( obj, args );
+ }
+ else
+ {
+ // throw IllegalArgumentException();
+ return aRet;
+ }
+ }
+ break;
+
+ case MAP_SETONLY:
+ {
+ // get-Methode gibt es nicht
+ // throw WriteOnlyPropertyException();
+ return aRet;
+ }
+ break;
+ }
+ return aRet;
+}
+
+
+// Hilfs-Methoden zur Groessen-Anpassung der Sequences
+void IntrospectionAccessStatic_Impl::checkPropertyArraysSize
+(
+ Property*& rpAllPropArray,
+ sal_Int16*& rpMapTypeArray,
+ sal_Int32*& rpPropertyConceptArray,
+ sal_Int32 iNextIndex
+)
+{
+ sal_Int32 nLen = maAllPropertySeq.getLength();
+ if( iNextIndex >= nLen )
+ {
+ maAllPropertySeq.realloc( nLen + ARRAY_SIZE_STEP );
+ rpAllPropArray = maAllPropertySeq.getArray();
+
+ maMapTypeSeq.realloc( nLen + ARRAY_SIZE_STEP );
+ rpMapTypeArray = maMapTypeSeq.getArray();
+
+ maPropertyConceptSeq.realloc( nLen + ARRAY_SIZE_STEP );
+ rpPropertyConceptArray = maPropertyConceptSeq.getArray();
+ }
+}
+
+void IntrospectionAccessStatic_Impl::checkInterfaceArraySize( Sequence< Reference<XInterface> >& rSeq,
+ Reference<XInterface>*& rpInterfaceArray, sal_Int32 iNextIndex )
+{
+ sal_Int32 nLen = rSeq.getLength();
+ if( iNextIndex >= nLen )
+ {
+ // Neue Groesse mit ARRAY_SIZE_STEP abgleichen
+ sal_Int32 nMissingSize = iNextIndex - nLen + 1;
+ sal_Int32 nSteps = nMissingSize / ARRAY_SIZE_STEP + 1;
+ sal_Int32 nNewSize = nLen + nSteps * ARRAY_SIZE_STEP;
+
+ rSeq.realloc( nNewSize );
+ rpInterfaceArray = rSeq.getArray();
+ }
+}
+
+
+//*******************************
+//*** ImplIntrospectionAdapter ***
+//*******************************
+
+// Neue Impl-Klasse im Rahmen der Introspection-Umstellung auf Instanz-gebundene
+// Introspection mit Property-Zugriff ueber XPropertySet. Die alte Klasse
+// ImplIntrospectionAccess lebt als IntrospectionAccessStatic_Impl
+class ImplIntrospectionAdapter :
+ public XPropertySet, public XFastPropertySet, public XPropertySetInfo,
+ public XNameContainer, public XIndexContainer,
+ public XEnumerationAccess, public XIdlArray,
+ public OWeakObject
+{
+ // Parent-Objekt
+ ImplIntrospectionAccess* mpAccess;
+
+ // Untersuchtes Objekt
+ const Any& mrInspectedObject;
+
+ // Statische Daten der Introspection
+ IntrospectionAccessStatic_Impl* mpStaticImpl;
+
+ // Objekt als Interface
+ Reference<XInterface> mxIface;
+
+ // Original-Interfaces des Objekts
+ Reference<XElementAccess> mxObjElementAccess;
+ Reference<XNameContainer> mxObjNameContainer;
+ Reference<XNameAccess> mxObjNameAccess;
+ Reference<XIndexAccess> mxObjIndexAccess;
+ Reference<XIndexContainer> mxObjIndexContainer;
+ Reference<XEnumerationAccess> mxObjEnumerationAccess;
+ Reference<XIdlArray> mxObjIdlArray;
+
+public:
+ ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_,
+ const Any& obj, IntrospectionAccessStatic_Impl* pStaticImpl_ );
+ ~ImplIntrospectionAdapter();
+
+ // Methoden von XInterface
+ virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw() { OWeakObject::release(); }
+
+ // Methoden von XPropertySet
+ virtual Reference<XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( RuntimeException );
+ virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, const Any& aValue)
+ throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException );
+ virtual Any SAL_CALL getPropertyValue(const OUString& aPropertyName)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL addPropertyChangeListener(const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL removePropertyChangeListener(const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL addVetoableChangeListener(const OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL removeVetoableChangeListener(const OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+
+ // Methoden von XFastPropertySet
+ virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const Any& aValue)
+ throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException );
+ virtual Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+
+ // Methoden von XPropertySetInfo
+ virtual Sequence< Property > SAL_CALL getProperties(void) throw( RuntimeException );
+ virtual Property SAL_CALL getPropertyByName(const OUString& Name) throw( RuntimeException );
+ virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& Name) throw( RuntimeException );
+
+ // Methoden von XElementAccess
+ virtual Type SAL_CALL getElementType(void) throw( RuntimeException );
+ virtual sal_Bool SAL_CALL hasElements(void) throw( RuntimeException );
+
+ // Methoden von XNameAccess
+ virtual Any SAL_CALL getByName(const OUString& Name)
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException );
+ virtual Sequence<OUString> SAL_CALL getElementNames(void) throw( RuntimeException );
+ virtual sal_Bool SAL_CALL hasByName(const OUString& Name) throw( RuntimeException );
+
+ // Methoden von XNameContainer
+ virtual void SAL_CALL insertByName(const OUString& Name, const Any& Element)
+ throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL replaceByName(const OUString& Name, const Any& Element)
+ throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL removeByName(const OUString& Name)
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException );
+
+ // Methoden von XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount(void) throw( RuntimeException );
+ virtual Any SAL_CALL getByIndex(sal_Int32 Index)
+ throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
+
+ // Methoden von XIndexContainer
+ virtual void SAL_CALL insertByIndex(sal_Int32 Index, const Any& Element)
+ throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const Any& Element)
+ throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL removeByIndex(sal_Int32 Index)
+ throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
+
+ // Methoden von XEnumerationAccess
+ virtual Reference<XEnumeration> SAL_CALL createEnumeration(void) throw( RuntimeException );
+
+ // Methoden von XIdlArray
+ virtual void SAL_CALL realloc(Any& array, sal_Int32 length)
+ throw( IllegalArgumentException, RuntimeException );
+ virtual sal_Int32 SAL_CALL getLen(const Any& array) throw( IllegalArgumentException, RuntimeException );
+ virtual Any SAL_CALL get(const Any& array, sal_Int32 index)
+ throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException );
+ virtual void SAL_CALL set(Any& array, sal_Int32 index, const Any& value)
+ throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException );
+};
+
+ImplIntrospectionAdapter::ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_,
+ const Any& obj, IntrospectionAccessStatic_Impl* pStaticImpl_ )
+ : mpAccess( pAccess_), mrInspectedObject( obj ), mpStaticImpl( pStaticImpl_ )
+{
+ mpStaticImpl->acquire();
+
+ // Objekt als Interfaceholen
+ TypeClass eType = mrInspectedObject.getValueType().getTypeClass();
+ if( eType == TypeClass_INTERFACE )
+ {
+ mxIface = *( Reference< XInterface >*)mrInspectedObject.getValue();
+
+ mxObjElementAccess = Reference<XElementAccess>::query( mxIface );
+ mxObjNameAccess = Reference<XNameAccess>::query( mxIface );
+ mxObjNameContainer = Reference<XNameContainer>::query( mxIface );
+ mxObjIndexAccess = Reference<XIndexAccess>::query( mxIface );
+ mxObjIndexContainer = Reference<XIndexContainer>::query( mxIface );
+ mxObjEnumerationAccess = Reference<XEnumerationAccess>::query( mxIface );
+ mxObjIdlArray = Reference<XIdlArray>::query( mxIface );
+ }
+}
+
+ImplIntrospectionAdapter::~ImplIntrospectionAdapter()
+{
+ mpStaticImpl->release();
+}
+
+// Methoden von XInterface
+Any SAL_CALL ImplIntrospectionAdapter::queryInterface( const Type& rType )
+ throw( RuntimeException )
+{
+ Any aRet( ::cppu::queryInterface(
+ rType,
+ static_cast< XPropertySet * >( this ),
+ static_cast< XFastPropertySet * >( this ),
+ static_cast< XPropertySetInfo * >( this ) ) );
+ if( !aRet.hasValue() )
+ aRet = OWeakObject::queryInterface( rType );
+
+ if( !aRet.hasValue() )
+ {
+ // Wrapper fuer die Objekt-Interfaces
+ if( ( mxObjElementAccess.is() && (aRet = ::cppu::queryInterface
+ ( rType, static_cast< XElementAccess* >( static_cast< XNameAccess* >( this ) ) ) ).hasValue() )
+ || ( mxObjNameAccess.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XNameAccess* >( this ) ) ).hasValue() )
+ || ( mxObjNameContainer.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XNameContainer* >( this ) ) ).hasValue() )
+ || ( mxObjIndexAccess.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XIndexAccess* >( this ) ) ).hasValue() )
+ || ( mxObjIndexContainer.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XIndexContainer* >( this ) ) ).hasValue() )
+ || ( mxObjEnumerationAccess .is() && (aRet = ::cppu::queryInterface( rType, static_cast< XEnumerationAccess* >( this ) ) ).hasValue() )
+ || ( mxObjIdlArray.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XIdlArray* >( this ) ) ).hasValue() )
+ )
+ {
+ }
+ }
+ return aRet;
+}
+
+
+//*******************************
+//*** ImplIntrospectionAccess ***
+//*******************************
+
+// Neue Impl-Klasse im Rahmen der Introspection-Umstellung auf Instanz-gebundene
+// Introspection mit Property-Zugriff ueber XPropertySet. Die alte Klasse
+// ImplIntrospectionAccess lebt als IntrospectionAccessStatic_Impl
+class ImplIntrospectionAccess : IntrospectionAccessHelper
+{
+ friend class ImplIntrospection;
+
+ // Untersuchtes Objekt
+ Any maInspectedObject;
+
+ // Als Interface
+ Reference<XInterface> mxIface;
+
+ // Statische Daten der Introspection
+ IntrospectionAccessStatic_Impl* mpStaticImpl;
+
+ // Adapter-Implementation
+ ImplIntrospectionAdapter* mpAdapter;
+
+ // Letzte Sequence, die bei getProperties geliefert wurde (Optimierung)
+ Sequence<Property> maLastPropertySeq;
+ sal_Int32 mnLastPropertyConcept;
+
+ // Letzte Sequence, die bei getMethods geliefert wurde (Optimierung)
+ Sequence<Reference<XIdlMethod> > maLastMethodSeq;
+ sal_Int32 mnLastMethodConcept;
+
+public:
+ ImplIntrospectionAccess( const Any& obj, IntrospectionAccessStatic_Impl* pStaticImpl_ );
+ ~ImplIntrospectionAccess();
+
+ // Methoden von XIntrospectionAccess
+ virtual sal_Int32 SAL_CALL getSuppliedMethodConcepts(void)
+ throw( RuntimeException );
+ virtual sal_Int32 SAL_CALL getSuppliedPropertyConcepts(void)
+ throw( RuntimeException );
+ virtual Property SAL_CALL getProperty(const OUString& Name, sal_Int32 PropertyConcepts)
+ throw( NoSuchElementException, RuntimeException );
+ virtual sal_Bool SAL_CALL hasProperty(const OUString& Name, sal_Int32 PropertyConcepts)
+ throw( RuntimeException );
+ virtual Sequence< Property > SAL_CALL getProperties(sal_Int32 PropertyConcepts)
+ throw( RuntimeException );
+ virtual Reference<XIdlMethod> SAL_CALL getMethod(const OUString& Name, sal_Int32 MethodConcepts)
+ throw( NoSuchMethodException, RuntimeException );
+ virtual sal_Bool SAL_CALL hasMethod(const OUString& Name, sal_Int32 MethodConcepts)
+ throw( RuntimeException );
+ virtual Sequence< Reference<XIdlMethod> > SAL_CALL getMethods(sal_Int32 MethodConcepts)
+ throw( RuntimeException );
+ virtual Sequence< Type > SAL_CALL getSupportedListeners(void)
+ throw( RuntimeException );
+ virtual Reference<XInterface> SAL_CALL queryAdapter( const Type& rType )
+ throw( IllegalTypeException, RuntimeException );
+
+ // Methoden von XMaterialHolder
+ virtual Any SAL_CALL getMaterial(void);
+
+ // Methoden von XExactName
+ virtual OUString SAL_CALL getExactName( const OUString& rApproximateName ) throw( RuntimeException );
+};
+
+ImplIntrospectionAccess::ImplIntrospectionAccess
+ ( const Any& obj, IntrospectionAccessStatic_Impl* pStaticImpl_ )
+ : maInspectedObject( obj ), mpStaticImpl( pStaticImpl_ ), mpAdapter( NULL )
+{
+ mpStaticImpl->acquire();
+
+ // Objekt als Interface merken, wenn moeglich
+ TypeClass eType = maInspectedObject.getValueType().getTypeClass();
+ if( eType == TypeClass_INTERFACE )
+ mxIface = *(Reference<XInterface>*)maInspectedObject.getValue();
+
+ mnLastPropertyConcept = -1;
+ mnLastMethodConcept = -1;
+}
+
+ImplIntrospectionAccess::~ImplIntrospectionAccess()
+{
+ mpStaticImpl->release();
+
+ // Eigene Referenz loslassen
+ if (mpAdapter)
+ mpAdapter->release();
+}
+
+
+//***************************************************
+//*** Implementation von ImplIntrospectionAdapter ***
+//***************************************************
+
+// Methoden von XPropertySet
+Reference<XPropertySetInfo> ImplIntrospectionAdapter::getPropertySetInfo(void)
+ throw( RuntimeException )
+{
+ return (XPropertySetInfo *)this;
+}
+
+void ImplIntrospectionAdapter::setPropertyValue(const OUString& aPropertyName, const Any& aValue)
+ throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
+{
+ mpStaticImpl->setPropertyValue( mrInspectedObject, aPropertyName, aValue );
+}
+
+Any ImplIntrospectionAdapter::getPropertyValue(const OUString& aPropertyName)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ return mpStaticImpl->getPropertyValue( mrInspectedObject, aPropertyName );
+}
+
+void ImplIntrospectionAdapter::addPropertyChangeListener(const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ if( mxIface.is() )
+ {
+ Reference<XPropertySet> xPropSet =
+ Reference<XPropertySet>::query( mxIface );
+ //Reference<XPropertySet> xPropSet( mxIface, USR_QUERY );
+ if( xPropSet.is() )
+ xPropSet->addPropertyChangeListener(aPropertyName, aListener);
+ }
+}
+
+void ImplIntrospectionAdapter::removePropertyChangeListener(const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ if( mxIface.is() )
+ {
+ Reference<XPropertySet> xPropSet =
+ Reference<XPropertySet>::query( mxIface );
+ //Reference<XPropertySet> xPropSet( mxIface, USR_QUERY );
+ if( xPropSet.is() )
+ xPropSet->removePropertyChangeListener(aPropertyName, aListener);
+ }
+}
+
+void ImplIntrospectionAdapter::addVetoableChangeListener(const OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ if( mxIface.is() )
+ {
+ Reference<XPropertySet> xPropSet =
+ Reference<XPropertySet>::query( mxIface );
+ //Reference<XPropertySet> xPropSet( mxIface, USR_QUERY );
+ if( xPropSet.is() )
+ xPropSet->addVetoableChangeListener(aPropertyName, aListener);
+ }
+}
+
+void ImplIntrospectionAdapter::removeVetoableChangeListener(const OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ if( mxIface.is() )
+ {
+ Reference<XPropertySet> xPropSet =
+ Reference<XPropertySet>::query( mxIface );
+ if( xPropSet.is() )
+ xPropSet->removeVetoableChangeListener(aPropertyName, aListener);
+ }
+}
+
+
+// Methoden von XFastPropertySet
+void ImplIntrospectionAdapter::setFastPropertyValue(sal_Int32 nHandle, const Any& aValue)
+ throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
+{
+}
+
+Any ImplIntrospectionAdapter::getFastPropertyValue(sal_Int32 nHandle)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ return Any();
+}
+
+// Methoden von XPropertySetInfo
+Sequence< Property > ImplIntrospectionAdapter::getProperties(void) throw( RuntimeException )
+{
+ return mpStaticImpl->getProperties();
+}
+
+Property ImplIntrospectionAdapter::getPropertyByName(const OUString& Name)
+ throw( RuntimeException )
+{
+ return mpAccess->getProperty( Name, PropertyConcept::ALL );
+}
+
+sal_Bool ImplIntrospectionAdapter::hasPropertyByName(const OUString& Name)
+ throw( RuntimeException )
+{
+ return mpAccess->hasProperty( Name, PropertyConcept::ALL );
+}
+
+// Methoden von XElementAccess
+Type ImplIntrospectionAdapter::getElementType(void) throw( RuntimeException )
+{
+ return mxObjElementAccess->getElementType();
+}
+
+sal_Bool ImplIntrospectionAdapter::hasElements(void) throw( RuntimeException )
+{
+ return mxObjElementAccess->hasElements();
+}
+
+// Methoden von XNameAccess
+Any ImplIntrospectionAdapter::getByName(const OUString& Name)
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException )
+{
+ return mxObjNameAccess->getByName( Name );
+}
+
+Sequence< OUString > ImplIntrospectionAdapter::getElementNames(void)
+ throw( RuntimeException )
+{
+ return mxObjNameAccess->getElementNames();
+}
+
+sal_Bool ImplIntrospectionAdapter::hasByName(const OUString& Name)
+ throw( RuntimeException )
+{
+ return mxObjNameAccess->hasByName( Name );
+}
+
+// Methoden von XNameContainer
+void ImplIntrospectionAdapter::insertByName(const OUString& Name, const Any& Element)
+ throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException )
+{
+ mxObjNameContainer->insertByName( Name, Element );
+}
+
+void ImplIntrospectionAdapter::replaceByName(const OUString& Name, const Any& Element)
+ throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException )
+{
+ mxObjNameContainer->replaceByName( Name, Element );
+}
+
+void ImplIntrospectionAdapter::removeByName(const OUString& Name)
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException )
+{
+ mxObjNameContainer->removeByName( Name );
+}
+
+// Methoden von XIndexAccess
+// Schon in XNameAccess: virtual Reference<XIdlClass> getElementType(void) const
+sal_Int32 ImplIntrospectionAdapter::getCount(void) throw( RuntimeException )
+{
+ return mxObjIndexAccess->getCount();
+}
+
+Any ImplIntrospectionAdapter::getByIndex(sal_Int32 Index)
+ throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+{
+ return mxObjIndexAccess->getByIndex( Index );
+}
+
+// Methoden von XIndexContainer
+void ImplIntrospectionAdapter::insertByIndex(sal_Int32 Index, const Any& Element)
+ throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+{
+ mxObjIndexContainer->insertByIndex( Index, Element );
+}
+
+void ImplIntrospectionAdapter::replaceByIndex(sal_Int32 Index, const Any& Element)
+ throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+{
+ mxObjIndexContainer->replaceByIndex( Index, Element );
+}
+
+void ImplIntrospectionAdapter::removeByIndex(sal_Int32 Index)
+ throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+{
+ mxObjIndexContainer->removeByIndex( Index );
+}
+
+// Methoden von XEnumerationAccess
+// Schon in XNameAccess: virtual Reference<XIdlClass> getElementType(void) const;
+Reference<XEnumeration> ImplIntrospectionAdapter::createEnumeration(void) throw( RuntimeException )
+{
+ return mxObjEnumerationAccess->createEnumeration();
+}
+
+// Methoden von XIdlArray
+void ImplIntrospectionAdapter::realloc(Any& array, sal_Int32 length)
+ throw( IllegalArgumentException, RuntimeException )
+{
+ mxObjIdlArray->realloc( array, length );
+}
+
+sal_Int32 ImplIntrospectionAdapter::getLen(const Any& array)
+ throw( IllegalArgumentException, RuntimeException )
+{
+ return mxObjIdlArray->getLen( array );
+}
+
+Any ImplIntrospectionAdapter::get(const Any& array, sal_Int32 index)
+ throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException )
+{
+ return mxObjIdlArray->get( array, index );
+}
+
+void ImplIntrospectionAdapter::set(Any& array, sal_Int32 index, const Any& value)
+ throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException )
+{
+ mxObjIdlArray->set( array, index, value );
+}
+
+
+//**************************************************
+//*** Implementation von ImplIntrospectionAccess ***
+//**************************************************
+
+// Methoden von XIntrospectionAccess
+sal_Int32 ImplIntrospectionAccess::getSuppliedMethodConcepts(void)
+ throw( RuntimeException )
+{
+ return MethodConcept::DANGEROUS |
+ PROPERTY |
+ LISTENER |
+ ENUMERATION |
+ NAMECONTAINER |
+ INDEXCONTAINER;
+}
+
+sal_Int32 ImplIntrospectionAccess::getSuppliedPropertyConcepts(void)
+ throw( RuntimeException )
+{
+ return PropertyConcept::DANGEROUS |
+ PROPERTYSET |
+ ATTRIBUTES |
+ METHODS;
+}
+
+Property ImplIntrospectionAccess::getProperty(const OUString& Name, sal_Int32 PropertyConcepts)
+ throw( NoSuchElementException, RuntimeException )
+{
+ Property aRet;
+ sal_Int32 i = mpStaticImpl->getPropertyIndex( Name );
+ sal_Bool bFound = sal_False;
+ if( i != -1 )
+ {
+ sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ];
+ if( (PropertyConcepts & nConcept) != 0 )
+ {
+ const Property* pProps = mpStaticImpl->getProperties().getConstArray();
+ aRet = pProps[ i ];
+ bFound = sal_True;
+ }
+ }
+ if( !bFound )
+ throw NoSuchElementException() ;
+ return aRet;
+}
+
+sal_Bool ImplIntrospectionAccess::hasProperty(const OUString& Name, sal_Int32 PropertyConcepts)
+ throw( RuntimeException )
+{
+ sal_Int32 i = mpStaticImpl->getPropertyIndex( Name );
+ sal_Bool bRet = sal_False;
+ if( i != -1 )
+ {
+ sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ];
+ if( (PropertyConcepts & nConcept) != 0 )
+ bRet = sal_True;
+ }
+ return bRet;
+}
+
+Sequence< Property > ImplIntrospectionAccess::getProperties(sal_Int32 PropertyConcepts)
+ throw( RuntimeException )
+{
+ // Wenn alle unterstuetzten Konzepte gefordert werden, Sequence einfach durchreichen
+ sal_Int32 nAllSupportedMask = PROPERTYSET |
+ ATTRIBUTES |
+ METHODS;
+ if( ( PropertyConcepts & nAllSupportedMask ) == nAllSupportedMask )
+ {
+ return mpStaticImpl->getProperties();
+ }
+
+ // Gleiche Sequence wie beim vorigen mal?
+ if( mnLastPropertyConcept == PropertyConcepts )
+ {
+ return maLastPropertySeq;
+ }
+
+ // Anzahl der zu liefernden Properties
+ sal_Int32 nCount = 0;
+
+ // Es gibt zur Zeit keine DANGEROUS-Properties
+ // if( PropertyConcepts & DANGEROUS )
+ // nCount += mpStaticImpl->mnDangerousPropCount;
+ if( PropertyConcepts & PROPERTYSET )
+ nCount += mpStaticImpl->mnPropertySetPropCount;
+ if( PropertyConcepts & ATTRIBUTES )
+ nCount += mpStaticImpl->mnAttributePropCount;
+ if( PropertyConcepts & METHODS )
+ nCount += mpStaticImpl->mnMethodPropCount;
+
+ // Sequence entsprechend der geforderten Anzahl reallocieren
+ ImplIntrospectionAccess* pThis = (ImplIntrospectionAccess*)this; // const umgehen
+ pThis->maLastPropertySeq.realloc( nCount );
+ Property* pDestProps = pThis->maLastPropertySeq.getArray();
+
+ // Alle Properties durchgehen und entsprechend der Concepte uebernehmen
+ Sequence<Property> aPropSeq = mpStaticImpl->getProperties();
+ const Property* pSourceProps = aPropSeq.getConstArray();
+ const sal_Int32* pConcepts = mpStaticImpl->getPropertyConcepts().getConstArray();
+ sal_Int32 nLen = aPropSeq.getLength();
+
+ sal_Int32 iDest = 0;
+ for( sal_Int32 i = 0 ; i < nLen ; i++ )
+ {
+ sal_Int32 nConcept = pConcepts[ i ];
+ if( nConcept & PropertyConcepts )
+ pDestProps[ iDest++ ] = pSourceProps[ i ];
+
+ /*
+ // Property mit Concepts ausgeben
+ OUString aPropName = pSourceProps[ i ].Name;
+ String aNameStr = OOUStringToString(aPropName, CHARSET_SYSTEM);
+ String ConceptStr;
+ if( nConcept & PROPERTYSET )
+ ConceptStr += "PROPERTYSET";
+ if( nConcept & ATTRIBUTES )
+ ConceptStr += "ATTRIBUTES";
+ if( nConcept & METHODS )
+ ConceptStr += "METHODS";
+ printf( "Property %ld: %s, Concept = %s\n", i, aNameStr.GetStr(), ConceptStr.GetStr() );
+ */
+ }
+
+ // PropertyConcept merken, dies entspricht maLastPropertySeq
+ pThis->mnLastPropertyConcept = PropertyConcepts;
+
+ // Zusammengebastelte Sequence liefern
+ return maLastPropertySeq;
+}
+
+Reference<XIdlMethod> ImplIntrospectionAccess::getMethod(const OUString& Name, sal_Int32 MethodConcepts)
+ throw( NoSuchMethodException, RuntimeException )
+{
+ Reference<XIdlMethod> xRet;
+ sal_Int32 i = mpStaticImpl->getMethodIndex( Name );
+ if( i != -1 )
+ {
+
+ sal_Int32 nConcept = mpStaticImpl->getMethodConcepts().getConstArray()[ i ];
+ if( (MethodConcepts & nConcept) != 0 )
+ {
+ const Reference<XIdlMethod>* pMethods = mpStaticImpl->getMethods().getConstArray();
+ xRet = pMethods[i];
+ }
+ }
+ if( !xRet.is() )
+ throw NoSuchMethodException();
+ return xRet;
+}
+
+sal_Bool ImplIntrospectionAccess::hasMethod(const OUString& Name, sal_Int32 MethodConcepts)
+ throw( RuntimeException )
+{
+ sal_Int32 i = mpStaticImpl->getMethodIndex( Name );
+ sal_Bool bRet = sal_False;
+ if( i != -1 )
+ {
+ sal_Int32 nConcept = mpStaticImpl->getMethodConcepts().getConstArray()[ i ];
+ if( (MethodConcepts & nConcept) != 0 )
+ bRet = sal_True;
+ }
+ return bRet;
+}
+
+Sequence< Reference<XIdlMethod> > ImplIntrospectionAccess::getMethods(sal_Int32 MethodConcepts)
+ throw( RuntimeException )
+{
+ ImplIntrospectionAccess* pThis = (ImplIntrospectionAccess*)this; // const umgehen
+
+ // Wenn alle unterstuetzten Konzepte gefordert werden, Sequence einfach durchreichen
+ sal_Int32 nAllSupportedMask = MethodConcept::DANGEROUS |
+ PROPERTY |
+ LISTENER |
+ ENUMERATION |
+ NAMECONTAINER |
+ INDEXCONTAINER |
+ MethodConcept_NORMAL_IMPL;
+ if( ( MethodConcepts & nAllSupportedMask ) == nAllSupportedMask )
+ {
+ return mpStaticImpl->getMethods();
+ }
+
+ // Gleiche Sequence wie beim vorigen mal?
+ if( mnLastMethodConcept == MethodConcepts )
+ {
+ return maLastMethodSeq;
+ }
+
+ // Methoden-Sequences besorgen
+ Sequence< Reference<XIdlMethod> > aMethodSeq = mpStaticImpl->getMethods();
+ const Reference<XIdlMethod>* pSourceMethods = aMethodSeq.getConstArray();
+ const sal_Int32* pConcepts = mpStaticImpl->getMethodConcepts().getConstArray();
+ sal_Int32 nLen = aMethodSeq.getLength();
+
+ // Sequence entsprechend der geforderten Anzahl reallocieren
+ // Anders als bei den Properties kann die Anzahl nicht durch
+ // Zaehler in inspect() vorher ermittelt werden, da Methoden
+ // mehreren Konzepten angehoeren koennen
+ pThis->maLastMethodSeq.realloc( nLen );
+ Reference<XIdlMethod>* pDestMethods = pThis->maLastMethodSeq.getArray();
+
+ // Alle Methods durchgehen und entsprechend der Concepte uebernehmen
+ sal_Int32 iDest = 0;
+ for( sal_Int32 i = 0 ; i < nLen ; i++ )
+ {
+ sal_Int32 nConcept = pConcepts[ i ];
+ if( nConcept & MethodConcepts )
+ pDestMethods[ iDest++ ] = pSourceMethods[ i ];
+
+ /*
+ // Methode mit Concepts ausgeben
+ const XIdlMethodRef& rxMethod = pSourceMethods[ i ];
+ OUString aMethName = rxMethod->getName();
+ String aNameStr = OOUStringToString(aMethName, CHARSET_SYSTEM);
+ String ConceptStr;
+ if( nConcept & DANGEROUS )
+ ConceptStr += "DANGEROUS |";
+ if( nConcept & PROPERTY )
+ ConceptStr += "PROPERTY |";
+ if( nConcept & LISTENER )
+ ConceptStr += "LISTENER |";
+ if( nConcept & ENUMERATION )
+ ConceptStr += "ENUMERATION |";
+ if( nConcept & NAMECONTAINER )
+ ConceptStr += "NAMECONTAINER |";
+ if( nConcept & INDEXCONTAINER )
+ ConceptStr += "INDEXCONTAINER |";
+ if( nConcept & NORMAL_IMPL )
+ ConceptStr += "NORMAL_IMPL |";
+ printf( "Method %ld: %s, Concepts = %s\n", i, aNameStr.GetStr(), ConceptStr.GetStr() );
+ */
+ }
+
+ // Auf die richtige Laenge bringen
+ pThis->maLastMethodSeq.realloc( iDest );
+
+ // MethodConcept merken, dies entspricht maLastMethodSeq
+ pThis->mnLastMethodConcept = MethodConcepts;
+
+ // Zusammengebastelte Sequence liefern
+ return maLastMethodSeq;
+}
+
+Sequence< Type > ImplIntrospectionAccess::getSupportedListeners(void)
+ throw( RuntimeException )
+{
+ return mpStaticImpl->getSupportedListeners();
+}
+
+Reference<XInterface> SAL_CALL ImplIntrospectionAccess::queryAdapter( const Type& rType )
+ throw( IllegalTypeException, RuntimeException )
+{
+ // Gibt es schon einen Adapter?
+ if( !mpAdapter )
+ {
+ ((ImplIntrospectionAccess*)this)->mpAdapter =
+ new ImplIntrospectionAdapter( this, maInspectedObject, mpStaticImpl );
+
+ // Selbst eine Referenz halten
+ mpAdapter->acquire();
+ }
+
+ Reference<XInterface> xRet;
+ Any aIfaceAny( mpAdapter->queryInterface( rType ) );
+ if( aIfaceAny.hasValue() )
+ xRet = *(Reference<XInterface>*)aIfaceAny.getValue();
+
+ return xRet;
+}
+
+// Methoden von XMaterialHolder
+Any ImplIntrospectionAccess::getMaterial(void)
+{
+ return maInspectedObject;
+}
+
+// Hilfs-Funktion zur LowerCase-Wandlung eines OUString
+OUString toLower( OUString aUStr )
+{
+ // Tabelle fuer XExactName pflegen
+ NAMESPACE_RTL(OUString) aOWStr( aUStr.getStr() );
+ NAMESPACE_RTL(OUString) aOWLowerStr = aOWStr.toLowerCase();
+ OUString aLowerUStr( aOWLowerStr.getStr() );
+ return aLowerUStr;
+}
+
+// Methoden von XExactName
+OUString ImplIntrospectionAccess::getExactName( const OUString& rApproximateName ) throw( RuntimeException )
+{
+ OUString aRetStr;
+ LowerToExactNameMap::iterator aIt =
+ mpStaticImpl->maLowerToExactNameMap.find( toLower( rApproximateName ) );
+ if( !( aIt == mpStaticImpl->maLowerToExactNameMap.end() ) )
+ aRetStr = (*aIt).second;
+ return aRetStr;
+}
+
+
+//-----------------------------------------------------------------------------
+
+#ifdef USE_INTROSPECTION_CACHE
+
+struct hashIntrospectionKey_Impl
+{
+ Sequence< Reference<XIdlClass> > aIdlClasses;
+ Reference<XPropertySetInfo> xPropInfo;
+ Reference<XIdlClass> xImplClass;
+ sal_Int32 nHitCount;
+
+ void IncHitCount() const { ((hashIntrospectionKey_Impl*)this)->nHitCount++; }
+ hashIntrospectionKey_Impl() : nHitCount( 0 ) {}
+ hashIntrospectionKey_Impl( const Sequence< Reference<XIdlClass> > & rIdlClasses,
+ const Reference<XPropertySetInfo> & rxPropInfo,
+ const Reference<XIdlClass> & rxImplClass );
+};
+
+hashIntrospectionKey_Impl::hashIntrospectionKey_Impl
+(
+ const Sequence< Reference<XIdlClass> > & rIdlClasses,
+ const Reference<XPropertySetInfo> & rxPropInfo,
+ const Reference<XIdlClass> & rxImplClass
+)
+ : aIdlClasses( rIdlClasses )
+ , xPropInfo( rxPropInfo )
+ , xImplClass( rxImplClass )
+ , nHitCount( 0 )
+{}
+
+
+struct hashIntrospectionAccessCache_Impl
+{
+ size_t operator()(const hashIntrospectionKey_Impl & rObj ) const
+ {
+ return (size_t)rObj.xImplClass.get() ^ (size_t)rObj.xPropInfo.get();
+ }
+
+ bool operator()( const hashIntrospectionKey_Impl & rObj1,
+ const hashIntrospectionKey_Impl & rObj2 ) const
+ {
+ if( rObj1.xPropInfo != rObj2.xPropInfo
+ || rObj1.xImplClass != rObj2.xImplClass )
+ return sal_False;
+
+ sal_Int32 nCount1 = rObj1.aIdlClasses.getLength();
+ sal_Int32 nCount2 = rObj2.aIdlClasses.getLength();
+ if( nCount1 != nCount2 )
+ return sal_False;
+
+ const Reference<XIdlClass>* pRefs1 = rObj1.aIdlClasses.getConstArray();
+ const Reference<XIdlClass>* pRefs2 = rObj2.aIdlClasses.getConstArray();
+ return memcmp( pRefs1, pRefs2, nCount1 * sizeof( Reference<XIdlClass> ) ) == 0;
+ }
+
+};
+
+typedef NAMESPACE_STD(hash_map)
+<
+ hashIntrospectionKey_Impl,
+ IntrospectionAccessStatic_Impl*,
+ hashIntrospectionAccessCache_Impl,
+ hashIntrospectionAccessCache_Impl
+>
+IntrospectionAccessCacheMap_Impl;
+
+class IntrospectionAccessCacheMap : public IntrospectionAccessCacheMap_Impl
+{
+public:
+ ~IntrospectionAccessCacheMap()
+ {
+ IntrospectionAccessCacheMap::iterator iter = begin();
+ IntrospectionAccessCacheMap::iterator end = this->end();
+ while( iter != end )
+ {
+
+ (*iter).second->release();
+ (*iter).second = NULL;
+ iter++;
+ }
+ }
+};
+
+
+// For XTypeProvider
+struct hashTypeProviderKey_Impl
+{
+ Reference<XPropertySetInfo> xPropInfo;
+ Sequence< sal_Int8 > maImpIdSeq;
+ sal_Int32 nHitCount;
+
+ void IncHitCount() const { ((hashTypeProviderKey_Impl*)this)->nHitCount++; }
+ hashTypeProviderKey_Impl() : nHitCount( 0 ) {}
+ hashTypeProviderKey_Impl( const Reference<XPropertySetInfo> & rxPropInfo, const Sequence< sal_Int8 > & aImpIdSeq_ );
+};
+
+hashTypeProviderKey_Impl::hashTypeProviderKey_Impl
+(
+ const Reference<XPropertySetInfo> & rxPropInfo,
+ const Sequence< sal_Int8 > & aImpIdSeq_
+)
+ : xPropInfo( rxPropInfo )
+ , maImpIdSeq( aImpIdSeq_ )
+ , nHitCount( 0 )
+{}
+
+
+struct TypeProviderAccessCache_Impl
+{
+ size_t operator()(const hashTypeProviderKey_Impl & rObj ) const;
+
+ bool operator()( const hashTypeProviderKey_Impl & rObj1,
+ const hashTypeProviderKey_Impl & rObj2 ) const
+ {
+ if( rObj1.xPropInfo != rObj2.xPropInfo )
+ return sal_False;
+
+ const sal_Int8* pId1 = rObj1.maImpIdSeq.getConstArray();
+ const sal_Int8* pId2 = rObj2.maImpIdSeq.getConstArray();
+ return memcmp( pId1, pId2, 16 * sizeof( sal_Int8 ) ) == 0;
+ }
+};
+
+size_t TypeProviderAccessCache_Impl::operator()(const hashTypeProviderKey_Impl & rObj ) const
+{
+ const sal_Int32* pBytesAsInt32Array = (const sal_Int32*)rObj.maImpIdSeq.getConstArray();
+ sal_Int32 nId32 = pBytesAsInt32Array[0] ^
+ pBytesAsInt32Array[1] ^
+ pBytesAsInt32Array[2] ^
+ pBytesAsInt32Array[3];
+ return (size_t)nId32 ^ (size_t)rObj.xPropInfo.get();
+}
+
+
+typedef NAMESPACE_STD(hash_map)
+<
+ hashTypeProviderKey_Impl,
+ IntrospectionAccessStatic_Impl*,
+ TypeProviderAccessCache_Impl,
+ TypeProviderAccessCache_Impl
+>
+TypeProviderAccessCacheMap_Impl;
+
+class TypeProviderAccessCacheMap : public TypeProviderAccessCacheMap_Impl
+{
+public:
+ ~TypeProviderAccessCacheMap()
+ {
+ TypeProviderAccessCacheMap::iterator iter = begin();
+ TypeProviderAccessCacheMap::iterator end = this->end();
+ while( iter != end )
+ {
+ (*iter).second->release();
+ (*iter).second = NULL;
+ iter++;
+ }
+ }
+};
+
+#endif
+
+
+//*************************
+//*** ImplIntrospection ***
+//*************************
+
+struct OIntrospectionMutex
+{
+ Mutex m_mutex;
+};
+
+class ImplIntrospection : public XIntrospection
+ , public XServiceInfo
+ , public OIntrospectionMutex
+ , public OComponentHelper
+{
+ friend class ImplMergeIntrospection;
+ friend class ImplMVCIntrospection;
+
+ // Implementation der Introspection.
+ // ACHTUNG: RefCounting von Hand !!!
+ IntrospectionAccessStatic_Impl* implInspect(const Any& aToInspectObj);
+
+ // Save XMultiServiceFactory from createComponent
+ Reference<XMultiServiceFactory> m_xSMgr;
+
+ // CoreReflection halten
+ Reference< XIdlReflection > mxCoreReflection;
+
+ // Klassen, deren Methoden eine spezielle Rolle spielen
+ Reference<XIdlClass> mxElementAccessClass;
+ Reference<XIdlClass> mxNameContainerClass;
+ Reference<XIdlClass> mxNameAccessClass;
+ Reference<XIdlClass> mxIndexContainerClass;
+ Reference<XIdlClass> mxIndexAccessClass;
+ Reference<XIdlClass> mxEnumerationAccessClass;
+ Reference<XIdlClass> mxInterfaceClass;
+ Reference<XIdlClass> mxAggregationClass;
+ sal_Bool mbDisposed;
+
+#ifdef USE_INTROSPECTION_CACHE
+ sal_uInt16 mnCacheEntryCount;
+ IntrospectionAccessCacheMap* mpCache;
+ TypeProviderAccessCacheMap* mpTypeProviderCache;
+#endif
+
+public:
+ ImplIntrospection( const Reference<XMultiServiceFactory> & rXSMgr );
+
+ // Methoden von XInterface
+ virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
+ virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
+
+ // XTypeProvider
+ Sequence< Type > SAL_CALL getTypes( ) throw( RuntimeException );
+ Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw( RuntimeException );
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName() throw();
+ sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw();
+ Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw();
+ static OUString SAL_CALL getImplementationName_Static( );
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static(void) throw();
+
+ // Methoden von XIntrospection
+ virtual Reference<XIntrospectionAccess> SAL_CALL inspect(const Any& aToInspectObj)
+ throw( RuntimeException );
+
+protected:
+ // some XComponent part from OComponentHelper
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+};
+
+enum MethodType
+{
+ STANDARD_METHOD, // normale Methode, kein Bezug zu Properties oder Listenern
+ GETSET_METHOD, // gehoert zu einer get/set-Property
+ ADD_LISTENER_METHOD, // add-Methode einer Listener-Schnittstelle
+ REMOVE_LISTENER_METHOD, // remove-Methode einer Listener-Schnittstelle
+ INVALID_METHOD // Methode, deren Klasse nicht beruecksichtigt wird, z.B. XPropertySet
+};
+
+// Ctor
+ImplIntrospection::ImplIntrospection( const Reference<XMultiServiceFactory> & rXSMgr )
+ : m_xSMgr( rXSMgr )
+ , OComponentHelper( m_mutex )
+{
+#ifdef USE_INTROSPECTION_CACHE
+ mnCacheEntryCount = 0;
+ mpCache = NULL;
+ mpTypeProviderCache = NULL;
+#endif
+
+ // Spezielle Klassen holen
+ Reference< XInterface > xServiceIface = m_xSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.CoreReflection")) );
+ if( xServiceIface.is() )
+ mxCoreReflection = Reference< XIdlReflection >::query( xServiceIface );
+
+ mxElementAccessClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XElementAccess")) );
+ mxNameContainerClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XNameContainer")) );
+ mxNameAccessClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XNameAccess")) );
+ mxIndexContainerClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XIndexContainer")) );
+ mxIndexAccessClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XIndexAccess")) );
+ mxEnumerationAccessClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XEnumerationAccess")) );
+ mxInterfaceClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface")) );
+ mxAggregationClass = mxCoreReflection->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XAggregation")) );
+ mbDisposed = sal_False;
+}
+
+// XComponent
+void ImplIntrospection::dispose() throw(::com::sun::star::uno::RuntimeException)
+{
+ OComponentHelper::dispose();
+
+#ifdef USE_INTROSPECTION_CACHE
+ // Cache loeschen
+ delete mpCache;
+ mpCache = NULL;
+ delete mpTypeProviderCache;
+ mpTypeProviderCache = NULL;
+#endif
+
+ mxElementAccessClass = NULL;
+ mxNameContainerClass = NULL;
+ mxNameAccessClass = NULL;
+ mxIndexContainerClass = NULL;
+ mxIndexAccessClass = NULL;
+ mxEnumerationAccessClass = NULL;
+ mxInterfaceClass = NULL;
+ mxAggregationClass = NULL;
+ mbDisposed = sal_True;
+}
+
+
+//-----------------------------------------------------------------------------
+
+// XInterface
+Any ImplIntrospection::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( ::cppu::queryInterface(
+ rType,
+ static_cast< XIntrospection * >( this ),
+ static_cast< XServiceInfo * >( this ) ) );
+
+ return (aRet.hasValue() ? aRet : OComponentHelper::queryInterface( rType ));
+}
+
+// XTypeProvider
+Sequence< Type > ImplIntrospection::getTypes()
+ throw( RuntimeException )
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< XIntrospection > *)0 ),
+ ::getCppuType( (const Reference< XServiceInfo > *)0 ),
+ OComponentHelper::getTypes() );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+
+Sequence< sal_Int8 > ImplIntrospection::getImplementationId()
+ throw( RuntimeException )
+{
+ static OImplementationId * s_pId = 0;
+ if (! s_pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pId)
+ {
+ static OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+}
+
+
+// XServiceInfo
+OUString ImplIntrospection::getImplementationName() throw()
+{
+ return getImplementationName_Static();
+}
+
+// XServiceInfo
+sal_Bool ImplIntrospection::supportsService(const OUString& ServiceName) throw()
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+// XServiceInfo
+Sequence< OUString > ImplIntrospection::getSupportedServiceNames(void) throw()
+{
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+// Helper XServiceInfo
+OUString ImplIntrospection::getImplementationName_Static( )
+{
+ return OUString::createFromAscii( IMPLEMENTATION_NAME );
+}
+
+// ORegistryServiceManager_Static
+Sequence< OUString > ImplIntrospection::getSupportedServiceNames_Static(void) throw()
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString::createFromAscii( SERVICE_NAME );
+ return aSNS;
+}
+
+//*************************************************************************
+
+// Methoden von XIntrospection
+Reference<XIntrospectionAccess> ImplIntrospection::inspect(const Any& aToInspectObj)
+ throw( RuntimeException )
+{
+ Reference<XIntrospectionAccess> xAccess;
+
+ if ( aToInspectObj.getValueType().getTypeClass() == TypeClass_TYPE )
+ {
+ Type aType;
+ aToInspectObj >>= aType;
+
+ Reference< XIdlClass > xIdlClass = mxCoreReflection->forName(((Type*)(aToInspectObj.getValue()))->getTypeName());
+
+ if ( xIdlClass.is() )
+ {
+ Any aRealInspectObj;
+ aRealInspectObj <<= xIdlClass;
+
+ IntrospectionAccessStatic_Impl* pStaticImpl = implInspect( aRealInspectObj );
+ if( pStaticImpl )
+ xAccess = new ImplIntrospectionAccess( aRealInspectObj, pStaticImpl );
+ }
+ }
+ else
+ {
+ IntrospectionAccessStatic_Impl* pStaticImpl = implInspect( aToInspectObj );
+ if( pStaticImpl )
+ xAccess = new ImplIntrospectionAccess( aToInspectObj, pStaticImpl );
+ }
+
+ return xAccess;
+}
+
+//-----------------------------------------------------------------------------
+
+// Hashtable fuer Pruefung auf mehrfache Beruecksichtigung von Interfaces
+struct hashInterface_Impl
+{
+ size_t operator()(const void* p) const
+ {
+ return (size_t)p;
+ }
+};
+
+struct eqInterface_Impl
+{
+ bool operator()(const void* p1, const void* p2) const
+ {
+ return ( p1 == p2 );
+ }
+};
+
+typedef NAMESPACE_STD(hash_map)
+<
+ void*,
+ void*,
+ hashInterface_Impl,
+ eqInterface_Impl
+>
+CheckedInterfacesMap;
+
+
+
+// TODO: Spaeter auslagern
+Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XMultiServiceFactory > & xMgr )
+{
+ static Reference< XIdlReflection > xRefl;
+
+ // void als Default-Klasse eintragen
+ Reference<XIdlClass> xRetClass;
+ typelib_TypeDescription * pTD = 0;
+ rType.getDescription( &pTD );
+ if( pTD )
+ {
+ OUString sOWName( pTD->pTypeName );
+ if( !xRefl.is() )
+ {
+ xRefl = Reference< XIdlReflection >( xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.CoreReflection")) ), UNO_QUERY );
+ OSL_ENSHURE( xRefl.is(), "### no corereflection!" );
+ }
+ xRetClass = xRefl->forName( sOWName );
+ }
+ return xRetClass;
+}
+
+// Implementation der Introspection.
+IntrospectionAccessStatic_Impl* ImplIntrospection::implInspect(const Any& aToInspectObj)
+{
+ MutexGuard aGuard( m_mutex );
+
+ // Wenn die Introspection schon disposed ist, wird nur ein leeres Ergebnis geliefert
+ if( mbDisposed )
+ return NULL;
+
+ // Objekt untersuchen
+ TypeClass eType = aToInspectObj.getValueType().getTypeClass();
+ if( eType != TypeClass_INTERFACE && eType != TypeClass_STRUCT && eType != TypeClass_EXCEPTION )
+ return NULL;
+
+ Reference<XInterface> x;
+ if( eType == TypeClass_INTERFACE )
+ {
+ // Interface aus dem Any besorgen
+ x = *(Reference<XInterface>*)aToInspectObj.getValue();
+ if( !x.is() )
+ return NULL;
+ }
+
+#ifdef USE_INTROSPECTION_CACHE
+ // Haben wir schon eine Cache-Instanz
+ if( !mpCache )
+ mpCache = new IntrospectionAccessCacheMap;
+ if( !mpTypeProviderCache )
+ mpTypeProviderCache = new TypeProviderAccessCacheMap;
+ IntrospectionAccessCacheMap& aCache = *mpCache;
+ TypeProviderAccessCacheMap& aTPCache = *mpTypeProviderCache;
+
+ // Pointer auf ggf. noetige neue IntrospectionAccess-Instanz
+ IntrospectionAccessStatic_Impl* pAccess = NULL;
+#else
+ // Pointer auf ggf. noetige neue IntrospectionAccess-Instanz
+ IntrospectionAccessStatic_Impl* pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
+#endif
+
+ // Pruefen: Ist schon ein passendes Access-Objekt gecached?
+ Sequence< Reference<XIdlClass> > SupportedClassSeq;
+ Sequence< Type > SupportedTypesSeq;
+ Reference<XIdlClassProvider> xClassProvider;
+ Reference<XTypeProvider> xTypeProvider;
+ Reference<XIdlClass> xImplClass;
+ Reference<XPropertySetInfo> xPropSetInfo;
+ Reference<XPropertySet> xPropSet;
+
+ // Bei Interfaces XTypeProvider / XIdlClassProvider- und PropertySet-Interface anfordern
+ if( eType == TypeClass_INTERFACE )
+ {
+ // XIdlClassProvider
+ xTypeProvider = Reference<XTypeProvider>::query( x );
+ if( xTypeProvider.is() )
+ {
+ SupportedTypesSeq = xTypeProvider->getTypes();
+ sal_Int32 nTypeCount = SupportedTypesSeq.getLength();
+ if( nTypeCount )
+ {
+ SupportedClassSeq.realloc( nTypeCount );
+ Reference<XIdlClass>* pClasses = SupportedClassSeq.getArray();
+
+ const Type* pTypes = SupportedTypesSeq.getConstArray();
+ for( sal_Int32 i = 0 ; i < nTypeCount ; i++ )
+ {
+ pClasses[ i ] = TypeToIdlClass( pTypes[ i ], m_xSMgr );
+ }
+ // TODO: Caching!
+ }
+ }
+ else
+ {
+ // XIdlClassProvider
+ xClassProvider = Reference<XIdlClassProvider>::query( x );
+ if( xClassProvider.is() )
+ {
+ SupportedClassSeq = xClassProvider->getIdlClasses();
+ if( SupportedClassSeq.getLength() )
+ xImplClass = SupportedClassSeq.getConstArray()[0];
+ }
+ }
+ // #70197, fuer InvocationAdapter: Interface-Typ im Any auch ohne
+ // ClassProvider unterstuetzen
+ if( !xClassProvider.is() && !xTypeProvider.is() )
+ {
+ xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr );
+ SupportedClassSeq.realloc( 1 );
+ SupportedClassSeq.getArray()[ 0 ] = xImplClass;
+ }
+
+ xPropSet = Reference<XPropertySet>::query( x );
+ // Jetzt versuchen, das PropertySetInfo zu bekommen
+ if( xPropSet.is() )
+ xPropSetInfo = xPropSet->getPropertySetInfo();
+ }
+ else
+ {
+ xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr );
+ }
+
+#ifdef USE_INTROSPECTION_CACHE
+ if( xTypeProvider.is() )
+ {
+ Sequence< sal_Int8 > aImpIdSeq = xTypeProvider->getImplementationId();
+
+ // cache only, if the descriptor class is set
+ hashTypeProviderKey_Impl aKeySeq( xPropSetInfo, aImpIdSeq );
+
+ TypeProviderAccessCacheMap::iterator aIt = aTPCache.find( aKeySeq );
+ if( aIt == aTPCache.end() )
+ {
+ // not found
+ // Neue Instanz anlegen und unter dem gegebenen Key einfuegen
+ pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
+
+ // RefCount von Hand erhoehen, muss beim Entfernen
+ // aus der Hashtable wieder released werden
+ pAccess->acquire();
+
+ // Groesse begrenzen, alten Eintrag wieder rausschmeissen
+ if( mnCacheEntryCount > INTROSPECTION_CACHE_MAX_SIZE )
+ {
+ // Access mit dem kleinsten HitCount suchen
+ TypeProviderAccessCacheMap::iterator iter = aTPCache.begin();
+ TypeProviderAccessCacheMap::iterator end = aTPCache.end();
+ TypeProviderAccessCacheMap::iterator toDelete = iter;
+ while( iter != end )
+ {
+ if( (*iter).first.nHitCount < (*toDelete).first.nHitCount )
+ toDelete = iter;
+ ++iter;
+ }
+
+ // Gefundenen Eintrag entfernen
+ if( (*toDelete).second )
+ (*toDelete).second->release();
+ (*toDelete).second = NULL;
+ aTPCache.erase( toDelete );
+ }
+ else
+ mnCacheEntryCount++;
+
+ // Neuer Eintrage rein in die Table
+ aKeySeq.nHitCount = 1;
+ aTPCache[ aKeySeq ] = pAccess;
+
+ }
+ else
+ {
+ // Hit-Count erhoehen
+ (*aIt).first.IncHitCount();
+ return (*aIt).second;
+ }
+
+ }
+ else if( xImplClass.is() )
+ {
+ // cache only, if the descriptor class is set
+ hashIntrospectionKey_Impl aKeySeq( SupportedClassSeq, xPropSetInfo, xImplClass );
+
+ IntrospectionAccessCacheMap::iterator aIt = aCache.find( aKeySeq );
+ if( aIt == aCache.end() )
+ {
+ // not found
+ // Neue Instanz anlegen und unter dem gegebenen Key einfuegen
+ pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
+
+ // RefCount von Hand erhoehen, muss beim Entfernen
+ // aus der Hashtable wieder released werden
+ pAccess->acquire();
+
+ // Groesse begrenzen, alten Eintrag wieder rausschmeissen
+ if( mnCacheEntryCount > INTROSPECTION_CACHE_MAX_SIZE )
+ {
+ // Access mit dem kleinsten HitCount suchen
+ IntrospectionAccessCacheMap::iterator iter = aCache.begin();
+ IntrospectionAccessCacheMap::iterator end = aCache.end();
+ IntrospectionAccessCacheMap::iterator toDelete = iter;
+ while( iter != end )
+ {
+ if( (*iter).first.nHitCount < (*toDelete).first.nHitCount )
+ toDelete = iter;
+ ++iter;
+ }
+
+ // Gefundenen Eintrag entfernen
+ if( (*toDelete).second )
+ (*toDelete).second->release();
+ (*toDelete).second = NULL;
+ aCache.erase( toDelete );
+ }
+ else
+ mnCacheEntryCount++;
+
+ // Neuer Eintrage rein in die Table
+ aKeySeq.nHitCount = 1;
+ aCache[ aKeySeq ] = pAccess;
+
+ }
+ else
+ {
+ // Hit-Count erhoehen
+ (*aIt).first.IncHitCount();
+ return (*aIt).second;
+ }
+ }
+#endif
+
+ // Kein Access gecached -> neu anlegen
+ Property* pAllPropArray;
+ Reference<XInterface>* pInterfaces1;
+ Reference<XInterface>* pInterfaces2;
+ sal_Int16* pMapTypeArray;
+ sal_Int32* pPropertyConceptArray;
+ sal_Int32 i;
+
+ if( !pAccess )
+ pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
+
+ // Referenzen auf wichtige Daten von pAccess
+ sal_Int32& rPropCount = pAccess->mnPropCount;
+ IntrospectionNameMap& rPropNameMap = pAccess->maPropertyNameMap;
+ IntrospectionNameMap& rMethodNameMap = pAccess->maMethodNameMap;
+ LowerToExactNameMap& rLowerToExactNameMap = pAccess->maLowerToExactNameMap;
+
+ // Schon mal Pointer auf das eigene Property-Feld holen
+ pAllPropArray = pAccess->maAllPropertySeq.getArray();
+ pInterfaces1 = pAccess->aInterfaceSeq1.getArray();
+ pInterfaces2 = pAccess->aInterfaceSeq2.getArray();
+ pMapTypeArray = pAccess->maMapTypeSeq.getArray();
+ pPropertyConceptArray = pAccess->maPropertyConceptSeq.getArray();
+
+ //*************************
+ //*** Analyse vornehmen ***
+ //*************************
+ if( eType == TypeClass_INTERFACE )
+ {
+ // Zunaechst nach speziellen Interfaces suchen, die fuer
+ // die Introspection von besonderer Bedeutung sind.
+
+ // XPropertySet vorhanden?
+ if( xPropSet.is() && xPropSetInfo.is() )
+ {
+ // Gibt es auch ein FastPropertySet?
+ Reference<XFastPropertySet> xDummy = Reference<XFastPropertySet>::query( x );
+ sal_Bool bFast = pAccess->mbFastPropSet = xDummy.is();
+
+ Sequence<Property> aPropSeq = xPropSetInfo->getProperties();
+ const Property* pProps = aPropSeq.getConstArray();
+ sal_Int32 nLen = aPropSeq.getLength();
+
+ // Bei FastPropertySet muessen wir uns die Original-Handles merken
+ if( bFast )
+ pAccess->mpOrgPropertyHandleArray = new sal_Int32[ nLen ];
+
+ for( i = 0 ; i < nLen ; i++ )
+ {
+ // Property in eigene Liste uebernehmen
+ pAccess->checkPropertyArraysSize
+ ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
+ Property& rProp = pAllPropArray[ rPropCount ];
+ rProp = pProps[ i ];
+
+ if( bFast )
+ pAccess->mpOrgPropertyHandleArray[ i ] = rProp.Handle;
+
+ // PropCount als Handle fuer das eigene FastPropertySet eintragen
+ rProp.Handle = rPropCount;
+
+ // Art der Property merken
+ pMapTypeArray[ rPropCount ] = MAP_PROPERTY_SET;
+ pPropertyConceptArray[ rPropCount ] = PROPERTYSET;
+ pAccess->mnPropertySetPropCount++;
+
+ // Namen in Hashtable eintragen, wenn nicht schon bekannt
+ OUString aPropName = rProp.Name;
+
+ // Haben wir den Namen schon?
+ IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
+ if( aIt == rPropNameMap.end() )
+ {
+ // Neuer Eintrag in die Hashtable
+ rPropNameMap[ aPropName ] = rPropCount;
+
+ // Tabelle fuer XExactName pflegen
+ rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
+ }
+ else
+ {
+ OSL_ENSHURE( sal_False,
+ OString( "Introspection: Property \"" ) +
+ OUStringToOString( aPropName, RTL_TEXTENCODING_ASCII_US ) +
+ OString( "\" found more than once in PropertySet" ) );
+ }
+
+ // Count pflegen
+ rPropCount++;
+ }
+ }
+
+
+ // Jetzt alle weiteren implementierten Interfaces durchgehen
+ // Diese muessen durch das XIdlClassProvider-Interface geliefert werden.
+ // #70197, fuer InvocationAdapter: Interface-Typ im Any auch ohne
+ // ClassProvider unterstuetzen
+ //if( xClassProvider.is() )
+ {
+ // Indizes in die Export-Tabellen
+ sal_Int32 iAllExportedMethod = 0L;
+ sal_Int32 iAllSupportedListener = 0L;
+
+ // Hashtable fuer Pruefung auf mehrfache Beruecksichtigung von Interfaces
+ CheckedInterfacesMap aCheckedInterfacesMap;
+
+ // Flag, ob XInterface-Methoden erfasst werden sollen
+ // (das darf nur einmal erfolgen, initial zulassen)
+ sal_Bool bXInterfaceIsInvalid = sal_False;
+
+ // Flag, ob die XInterface-Methoden schon erfasst wurden. Wenn sal_True,
+ // wird bXInterfaceIsInvalid am Ende der Iface-Schleife aktiviert und
+ // XInterface-Methoden werden danach abgeklemmt.
+ sal_Bool bFoundXInterface = sal_False;
+
+ // Schleife ueber alle vom ClassProvider angegebenen Klassen
+ sal_Int32 nClassCount = SupportedClassSeq.getLength();
+ for( sal_Int32 nIdx = 0 ; nIdx < nClassCount; nIdx++ )
+ {
+ Reference<XIdlClass> xImplClass = SupportedClassSeq.getConstArray()[nIdx];
+ while( xImplClass.is() )
+ {
+ // Interfaces der Implementation holen
+ Sequence< Reference<XIdlClass> > aClassSeq = xImplClass->getInterfaces();
+ sal_Int32 nIfaceCount = aClassSeq.getLength();
+
+ aClassSeq.realloc( nIfaceCount + 1 );
+ aClassSeq.getArray()[ nIfaceCount ] = xImplClass;
+ nIfaceCount++;
+
+ const Reference<XIdlClass>* pParamArray = aClassSeq.getConstArray();
+
+ for( sal_Int32 j = 0 ; j < nIfaceCount ; j++ )
+ {
+ const Reference<XIdlClass>& rxIfaceClass = pParamArray[j];
+
+ // Pruefen, ob das Interface schon beruecksichtigt wurde.
+ XInterface* pIface = SAL_STATIC_CAST( XInterface*, rxIfaceClass.get() );
+ if( aCheckedInterfacesMap.count( pIface ) > 0 )
+ {
+ // Kennen wir schon
+ continue;
+ }
+ else
+ {
+ // Sonst eintragen
+ aCheckedInterfacesMap[ pIface ] = pIface;
+ }
+
+ //********************************************************************
+
+ // 2. Fields als Properties registrieren
+
+ // Felder holen
+ Sequence< Reference<XIdlField> > fields = rxIfaceClass->getFields();
+ const Reference<XIdlField>* pFields = fields.getConstArray();
+ sal_Int32 nLen = fields.getLength();
+
+ for( i = 0 ; i < nLen ; i++ )
+ {
+ Reference<XIdlField> xField = pFields[i];
+ Reference<XIdlClass> xPropType = xField->getType();
+
+ // Ist die PropertySequence gross genug?
+ pAccess->checkPropertyArraysSize
+ ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
+
+ // In eigenes Property-Array eintragen
+ Property& rProp = pAllPropArray[ rPropCount ];
+ OUString aFieldName = xField->getName();
+ rProp.Name = aFieldName;
+ rProp.Handle = rPropCount;
+ Type aFieldType( xPropType->getTypeClass(), xPropType->getName() );
+ rProp.Type = aFieldType;
+ FieldAccessMode eAccessMode = xField->getAccessMode();
+ rProp.Attributes = (eAccessMode == FieldAccessMode_READONLY ||
+ eAccessMode == FieldAccessMode_CONST)
+ ? READONLY : 0;
+
+ // Namen in Hashtable eintragen
+ OUString aPropName = rProp.Name;
+
+ // Haben wir den Namen schon?
+ IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
+ if( !( aIt == rPropNameMap.end() ) )
+ {
+ /* TODO
+ OSL_TRACE(
+ String( "Introspection: Property \"" ) +
+ OOUStringToString( aPropName, CHARSET_SYSTEM ) +
+ String( "\" found more than once" ) );
+ */
+ continue;
+ }
+
+ // Neuer Eintrag in die Hashtable
+ rPropNameMap[ aPropName ] = rPropCount;
+
+ // Tabelle fuer XExactName pflegen
+ rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
+
+ // Field merken
+ pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq1,
+ pInterfaces1, rPropCount );
+ pInterfaces1[ rPropCount ] = xField;
+
+ // Art der Property merken
+ pMapTypeArray[ rPropCount ] = MAP_FIELD;
+ pPropertyConceptArray[ rPropCount ] = ATTRIBUTES;
+ pAccess->mnAttributePropCount++;
+
+ // Count pflegen
+ rPropCount++;
+ }
+
+ //********************************************************************
+
+ // 3. Methoden
+
+ // Zaehler fuer die gefundenen Listener
+ sal_Int32 nListenerCount = 0L;
+
+ // Alle Methoden holen und merken
+ Sequence< Reference<XIdlMethod> > methods = rxIfaceClass->getMethods();
+ const Reference<XIdlMethod>* pSourceMethods = methods.getConstArray();
+ sal_Int32 nSourceMethodCount = methods.getLength();
+
+ // 3. a) get/set- und Listener-Methoden suchen
+
+ // Feld fuer Infos ueber die Methoden anlegen, damit spaeter leicht die Methoden
+ // gefunden werden koennen, die nicht im Zusammenhang mit Properties oder Listenern
+ // stehen. NEU: auch MethodConceptArray initialisieren
+ MethodType* pMethodTypes = new MethodType[ nSourceMethodCount ];
+ sal_Int32* pLocalMethodConcepts = new sal_Int32[ nSourceMethodCount ];
+ for( i = 0 ; i < nSourceMethodCount ; i++ )
+ {
+ pMethodTypes[ i ] = STANDARD_METHOD;
+ pLocalMethodConcepts[ i ] = 0;
+ }
+
+ OUString aMethName;
+ OUString aPropName;
+ OUString aStartStr;
+ for( i = 0 ; i < nSourceMethodCount ; i++ )
+ {
+ // Methode ansprechen
+ const Reference<XIdlMethod>& rxMethod_i = pSourceMethods[i];
+ sal_Int32& rMethodConcept_i = pLocalMethodConcepts[ i ];
+
+ // Namen besorgen
+ aMethName = rxMethod_i->getName();
+
+ // Methoden katalogisieren
+ // Alle (?) Methoden von XInterface filtern, damit z.B. nicht
+ // vom Scripting aus aquire oder release gerufen werden kann
+ if( rxMethod_i->getDeclaringClass()->equals( mxInterfaceClass ) )
+ {
+ // XInterface-Methoden sind hiermit einmal beruecksichtigt
+ bFoundXInterface = sal_True;
+
+ if( bXInterfaceIsInvalid )
+ {
+ pMethodTypes[ i ] = INVALID_METHOD;
+ continue;
+ }
+ else
+ {
+ if( aMethName != OUString( RTL_CONSTASCII_USTRINGPARAM("queryInterface")) )
+ {
+ rMethodConcept_i |= MethodConcept::DANGEROUS;
+ continue;
+ }
+ }
+ }
+ else if( rxMethod_i->getDeclaringClass()->equals( mxAggregationClass ) )
+ {
+ if( aMethName == OUString( RTL_CONSTASCII_USTRINGPARAM("setDelegator")) )
+ {
+ rMethodConcept_i |= MethodConcept::DANGEROUS;
+ continue;
+ }
+ }
+ else if( rxMethod_i->getDeclaringClass()->equals( mxElementAccessClass ) )
+ {
+ rMethodConcept_i |= ( NAMECONTAINER |
+ INDEXCONTAINER |
+ ENUMERATION );
+ }
+ else if( rxMethod_i->getDeclaringClass()->equals( mxNameContainerClass ) ||
+ rxMethod_i->getDeclaringClass()->equals( mxNameAccessClass ) )
+ {
+ rMethodConcept_i |= NAMECONTAINER;
+ }
+ else if( rxMethod_i->getDeclaringClass()->equals( mxIndexContainerClass ) ||
+ rxMethod_i->getDeclaringClass()->equals( mxIndexAccessClass ) )
+ {
+ rMethodConcept_i |= INDEXCONTAINER;
+ }
+ else if( rxMethod_i->getDeclaringClass()->equals( mxEnumerationAccessClass ) )
+ {
+ rMethodConcept_i |= ENUMERATION;
+ }
+
+ // Wenn der Name zu kurz ist, wird's sowieso nichts
+ if( aMethName.len() <= 3 )
+ continue;
+
+ // Ist es eine get-Methode?
+ aStartStr = aMethName.copy( 0, 3 );
+ if( aStartStr == OUString( RTL_CONSTASCII_USTRINGPARAM("get")) )
+ {
+ // Namen der potentiellen Property
+ aPropName = aMethName.copy( 3 );
+
+ // get-Methode darf keinen Parameter haben
+ Sequence< Reference<XIdlClass> > getParams = rxMethod_i->getParameterTypes();
+ if( getParams.getLength() > 0 )
+ {
+ continue;
+ }
+
+ // Haben wir den Namen schon?
+ IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
+ if( !( aIt == rPropNameMap.end() ) )
+ {
+ /* TODO
+ OSL_TRACE(
+ String( "Introspection: Property \"" ) +
+ OOUStringToString( aPropName, CHARSET_SYSTEM ) +
+ String( "\" found more than once" ) );
+ */
+ continue;
+ }
+
+ // Eine readonly-Property ist es jetzt mindestens schon
+ rMethodConcept_i |= PROPERTY;
+
+ pMethodTypes[i] = GETSET_METHOD;
+ Reference<XIdlClass> xGetRetType = rxMethod_i->getReturnType();
+
+ // Ist die PropertySequence gross genug?
+ pAccess->checkPropertyArraysSize
+ ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
+
+ // In eigenes Property-Array eintragen
+ Property& rProp = pAllPropArray[ rPropCount ];
+ rProp.Name = aPropName;
+ rProp.Handle = rPropCount;
+ rProp.Type = Type( xGetRetType->getTypeClass(), xGetRetType->getName() );
+ rProp.Attributes = READONLY;
+
+ // Neuer Eintrag in die Hashtable
+ rPropNameMap[ aPropName ] = rPropCount;
+
+ // Tabelle fuer XExactName pflegen
+ rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
+
+ // get-Methode merken
+ pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq1,
+ pInterfaces1, rPropCount );
+ pInterfaces1[ rPropCount ] = rxMethod_i;
+
+ // Art der Property merken
+ pMapTypeArray[ rPropCount ] = MAP_GETSET;
+ pPropertyConceptArray[ rPropCount ] = METHODS;
+ pAccess->mnMethodPropCount++;
+
+ // Passende set-Methode suchen
+ sal_Int32 k;
+ for( k = 0 ; k < nSourceMethodCount ; k++ )
+ {
+ // Methode ansprechen
+ const Reference<XIdlMethod>& rxMethod_k = pSourceMethods[k];
+
+ // Nur Methoden nehmen, die nicht schon zugeordnet sind
+ if( k == i || pMethodTypes[k] != STANDARD_METHOD )
+ continue;
+
+ // Name holen und auswerten
+ OUString aMethName2 = rxMethod_k->getName();
+ OUString aStartStr2 = aMethName2.copy( 0, 3 );
+ // ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
+ if( !( aStartStr2 == OUString( RTL_CONSTASCII_USTRINGPARAM("set")) ) )
+ continue;
+
+ // Ist es denn der gleiche Name?
+ OUString aPropName2 = aMethName2.copy( 3 );
+ // ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
+ if( !( aPropName == aPropName2 ) )
+ continue;
+
+ // set-Methode muss void returnen
+ Reference<XIdlClass> xSetRetType = rxMethod_k->getReturnType();
+ if( xSetRetType->getTypeClass() != TypeClass_VOID )
+ {
+ continue;
+ }
+
+ // set-Methode darf nur einen Parameter haben
+ Sequence< Reference<XIdlClass> > setParams = rxMethod_k->getParameterTypes();
+ sal_Int32 nParamCount = setParams.getLength();
+ if( nParamCount != 1 )
+ {
+ continue;
+ }
+
+ // Jetzt muss nur noch der return-Typ dem Parameter-Typ entsprechen
+ const Reference<XIdlClass>* pParamArray = setParams.getConstArray();
+ Reference<XIdlClass> xParamType = pParamArray[ 0 ];
+ if( xParamType->equals( xGetRetType ) )
+ {
+ pLocalMethodConcepts[ k ] = PROPERTY;
+
+ pMethodTypes[k] = GETSET_METHOD;
+
+ // ReadOnly-Flag wieder loschen
+ rProp.Attributes &= ~READONLY;
+
+ // set-Methode merken
+ pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq2,
+ pInterfaces2, rPropCount );
+ pInterfaces2[ rPropCount ] = rxMethod_k;
+ }
+ }
+
+ // Count pflegen
+ rPropCount++;
+ }
+
+ // Ist es eine addListener-Methode?
+ else if( aStartStr == OUString( RTL_CONSTASCII_USTRINGPARAM("add")) )
+ {
+ OUString aListenerStr( RTL_CONSTASCII_USTRINGPARAM("Listener" ) );
+
+ // Namen der potentiellen Property
+ sal_Int32 nStrLen = aMethName.len();
+ OUString aEndStr = aMethName.copy( nStrLen - aListenerStr.len() );
+
+ // Endet das Teil auf Listener?
+ // ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
+ if( !( aEndStr == aListenerStr ) )
+ continue;
+
+ // Welcher Listener?
+ OUString aListenerName = aMethName.copy( 3, nStrLen - aListenerStr.len() - 3 );
+
+ // TODO: Hier koennten noch genauere Pruefungen vorgenommen werden
+ // - Rueckgabe-Typ
+ // - Anzahl und Art der Parameter
+
+
+ // Passende remove-Methode suchen, sonst gilt's nicht
+ sal_Int32 k;
+ for( k = 0 ; k < nSourceMethodCount ; k++ )
+ {
+ // Methode ansprechen
+ const Reference<XIdlMethod>& rxMethod_k = pSourceMethods[k];
+
+ // Nur Methoden nehmen, die nicht schon zugeordnet sind
+ if( k == i || pMethodTypes[k] != STANDARD_METHOD )
+ continue;
+
+ // Name holen und auswerten
+ OUString aMethName2 = rxMethod_k->getName();
+ OUString aStartStr2 = aMethName2.copy( 0, 6 );
+ OUString aRemoveStr( RTL_CONSTASCII_USTRINGPARAM("remove" ) );
+ // ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
+ if( !( aStartStr2 == aRemoveStr ) )
+ continue;
+
+ // Ist es denn der gleiche Listener?
+ if( aMethName2.len() - aRemoveStr.len() <= aListenerStr.len() )
+ continue;
+ OUString aListenerName2 = aMethName2.copy
+ ( 6, aMethName2.len() - aRemoveStr.len() - aListenerStr.len() );
+ // ACHTUNG: Wegen SDL-Bug NICHT != bei OUString verwenden !!!
+ if( !( aListenerName == aListenerName2 ) )
+ continue;
+
+ // TODO: Hier koennten noch genauere Pruefungen vorgenommen werden
+ // - Rueckgabe-Typ
+ // - Anzahl und Art der Parameter
+
+
+ // Methoden sind als Listener-Schnittstelle erkannt
+ rMethodConcept_i |= LISTENER;
+ pLocalMethodConcepts[ k ] |= LISTENER;
+
+ pMethodTypes[i] = ADD_LISTENER_METHOD;
+ pMethodTypes[k] = REMOVE_LISTENER_METHOD;
+ nListenerCount++;
+ }
+ }
+ }
+
+
+ // Jetzt koennen noch SET-Methoden ohne zugehoerige GET-Methode existieren,
+ // diese muessen zu Write-Only-Properties gemachte werden.
+ for( i = 0 ; i < nSourceMethodCount ; i++ )
+ {
+ // Methode ansprechen
+ const Reference<XIdlMethod>& rxMethod_i = pSourceMethods[i];
+
+ // Nur Methoden nehmen, die nicht schon zugeordnet sind
+ if( pMethodTypes[i] != STANDARD_METHOD )
+ continue;
+
+ // Namen besorgen
+ aMethName = rxMethod_i->getName();
+
+ // Wenn der Name zu kurz ist, wird's sowieso nichts
+ if( aMethName.len() <= 3 )
+ continue;
+
+ // Ist es eine set-Methode ohne zugehoerige get-Methode?
+ aStartStr = aMethName.copy( 0, 3 );
+ if( aStartStr == OUString( RTL_CONSTASCII_USTRINGPARAM("set")) )
+ {
+ // Namen der potentiellen Property
+ aPropName = aMethName.copy( 3 );
+
+ // set-Methode muss void returnen
+ Reference<XIdlClass> xSetRetType = rxMethod_i->getReturnType();
+ if( xSetRetType->getTypeClass() != TypeClass_VOID )
+ {
+ continue;
+ }
+
+ // set-Methode darf nur einen Parameter haben
+ Sequence< Reference<XIdlClass> > setParams = rxMethod_i->getParameterTypes();
+ sal_Int32 nParamCount = setParams.getLength();
+ if( nParamCount != 1 )
+ {
+ continue;
+ }
+
+ // Haben wir den Namen schon?
+ IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
+ if( !( aIt == rPropNameMap.end() ) )
+ {
+ /* TODO:
+ OSL_TRACE(
+ String( "Introspection: Property \"" ) +
+ OOUStringToString( aPropName, CHARSET_SYSTEM ) +
+ String( "\" found more than once" ) );
+ */
+ continue;
+ }
+
+ // Alles klar, es ist eine Write-Only-Property
+ pLocalMethodConcepts[ i ] = PROPERTY;
+
+ pMethodTypes[i] = GETSET_METHOD;
+ Reference<XIdlClass> xGetRetType = setParams.getConstArray()[0];
+
+ // Ist die PropertySequence gross genug?
+ pAccess->checkPropertyArraysSize
+ ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
+
+ // In eigenes Property-Array eintragen
+ Property& rProp = pAllPropArray[ rPropCount ];
+ rProp.Name = aPropName;
+ rProp.Handle = rPropCount;
+ rProp.Type = Type( xGetRetType->getTypeClass(), xGetRetType->getName() );
+ rProp.Attributes = 0; // PROPERTY_WRITEONLY ???
+
+ // Neuer Eintrag in die Hashtable
+ rPropNameMap[ aPropName ] = rPropCount;
+
+ // Tabelle fuer XExactName pflegen
+ rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
+
+ // set-Methode merken
+ pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq2,
+ pInterfaces2, rPropCount );
+ pInterfaces2[ rPropCount ] = rxMethod_i;
+
+ // Art der Property merken
+ pMapTypeArray[ rPropCount ] = MAP_SETONLY;
+ pPropertyConceptArray[ rPropCount ] = METHODS;
+ pAccess->mnMethodPropCount++;
+
+ // Count pflegen
+ rPropCount++;
+ }
+ }
+
+
+ //********************************************************************
+
+ // 4. Methoden in die Gesamt-Sequence uebernehmen
+
+ // Wieviele Methoden muessen in die Method-Sequence?
+ sal_Int32 nExportedMethodCount = 0L;
+ sal_Int32 nSupportedListenerCount = 0L;
+ for( i = 0 ; i < nSourceMethodCount ; i++ )
+ {
+ if( pMethodTypes[ i ] != INVALID_METHOD )
+ {
+ nExportedMethodCount++;
+ }
+ if( pMethodTypes[ i ] == ADD_LISTENER_METHOD )
+ {
+ nSupportedListenerCount++;
+ }
+ }
+
+ // Sequences im Access-Objekt entsprechend aufbohren
+ pAccess->maAllMethodSeq.realloc( nExportedMethodCount + iAllExportedMethod );
+ pAccess->maMethodConceptSeq.realloc( nExportedMethodCount + iAllExportedMethod );
+ pAccess->maSupportedListenerSeq.realloc( nSupportedListenerCount + iAllSupportedListener );
+
+ // Methoden reinschreiben
+ Reference<XIdlMethod>* pDestMethods = pAccess->maAllMethodSeq.getArray();
+ sal_Int32* pMethodConceptArray = pAccess->maMethodConceptSeq.getArray();
+ Type* pListenerClassRefs = pAccess->maSupportedListenerSeq.getArray();
+ for( i = 0 ; i < nSourceMethodCount ; i++ )
+ {
+ if( pMethodTypes[ i ] != INVALID_METHOD )
+ {
+ // Methode ansprechen
+ const Reference<XIdlMethod>& rxMethod = pSourceMethods[i];
+
+ // Namen in Hashtable eintragen, wenn nicht schon bekannt
+ OUString aMethName = rxMethod->getName();
+ IntrospectionNameMap::iterator aIt = rMethodNameMap.find( aMethName );
+ if( !( aIt == rMethodNameMap.end() ) )
+ {
+ /* TODO:
+ OSL_TRACE( String( "Introspection: Method \"" ) +
+ OOUStringToString( aMethName, CHARSET_SYSTEM ) +
+ String( "\" found more than once" ) );
+ */
+ continue;
+ }
+
+ // Eintragen
+ rMethodNameMap[ aMethName ] = iAllExportedMethod;
+
+ // Tabelle fuer XExactName pflegen
+ rLowerToExactNameMap[ toLower( aMethName ) ] = aMethName;
+
+ pDestMethods[ iAllExportedMethod ] = rxMethod;
+
+ // Wenn kein Concept gesetzt wurde, ist die Methode "normal"
+ sal_Int32& rMethodConcept_i = pLocalMethodConcepts[ i ];
+ if( !rMethodConcept_i )
+ rMethodConcept_i = MethodConcept_NORMAL_IMPL;
+ pMethodConceptArray[ iAllExportedMethod ] = rMethodConcept_i;
+ iAllExportedMethod++;
+ }
+ if( pMethodTypes[ i ] == ADD_LISTENER_METHOD )
+ {
+ // Klasse des Listeners ermitteln
+ const Reference<XIdlMethod>& rxMethod = pSourceMethods[i];
+
+ // void als Default-Klasse eintragen
+ Reference<XIdlClass> xListenerClass = TypeToIdlClass( getCppuVoidType(), m_xSMgr );
+ // ALT: Reference<XIdlClass> xListenerClass = Void_getReflection()->getIdlClass();
+
+ // 1. Moeglichkeit: Parameter nach einer Listener-Klasse durchsuchen
+ // Nachteil: Superklassen muessen rekursiv durchsucht werden
+ Sequence< Reference<XIdlClass> > aParams = rxMethod->getParameterTypes();
+ const Reference<XIdlClass>* pParamArray = aParams.getConstArray();
+
+ Reference<XIdlClass> xEventListenerClass = TypeToIdlClass( getCppuType( (Reference<XEventListener>*) NULL ), m_xSMgr );
+ // ALT: Reference<XIdlClass> xEventListenerClass = XEventListener_getReflection()->getIdlClass();
+ sal_Int32 nParamCount = aParams.getLength();
+ sal_Int32 k;
+ for( k = 0 ; k < nParamCount ; k++ )
+ {
+ const Reference<XIdlClass>& rxClass = pParamArray[k];
+
+ // Sind wir von einem Listener abgeleitet?
+ if( rxClass->equals( xEventListenerClass ) ||
+ isDerivedFrom( rxClass, xEventListenerClass ) )
+ {
+ xListenerClass = rxClass;
+ break;
+ }
+ }
+
+ // 2. Moeglichkeit: Namen der Methode auswerden
+ // Nachteil: geht nicht bei Test-Listenern, die es nicht gibt
+ //aMethName = rxMethod->getName();
+ //aListenerName = aMethName.Copy( 3, aMethName.Len()-8-3 );
+ //Reference<XIdlClass> xListenerClass = reflection->forName( aListenerName );
+ Type aListenerType( TypeClass_INTERFACE, xListenerClass->getName() );
+ pListenerClassRefs[ iAllSupportedListener ] = aListenerType;
+ iAllSupportedListener++;
+ }
+ }
+
+ // Wenn in diesem Durchlauf XInterface-Methoden
+ // dabei waren, diese zukuenftig ignorieren
+ if( bFoundXInterface )
+ bXInterfaceIsInvalid = sal_True;
+
+ delete pMethodTypes;
+ delete pLocalMethodConcepts;
+ }
+
+ // Super-Klasse(n) vorhanden? Dann dort fortsetzen
+ Sequence< Reference<XIdlClass> > aSuperClassSeq = xImplClass->getSuperclasses();
+
+ // Zur Zeit wird nur von einer Superklasse ausgegangen
+ if( aSuperClassSeq.getLength() >= 1 )
+ {
+ xImplClass = aSuperClassSeq.getConstArray()[0];
+ OSL_ENSHURE( xImplClass.is(), "super class null" );
+ }
+ else
+ {
+ xImplClass = NULL;
+ }
+ }
+ }
+
+ // Anzahl der exportierten Methoden uebernehmen und Sequences anpassen
+ // (kann abweichen, weil doppelte Methoden erst nach der Ermittlung
+ // von nExportedMethodCount herausgeworfen werden)
+ sal_Int32& rMethCount = pAccess->mnMethCount;
+ rMethCount = iAllExportedMethod;
+ pAccess->maAllMethodSeq.realloc( rMethCount );
+ pAccess->maMethodConceptSeq.realloc( rMethCount );
+
+ // Groesse der Property-Sequences anpassen
+ pAccess->maAllPropertySeq.realloc( rPropCount );
+ pAccess->maPropertyConceptSeq.realloc( rPropCount );
+ pAccess->maMapTypeSeq.realloc( rPropCount );
+
+ // Ende der Schleife ueber alle vom ClassProvider angegebenen Klassen
+ }
+ }
+ // Bei structs Fields als Properties registrieren
+ else //if( eType == TypeClass_STRUCT )
+ {
+ // Ist es ein Interface oder eine struct?
+ //Reference<XIdlClass> xClassRef = aToInspectObj.getReflection()->getIdlClass();
+ Reference<XIdlClass> xClassRef = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr );
+ if( !xClassRef.is() )
+ {
+ OSL_ENSHURE( sal_False, "Can't get XIdlClass from Reflection" );
+ return pAccess;
+ }
+
+ // Felder holen
+ Sequence< Reference<XIdlField> > fields = xClassRef->getFields();
+ const Reference<XIdlField>* pFields = fields.getConstArray();
+ sal_Int32 nLen = fields.getLength();
+
+ for( i = 0 ; i < nLen ; i++ )
+ {
+ Reference<XIdlField> xField = pFields[i];
+ Reference<XIdlClass> xPropType = xField->getType();
+ OUString aPropName = xField->getName();
+
+ // Ist die PropertySequence gross genug?
+ pAccess->checkPropertyArraysSize
+ ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
+
+ // In eigenes Property-Array eintragen
+ Property& rProp = pAllPropArray[ rPropCount ];
+ rProp.Name = aPropName;
+ rProp.Handle = rPropCount;
+ rProp.Type = Type( xPropType->getTypeClass(), xPropType->getName() );
+ FieldAccessMode eAccessMode = xField->getAccessMode();
+ rProp.Attributes = (eAccessMode == FieldAccessMode_READONLY ||
+ eAccessMode == FieldAccessMode_CONST)
+ ? READONLY : 0;
+
+ //FieldAccessMode eAccessMode = xField->getAccessMode();
+ //rProp.Attributes = (eAccessMode == FieldAccessMode::READONLY || eAccessMode == CONST)
+ //? PropertyAttribute::READONLY : 0;
+
+ // Namen in Hashtable eintragen
+ rPropNameMap[ aPropName ] = rPropCount;
+
+ // Tabelle fuer XExactName pflegen
+ rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
+
+ // Field merken
+ pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq1,
+ pInterfaces1, rPropCount );
+ pInterfaces1[ rPropCount ] = xField;
+
+ // Art der Property merken
+ pMapTypeArray[ rPropCount ] = MAP_FIELD;
+ pPropertyConceptArray[ rPropCount ] = ATTRIBUTES;
+ pAccess->mnAttributePropCount++;
+
+ // Count pflegen
+ rPropCount++;
+ }
+ }
+
+ // Property-Sequence auf die richtige Laenge bringen
+ pAccess->maAllPropertySeq.realloc( pAccess->mnPropCount );
+
+ return pAccess;
+}
+
+//*************************************************************************
+Reference< XInterface > SAL_CALL ImplIntrospection_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr )
+ throw( RuntimeException )
+{
+ Reference< XInterface > xService = (OWeakObject*)(OComponentHelper*)new ImplIntrospection( rSMgr );
+ return xService;
+}
+
+}
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
+
+ const Sequence< OUString > & rSNL =
+ stoc_inspect::ImplIntrospection::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ stoc_inspect::ImplIntrospection_CreateInstance,
+ stoc_inspect::ImplIntrospection::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
diff --git a/stoc/source/inspect/makefile.mk b/stoc/source/inspect/makefile.mk
new file mode 100644
index 000000000000..fcc65bdf8748
--- /dev/null
+++ b/stoc/source/inspect/makefile.mk
@@ -0,0 +1,106 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= insp
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/introspection.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/stoc/source/invocation/inv.xml b/stoc/source/invocation/inv.xml
new file mode 100644
index 000000000000..b8a30a05af05
--- /dev/null
+++ b/stoc/source/invocation/inv.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Daniel Boelzle </Author>
+
+<Name> com.sun.star.comp.stoc.Invocation </Name>
+
+<Description>
+You can construct Invocation objects through this factory service.
+Invoke createInstanceWithArguments() of XSingleServiceFactory
+to create an Invocation adapter for your object;
+invoking createInstance() will fail.
+Instances implement XInvocation to invoke methods and set/get properties at an object
+which corresponds with the object which implements this interface.
+
+There are two ways to get information about this object. First you
+can get the implemented method with XInvocation::getMethodNames()
+and the properties with XInvocation::getPropertyNames().
+Second you can get, if provided, all information about the methods and the
+properties with XInvocation::getIntrospection().
+Container access is available through the XIndexContainer,
+XNameContainer and XEnumerationContainer
+(use XInterface::queryInterface).
+</Description>
+
+<ModuleName> inv </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> C++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService>
+com.sun.star.script.Invocation
+</SupportedService>
+
+<ServiceDependency>com.sun.star.script.Converter</ServiceDependency>
+<ServiceDependency>com.sun.star.beans.Introspection</ServiceDependency>
+<ServiceDependency>com.sun.star.reflection.CoreReflection</ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> vos </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal </RuntimeModuleDependency>
+
+<Type> com.sun.star.script.XInvocation </Type>
+<Type> com.sun.star.script.XInvocation2 </Type>
+<Type> com.sun.star.script.InvocationInfo </Type>
+<Type> com.sun.star.script.MemberType </Type>
+<Type> com.sun.star.script.XTypeConverter </Type>
+<Type> com.sun.star.script.FailReason </Type>
+<Type> com.sun.star.beans.XIntrospection </Type>
+<Type> com.sun.star.beans.XIntrospectionAccess </Type>
+<Type> com.sun.star.beans.XPropertySet </Type>
+<Type> com.sun.star.beans.XFastPropertySet </Type>
+<Type> com.sun.star.beans.XMaterialHolder </Type>
+<Type> com.sun.star.beans.XExactName </Type>
+<Type> com.sun.star.beans.PropertyAttribute </Type>
+<Type> com.sun.star.beans.PropertyConcept </Type>
+<Type> com.sun.star.beans.MethodConcept </Type>
+<Type> com.sun.star.lang.XEventListener </Type>
+<Type> com.sun.star.lang.XInitialization </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.container.XEnumerationAccess </Type>
+<Type> com.sun.star.container.XNameContainer </Type>
+<Type> com.sun.star.container.XIndexContainer </Type>
+<Type> com.sun.star.reflection.XIdlReflection </Type>
+<Type> com.sun.star.reflection.XIdlClassProvider </Type>
+<Type> com.sun.star.reflection.XIdlClass </Type>
+<Type> com.sun.star.reflection.XIdlArray </Type>
+<Type> com.sun.star.reflection.FieldAccessMode </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx
new file mode 100644
index 000000000000..fa065dc4331f
--- /dev/null
+++ b/stoc/source/invocation/invocation.cxx
@@ -0,0 +1,1282 @@
+/*************************************************************************
+ *
+ * $RCSfile: invocation.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#include <cppuhelper/typeprovider.hxx>
+
+#include <com/sun/star/script/FailReason.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/script/XInvocation2.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/beans/XExactName.hpp>
+#include <com/sun/star/beans/XMaterialHolder.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/MethodConcept.hpp>
+#include <com/sun/star/beans/PropertyConcept.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+#include <rtl/ustrbuf.hxx>
+#include <rtl/strbuf.hxx>
+
+#include <stdlib.h>
+#include <search.h>
+
+
+#define SERVICE_NAME "com.sun.star.script.Invocation"
+#define IMPL_NAME "com.sun.star.comp.stoc.Invocation"
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::script;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::container;
+using namespace cppu;
+using namespace rtl;
+using namespace osl;
+
+
+namespace stoc_inv
+{
+
+// TODO: Zentral implementieren
+inline Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XIdlReflection > & xRefl )
+{
+ return xRefl->forName( rType.getTypeName() );
+}
+
+
+//==================================================================================================
+class Invocation_Impl
+ : public OWeakObject
+ , public XInvocation2
+ , public XNameContainer
+ , public XIndexContainer
+ , public XEnumerationAccess
+ , public XExactName
+ , public XMaterialHolder
+ , public XTypeProvider
+{
+public:
+ Invocation_Impl( const Any & rAdapted, const Reference<XTypeConverter> &,
+ const Reference<XIntrospection> &,
+ const Reference<XIdlReflection> & );
+
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type & aType) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw() { OWeakObject::release(); }
+ //void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+
+ // XTypeProvider
+ virtual Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( )
+ throw(RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId( )
+ throw( RuntimeException);
+
+ // Methoden von XMaterialHolder
+ virtual Any SAL_CALL getMaterial(void);
+
+ // ? XTool
+ virtual void SAL_CALL setMaterial( const Any& rMaterial );
+
+ // XInvocation
+ virtual Reference<XIntrospectionAccess> SAL_CALL getIntrospection(void) throw( RuntimeException );
+ virtual Any SAL_CALL invoke(const OUString& FunctionName, const Sequence< Any >& Params, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam)
+ throw( IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException );
+ virtual void SAL_CALL setValue(const OUString& PropertyName, const Any& Value)
+ throw( UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException );
+ virtual Any SAL_CALL getValue(const OUString& PropertyName)
+ throw( UnknownPropertyException, RuntimeException );
+ virtual sal_Bool SAL_CALL hasMethod(const OUString& Name) throw( RuntimeException );
+ virtual sal_Bool SAL_CALL hasProperty(const OUString& Name) throw( RuntimeException );
+
+ // XInvocation2
+ virtual Sequence< OUString > SAL_CALL getMemberNames( )
+ throw( RuntimeException );
+ virtual Sequence< InvocationInfo > SAL_CALL getInfo( )
+ throw( RuntimeException );
+ virtual InvocationInfo SAL_CALL getInfoForName( const OUString& aName, sal_Bool bExact )
+ throw( IllegalArgumentException, RuntimeException );
+
+ // All Access and Container methods are not thread save
+ // XElementAccess
+ virtual Type SAL_CALL getElementType(void) throw( RuntimeException )
+ { return _xElementAccess->getElementType(); }
+
+ virtual sal_Bool SAL_CALL hasElements(void) throw( RuntimeException )
+ { return _xElementAccess->hasElements(); }
+
+ // XNameContainer
+ virtual void SAL_CALL insertByName( const OUString& Name, const Any& Element )
+ throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException )
+ { _xNameContainer->insertByName( Name, Element ); }
+
+ virtual void SAL_CALL replaceByName( const OUString& Name, const Any& Element )
+ throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException )
+ { _xNameContainer->replaceByName( Name, Element ); }
+
+ virtual void SAL_CALL removeByName( const OUString& Name )
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException )
+ { _xNameContainer->removeByName( Name ); }
+
+ // XNameAccess
+ virtual Any SAL_CALL getByName( const OUString& Name )
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException )
+ { return _xNameAccess->getByName( Name ); }
+
+ virtual Sequence<OUString> SAL_CALL getElementNames(void) throw( RuntimeException )
+ { return _xNameAccess->getElementNames(); }
+
+ virtual sal_Bool SAL_CALL hasByName( const OUString& Name ) throw( RuntimeException )
+ { return _xNameAccess->hasByName( Name ); }
+
+ // XIndexContainer
+ virtual void SAL_CALL insertByIndex( sal_Int32 Index, const Any& Element )
+ throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+ { _xIndexContainer->insertByIndex( Index, Element ); }
+
+ virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const Any& Element )
+ throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+ { _xIndexContainer->replaceByIndex( Index, Element ); }
+
+ virtual void SAL_CALL removeByIndex( sal_Int32 Index )
+ throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+ { _xIndexContainer->removeByIndex( Index ); }
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount(void) throw( RuntimeException )
+ { return _xIndexAccess->getCount(); }
+
+ virtual Any SAL_CALL getByIndex( sal_Int32 Index )
+ throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+ { return _xIndexAccess->getByIndex( Index ); }
+
+ // XEnumerationAccess
+ virtual Reference<XEnumeration> SAL_CALL createEnumeration(void) throw( RuntimeException )
+ { return _xEnumerationAccess->createEnumeration(); }
+
+ // XExactName
+ virtual OUString SAL_CALL getExactName( const OUString& rApproximateName ) throw( RuntimeException );
+
+
+ //=====================================================================================================
+private:
+ void getInfoSequenceImpl( Sequence< OUString >* pStringSeq, Sequence< InvocationInfo >* pInfoSeq );
+ void fillInfoForNameAccess( InvocationInfo& rInfo, const OUString& aName );
+ void fillInfoForProperty( InvocationInfo& rInfo, const Property& rProp );
+ void fillInfoForMethod( InvocationInfo& rInfo, const Reference< XIdlMethod > xMethod );
+
+ Reference<XTypeConverter> xTypeConverter;
+ Reference<XIntrospection> xIntrospection;
+ Reference<XIdlReflection> xCoreReflection;
+
+ Any _aMaterial;
+ // _xDirect and (_xIntrospectionAccess, xPropertySet) are exclusive
+ Reference<XInvocation> _xDirect;
+ Reference<XInvocation2> _xDirect2;
+ Reference<XPropertySet> _xPropertySet;
+ Reference<XIntrospectionAccess> _xIntrospectionAccess;
+
+ // supplied Interfaces
+ Reference<XNameContainer> _xNameContainer;
+ Reference<XNameAccess> _xNameAccess;
+ Reference<XIndexContainer> _xIndexContainer;
+ Reference<XIndexAccess> _xIndexAccess;
+ Reference<XEnumerationAccess> _xEnumerationAccess;
+ Reference<XElementAccess> _xElementAccess;
+
+ //
+ Reference<XExactName> _xENDirect, _xENIntrospection, _xENNameAccess;
+};
+
+
+//==================================================================================================
+//==================================================================================================
+//==================================================================================================
+
+//--------------------------------------------------------------------------------------------------
+Invocation_Impl::Invocation_Impl
+(
+ const Any & rAdapted,
+ const Reference<XTypeConverter> & rTC,
+ const Reference<XIntrospection> & rI,
+ const Reference<XIdlReflection> & rCR
+)
+ : xIntrospection( rI )
+ , xTypeConverter( rTC )
+ , xCoreReflection( rCR )
+{
+ setMaterial( rAdapted );
+}
+
+//##################################################################################################
+//### INTERFACE IMPLEMENTATIONS ####################################################################
+//##################################################################################################
+
+
+Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType )
+ throw( RuntimeException )
+{
+ // TODO: Aendern, so sehr ineffektiv,
+
+ // PropertySet-Implementation
+ Any a = ::cppu::queryInterface( aType,
+ SAL_STATIC_CAST(XInvocation*, this),
+ SAL_STATIC_CAST(XMaterialHolder*, this),
+ SAL_STATIC_CAST(XTypeProvider *,this) );
+ if( a.hasValue() )
+ {
+ return a;
+ }
+
+ if( aType == getCppuType( (Reference<XExactName>*) NULL ) )
+ {
+ // Ivocation does not support XExactName, if direct object supports
+ // XInvocation, but not XExactName.
+ if ((_xDirect.is() && _xENDirect.is()) ||
+ (!_xDirect.is() && (_xENIntrospection.is() || _xENNameAccess.is())))
+ {
+ return cppu::queryInterface( aType, SAL_STATIC_CAST(XExactName*, this) );
+ }
+ }
+ else if ( aType == getCppuType( (Reference<XNameContainer>*) NULL ) )
+ {
+ if( _xNameContainer.is() )
+ return cppu::queryInterface( aType, SAL_STATIC_CAST(XNameContainer*, this) );
+ }
+ else if ( aType == getCppuType( (Reference<XNameAccess>*) NULL ) )
+ {
+ if( _xNameAccess.is() )
+ return cppu::queryInterface( aType, SAL_STATIC_CAST(XNameAccess*, this) );
+ }
+ else if ( aType == getCppuType( (Reference<XIndexContainer>*) NULL ) )
+ {
+ if (_xIndexContainer.is())
+ return cppu::queryInterface( aType, SAL_STATIC_CAST(XIndexContainer*, this) );
+ }
+ else if ( aType == getCppuType( (Reference<XIndexAccess>*) NULL ) )
+ {
+ if (_xIndexAccess.is())
+ return cppu::queryInterface( aType, SAL_STATIC_CAST(XIndexAccess*, this) );
+ }
+ else if ( aType == getCppuType( (Reference<XEnumerationAccess>*) NULL ) )
+ {
+ if (_xEnumerationAccess.is())
+ return cppu::queryInterface( aType , SAL_STATIC_CAST(XEnumerationAccess*, this) );
+ }
+ else if ( aType == getCppuType( (Reference<XElementAccess>*) NULL ) )
+ {
+ if (_xElementAccess.is())
+ {
+ return ::cppu::queryInterface
+ ( aType , SAL_STATIC_CAST(XElementAccess*, SAL_STATIC_CAST(XNameContainer*, this) ) );
+ }
+ }
+ else if ( aType == getCppuType( (Reference<XInvocation2>*) NULL ) )
+ {
+ // Invocation does not support XInvocation2, if direct object supports
+ // XInvocation, but not XInvocation2.
+ if ( ( _xDirect.is() && _xDirect2.is()) ||
+ (!_xDirect.is() && _xIntrospectionAccess.is() ) )
+ {
+ return cppu::queryInterface( aType, SAL_STATIC_CAST(XInvocation2*, this) );
+ }
+ }
+
+ return OWeakObject::queryInterface( aType );
+}
+
+
+//--------------------------------------------------------------------------------------------------
+Any Invocation_Impl::getMaterial(void)
+{
+ // AB, 12.2.1999 Sicherstellen, dass das Material wenn moeglich
+ // aus der direkten Invocation bzw. von der Introspection geholt
+ // wird, da sonst Structs nicht korrekt behandelt werden
+ Reference<XMaterialHolder> xMaterialHolder;
+ if( _xDirect.is() )
+ {
+ xMaterialHolder = Reference<XMaterialHolder>::query( _xDirect );
+ //_xDirect->queryInterface( XMaterialHolder::getSmartUik(), xMaterialHolder );
+ }
+ else if( _xIntrospectionAccess.is() )
+ {
+ xMaterialHolder = Reference<XMaterialHolder>::query( _xIntrospectionAccess );
+ //_xIntrospectionAccess->queryInterface( XMaterialHolder::getSmartUik(), xMaterialHolder );
+ }
+ if( xMaterialHolder.is() )
+ {
+ return xMaterialHolder->getMaterial();
+ }
+ return _aMaterial;
+}
+
+//--------------------------------------------------------------------------------------------------
+void Invocation_Impl::setMaterial( const Any& rMaterial )
+{
+ // set the material first and only once
+ Reference<XInterface> xObj;
+
+ if (rMaterial.getValueType().getTypeClass() == TypeClass_INTERFACE)
+ xObj = *(Reference<XInterface>*)rMaterial.getValue();
+ _aMaterial = rMaterial;
+
+ // Ersteinmal alles ausserhalb des guards machen
+ _xDirect = Reference<XInvocation>::query( xObj );
+
+ if( _xDirect.is() )
+ {
+ // Objekt direkt befragen
+ _xElementAccess = Reference<XElementAccess>::query( _xDirect );
+ _xEnumerationAccess = Reference<XEnumerationAccess>::query( _xDirect );
+ _xIndexAccess = Reference<XIndexAccess>::query( _xDirect );
+ _xIndexContainer = Reference<XIndexContainer>::query( _xDirect );
+ _xNameAccess = Reference<XNameAccess>::query( _xDirect );
+ _xNameContainer = Reference<XNameContainer>::query( _xDirect );
+ _xENDirect = Reference<XExactName>::query( _xDirect );
+ _xDirect2 = Reference<XInvocation2>::query( _xDirect );
+
+ // only once!!!
+ //_xIntrospectionAccess = XIntrospectionAccessRef();
+ //_xPropertySet = XPropertySetRef();
+ }
+ else
+ {
+ // Invocation ueber die Introspection machen
+ if (xIntrospection.is())
+ {
+ _xIntrospectionAccess = xIntrospection->inspect( _aMaterial );
+ if( _xIntrospectionAccess.is() )
+ {
+
+ _xElementAccess = Reference<XElementAccess>::query(
+ _xIntrospectionAccess->queryAdapter(
+ getCppuType( (Reference<XElementAccess>*) NULL ) ) );
+
+ _xEnumerationAccess = Reference<XEnumerationAccess>::query(
+ _xIntrospectionAccess->queryAdapter(
+ getCppuType( (Reference<XEnumerationAccess>*) NULL )) );
+
+ _xIndexAccess = Reference<XIndexAccess>::query(
+ _xIntrospectionAccess->queryAdapter(
+ getCppuType( (Reference<XIndexAccess>*) NULL ) ) );
+
+ _xIndexContainer = Reference<XIndexContainer>::query(
+ _xIntrospectionAccess->queryAdapter(
+ getCppuType( (Reference<XIndexContainer>*) NULL ) ) );
+
+ _xNameAccess = Reference<XNameAccess>::query(
+ _xIntrospectionAccess->queryAdapter(
+ getCppuType( (Reference<XNameAccess>*) NULL ) ) );
+
+ _xNameContainer = Reference<XNameContainer>::query(
+ _xIntrospectionAccess->queryAdapter(
+ getCppuType( (Reference<XNameContainer>*) NULL ) ) );
+
+ _xPropertySet = Reference<XPropertySet>::query(
+ _xIntrospectionAccess->queryAdapter(
+ getCppuType( (Reference<XPropertySet>*) NULL )) );
+
+ _xENIntrospection = Reference<XExactName>::query( _xIntrospectionAccess );
+ if (_xNameAccess.is())
+ _xENNameAccess = Reference<XExactName>::query( _xNameAccess );
+ }
+ }
+ /* only once !!!
+ _xDirect = XInvocationRef();
+ if( !_xIntrospectionAccess.is() )
+ {
+ // reset
+ _xElementAccess = XElementAccessRef();
+ _xEnumerationAccess = XEnumerationAccessRef();
+ _xIndexAccess = XIndexAccessRef();
+ _xIndexContainer = XIndexContainerRef();
+ _xNameAccess = XNameAccessRef();
+ _xNameContainer = XNameContainerRef();
+ _xPropertySet = XPropertySetRef();
+ }
+ */
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+OUString Invocation_Impl::getExactName( const OUString& rApproximateName )
+ throw( RuntimeException )
+{
+ if (_xENDirect.is())
+ return _xENDirect->getExactName( rApproximateName );
+
+ OUString aRet;
+ if (_xENIntrospection.is())
+ aRet = _xENIntrospection->getExactName( rApproximateName );
+ if (!aRet.len() && _xENNameAccess.is())
+ aRet = _xENNameAccess->getExactName( rApproximateName );
+ return aRet;
+}
+
+//--------------------------------------------------------------------------------------------------
+Reference<XIntrospectionAccess> Invocation_Impl::getIntrospection(void)
+ throw( RuntimeException )
+{
+ if( _xDirect.is() )
+ return _xDirect->getIntrospection();
+ else
+ return _xIntrospectionAccess;
+}
+
+//--------------------------------------------------------------------------------------------------
+sal_Bool Invocation_Impl::hasMethod( const OUString& Name )
+ throw( RuntimeException )
+{
+ if (_xDirect.is())
+ return _xDirect->hasMethod( Name );
+ if( _xIntrospectionAccess.is() )
+ return _xIntrospectionAccess->hasMethod( Name, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
+ return sal_False;
+}
+
+//--------------------------------------------------------------------------------------------------
+sal_Bool Invocation_Impl::hasProperty( const OUString& Name )
+ throw( RuntimeException )
+{
+ if (_xDirect.is())
+ return _xDirect->hasProperty( Name );
+ // PropertySet
+ if( _xIntrospectionAccess.is()
+ && _xIntrospectionAccess->hasProperty( Name, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
+ return sal_True;
+ // NameAccess
+ if( _xNameAccess.is() )
+ return _xNameAccess->hasByName( Name );
+ return sal_False;
+}
+
+//--------------------------------------------------------------------------------------------------
+Any Invocation_Impl::getValue( const OUString& PropertyName )
+ throw( UnknownPropertyException, RuntimeException )
+{
+ if (_xDirect.is())
+ return _xDirect->getValue( PropertyName );
+ // PropertySet
+ if( _xIntrospectionAccess.is() && _xPropertySet.is()
+ && _xIntrospectionAccess->hasProperty( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
+ {
+ return _xPropertySet->getPropertyValue( PropertyName );
+ }
+ // NameAccess
+ if( _xNameAccess.is() && _xNameAccess->hasByName( PropertyName ) )
+ return _xNameAccess->getByName( PropertyName );
+
+ throw UnknownPropertyException();
+ return Any(); // dummy
+}
+
+//--------------------------------------------------------------------------------------------------
+void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
+ throw( UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException )
+{
+ if (_xDirect.is())
+ _xDirect->setValue( PropertyName, Value );
+ else
+ {
+ // Properties
+
+ if( _xIntrospectionAccess.is() && _xPropertySet.is()
+ && _xIntrospectionAccess->hasProperty( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
+ {
+ Property aProp = _xIntrospectionAccess->getProperty( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
+ Reference < XIdlClass > r = TypeToIdlClass( aProp.Type, xCoreReflection );
+ if( r->isAssignableFrom(
+ TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
+ _xPropertySet->setPropertyValue( PropertyName, Value );
+ else if( xTypeConverter.is() )
+ _xPropertySet->setPropertyValue( PropertyName, xTypeConverter->convertTo( Value, aProp.Type ) );
+ else
+ throw CannotConvertException();
+ }
+ // NameContainer
+ else
+
+ if( _xNameContainer.is() )
+ {
+ Any aConv;
+ Reference < XIdlClass > r = TypeToIdlClass( _xNameContainer->getElementType(), xCoreReflection );
+ if( r->isAssignableFrom(TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
+ aConv = Value;
+ else if( xTypeConverter.is() )
+ aConv = xTypeConverter->convertTo( Value, _xNameContainer->getElementType() );
+ else
+ throw CannotConvertException();
+
+ // bei Vorhandensein ersetzen, ansonsten einfuegen
+ if (_xNameContainer->hasByName( PropertyName ))
+ _xNameContainer->replaceByName( PropertyName, aConv );
+ else
+ _xNameContainer->insertByName( PropertyName, aConv );
+ }
+ else
+ throw UnknownPropertyException();
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& InParams,
+ Sequence<sal_Int16>& OutIndizes, Sequence<Any>& OutParams )
+ throw( IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException )
+{
+ if (_xDirect.is())
+ return _xDirect->invoke( FunctionName, InParams, OutIndizes, OutParams );
+
+ if (_xIntrospectionAccess.is())
+ {
+ // throw NoSuchMethodException if not exist
+ Reference<XIdlMethod> xMethod = _xIntrospectionAccess->getMethod( FunctionName, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
+
+ // ParameterInfos
+ Sequence<ParamInfo> aFParams = xMethod->getParameterInfos();
+ const ParamInfo* pFParams = aFParams.getConstArray();
+ sal_uInt32 nFParamsLen = aFParams.getLength();
+
+ // IN Parameter
+ const Any* pInParams = InParams.getConstArray();
+ sal_uInt32 nInParamsLen = InParams.getLength();
+ sal_uInt32 nInIndex = 0;
+
+ // Introspection Invoke Parameter
+ Sequence<Any> aInvokeParams( nFParamsLen );
+ Any* pInvokeParams = aInvokeParams.getArray();
+
+ // OUT Indizes
+ OutIndizes.realloc( nFParamsLen );
+ sal_Int16* pOutIndizes = OutIndizes.getArray();
+ sal_uInt32 nOutIndex = 0;
+
+ try
+ {
+ for ( sal_uInt32 nPos = 0; nPos < nFParamsLen; ++nPos )
+ {
+ const ParamInfo& rFParam = pFParams[nPos];
+ const Reference<XIdlClass>& rDestType = rFParam.aType;
+
+ // is IN/INOUT parameter?
+ if (rFParam.aMode != ParamMode_OUT)
+ {
+ // IN parameter available?
+ if (nInIndex >= nInParamsLen)
+ throw CannotConvertException();
+ //TODO: Parameter? throw( CannotConvertException( OUString( RTL_CONSTASCII_USTRINGPARAM(not enough IN parameters available!")), Reference<XInterface>(), rDestType->getTypeClass(), FailReason::NO_DEFAULT_AVAILABLE, nInIndex ) );
+
+ if (rDestType->isAssignableFrom( TypeToIdlClass( pInParams[nInIndex].getValueType(), xCoreReflection ) ))
+ pInvokeParams[nPos] = pInParams[nInIndex];
+ else if (xTypeConverter.is())
+ {
+ Type aDestType( rDestType->getTypeClass(), rDestType->getName() );
+ pInvokeParams[nPos] = xTypeConverter->convertTo( pInParams[nInIndex], aDestType );
+ }
+ else
+ throw CannotConvertException();
+
+ ++nInIndex;
+ }
+
+ // is OUT/INOUT parameter?
+ if (rFParam.aMode != ParamMode_IN)
+ {
+ pOutIndizes[nOutIndex] = nPos;
+ if (rFParam.aMode == ParamMode_OUT)
+ rDestType->createObject( pInvokeParams[nPos] ); // default init
+ ++nOutIndex;
+ }
+ }
+
+ // execute Method
+ Any aRet = xMethod->invoke( _aMaterial, aInvokeParams );
+
+ // OUT Params
+ OutIndizes.realloc( nOutIndex );
+ pOutIndizes = OutIndizes.getArray();
+ OutParams.realloc( nOutIndex );
+ Any* pOutParams = OutParams.getArray();
+
+ for ( ; nOutIndex--; )
+ pOutParams[nOutIndex] = pInvokeParams[pOutIndizes[nOutIndex]];
+
+ return aRet;
+ }
+ catch( CannotConvertException& rExc )
+ {
+ rExc.ArgumentIndex = nInIndex; // optionalen Parameter Index hinzufuegen
+ throw rExc;
+ }
+ }
+ throw NoSuchMethodException();
+ return Any();
+}
+
+//--------------------------------------------------------------------------------------------------
+
+// Struct to optimize sorting
+struct MemberItem
+{
+ OUString aName;
+
+ // Defines where the member comes from
+ enum { NAMEACCESS, PROPERTYSET, METHOD } eMode;
+
+ // Index to respective sequence
+ // (Index to NameAccess sequence for eMode==NAMEACCESS etc.)
+ sal_Int32 nIndex;
+};
+
+// qsort compare function for MemberItem
+int __cdecl compare(const void *elem1, const void *elem2 )
+{
+ MemberItem* pItem1 = *(MemberItem**)elem1;
+ MemberItem* pItem2 = *(MemberItem**)elem2;
+ return (int)pItem1->aName.compareTo( pItem2->aName );
+}
+
+
+// Implementation of getting name or info
+// String sequence will be filled when pStringSeq != NULL
+// Info sequence will be filled when pInfoSeq != NULL
+void Invocation_Impl::getInfoSequenceImpl
+(
+ Sequence< OUString >* pStringSeq,
+ Sequence< InvocationInfo >* pInfoSeq
+)
+{
+ //Sequence< OUString > aStrSeq;
+ //if( !pStringSeq )
+ //pStringSeq = &aStrSeq;
+
+
+ // Get all needed sequences
+ Sequence<OUString> aNameAccessNames;
+ Sequence<Property> aPropertySeq;
+ Sequence< Reference< XIdlMethod > > aMethodSeq;
+
+ if( _xNameAccess.is() )
+ {
+ aNameAccessNames = _xNameAccess->getElementNames();
+ }
+
+ if( _xIntrospectionAccess.is() )
+ {
+ aPropertySeq = _xIntrospectionAccess->getProperties
+ ( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
+
+ aMethodSeq = _xIntrospectionAccess->getMethods
+ ( MethodConcept::ALL - MethodConcept::DANGEROUS );
+ }
+
+ sal_Int32 nNameAccessCount = aNameAccessNames.getLength();
+ sal_Int32 nPropertyCount = aPropertySeq.getLength();
+ sal_Int32 nMethodCount = aMethodSeq.getLength();
+ sal_Int32 nTotalCount = nNameAccessCount + nPropertyCount + nMethodCount;
+
+ // Create and fill array of MemberItems
+ MemberItem* pItems = new MemberItem[ nTotalCount ];
+ const OUString* pStrings = aNameAccessNames.getConstArray();
+ const Property* pProps = aPropertySeq.getConstArray();
+ const Reference< XIdlMethod >* pMethods = aMethodSeq.getConstArray();
+
+ // Create array of MemberItem* for sorting
+ MemberItem** ppItems = new MemberItem*[ nTotalCount ];
+
+ // Fill array of MemberItems
+ sal_Int32 i, iTotal = 0;
+
+ // Name Access
+ for( i = 0 ; i < nNameAccessCount ; i++, iTotal++ )
+ {
+ MemberItem& rItem = pItems[ iTotal ];
+ ppItems[ iTotal ] = &rItem;
+ rItem.aName = pStrings[ i ];
+ rItem.eMode = MemberItem::NAMEACCESS;
+ rItem.nIndex = i;
+ }
+
+ // Property set
+ for( i = 0 ; i < nPropertyCount ; i++, iTotal++ )
+ {
+ MemberItem& rItem = pItems[ iTotal ];
+ ppItems[ iTotal ] = &rItem;
+ rItem.aName = pProps[ i ].Name;
+ rItem.eMode = MemberItem::PROPERTYSET;
+ rItem.nIndex = i;
+ }
+
+ // Methods
+ for( i = 0 ; i < nMethodCount ; i++, iTotal++ )
+ {
+ MemberItem& rItem = pItems[ iTotal ];
+ ppItems[ iTotal ] = &rItem;
+ Reference< XIdlMethod > xMethod = pMethods[ i ];
+ rItem.aName = xMethod->getName();
+ rItem.eMode = MemberItem::METHOD;
+ rItem.nIndex = i;
+ }
+
+ // Sort pointer array
+ qsort( ppItems, (size_t)nTotalCount, sizeof( MemberItem* ), compare );
+
+ // Setting up result sequences
+ OUString* pRetStrings = NULL;
+ if( pStringSeq )
+ {
+ pStringSeq->realloc( nTotalCount );
+ pRetStrings = pStringSeq->getArray();
+ }
+
+ InvocationInfo* pRetInfos = NULL;
+ if( pInfoSeq )
+ {
+ pInfoSeq->realloc( nTotalCount );
+ pRetInfos = pInfoSeq->getArray();
+ }
+
+ // Fill result sequences in the correct order of members
+ for( iTotal = 0 ; iTotal < nTotalCount ; iTotal++ )
+ {
+ MemberItem& rItem = pItems[ iTotal ];
+ if( pRetStrings )
+ {
+ pRetStrings[ iTotal ] = rItem.aName;
+ }
+
+ if( pRetInfos )
+ {
+ if( rItem.eMode == MemberItem::NAMEACCESS )
+ {
+ fillInfoForNameAccess( pRetInfos[ iTotal ], rItem.aName );
+ }
+ else if( rItem.eMode == MemberItem::PROPERTYSET )
+ {
+ fillInfoForProperty( pRetInfos[ iTotal ], pProps[ rItem.nIndex ] );
+ }
+ else if( rItem.eMode == MemberItem::METHOD )
+ {
+ fillInfoForMethod( pRetInfos[ iTotal ], pMethods[ rItem.nIndex ] );
+ }
+ }
+ }
+}
+
+// XInvocation2
+Sequence< OUString > SAL_CALL Invocation_Impl::getMemberNames( )
+ throw( RuntimeException )
+{
+ if( _xDirect2.is() )
+ {
+ return _xDirect2->getMemberNames();
+ }
+ Sequence< OUString > aRetSeq;
+ getInfoSequenceImpl( &aRetSeq, NULL );
+ return aRetSeq;
+}
+
+Sequence< InvocationInfo > SAL_CALL Invocation_Impl::getInfo( )
+ throw( RuntimeException )
+{
+ if( _xDirect2.is() )
+ {
+ return _xDirect2->getInfo();
+ }
+ Sequence< InvocationInfo > aRetSeq;
+ getInfoSequenceImpl( NULL, &aRetSeq );
+ return aRetSeq;
+}
+
+InvocationInfo SAL_CALL Invocation_Impl::getInfoForName( const OUString& aName, sal_Bool bExact )
+ throw( IllegalArgumentException, RuntimeException )
+{
+ if( _xDirect2.is() )
+ {
+ return _xDirect2->getInfoForName( aName, bExact );
+ }
+
+ sal_Bool bFound = sal_False;
+ OUString aExactName = aName;
+ InvocationInfo aRetInfo;
+
+ if( bExact )
+ aExactName = getExactName( aName );
+ if( aExactName.getLength() > 0 )
+ {
+ if( _xIntrospectionAccess->hasMethod( aExactName, MethodConcept::ALL ^ MethodConcept::DANGEROUS ) )
+ {
+ Reference<XIdlMethod> xMethod = _xIntrospectionAccess->getMethod
+ ( aExactName, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
+ fillInfoForMethod( aRetInfo, xMethod );
+ bFound = sal_True;
+ }
+ else
+ {
+ if( _xIntrospectionAccess.is() && _xIntrospectionAccess->hasProperty
+ ( aExactName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
+ {
+ Property aProp = _xIntrospectionAccess->getProperty
+ ( aExactName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
+ fillInfoForProperty( aRetInfo, aProp );
+ bFound = sal_True;
+ }
+ // NameAccess
+ else if( _xNameAccess.is() && _xNameAccess->hasByName( aExactName ) )
+ {
+ fillInfoForNameAccess( aRetInfo, aExactName );
+ bFound = sal_True;
+ }
+ }
+ }
+ if( !bFound )
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown name, getExactName() failed!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ }
+ return aRetInfo;
+}
+
+// Helper functions to fill InvocationInfo for XNameAccess
+void Invocation_Impl::fillInfoForNameAccess
+(
+ InvocationInfo& rInfo,
+ const OUString& aName
+)
+{
+ rInfo.aName = aName;
+ rInfo.eMemberType = MemberType_PROPERTY;
+ rInfo.PropertyAttribute = 0;
+ if( !_xNameContainer.is() )
+ {
+ rInfo.PropertyAttribute = PropertyAttribute::READONLY;
+ }
+ rInfo.aType = _xNameAccess->getElementType();
+}
+
+void Invocation_Impl::fillInfoForProperty
+(
+ InvocationInfo& rInfo,
+ const Property& rProp
+)
+{
+ rInfo.aName = rProp.Name;
+ rInfo.eMemberType = MemberType_PROPERTY;
+ rInfo.PropertyAttribute = rProp.Attributes;
+ rInfo.aType = rProp.Type;
+}
+
+void Invocation_Impl::fillInfoForMethod
+(
+ InvocationInfo& rInfo,
+ const Reference< XIdlMethod > xMethod
+)
+{
+ rInfo.aName = xMethod->getName();
+ rInfo.eMemberType = MemberType_METHOD;
+ Reference< XIdlClass > xReturnClass = xMethod->getReturnType();
+ Type aReturnType( xReturnClass->getTypeClass(), xReturnClass->getName() );
+ rInfo.aType = aReturnType;
+ Sequence<ParamInfo> aParamInfos = xMethod->getParameterInfos();
+ sal_Int32 nParamCount = aParamInfos.getLength();
+ if( nParamCount > 0 )
+ {
+ const ParamInfo* pInfos = aParamInfos.getConstArray();
+
+ rInfo.aParamTypes.realloc( nParamCount );
+ Type* pParamTypes = rInfo.aParamTypes.getArray();
+ rInfo.aParamModes.realloc( nParamCount );
+ ParamMode* pParamModes = rInfo.aParamModes.getArray();
+
+ for( sal_Int32 i = 0 ; i < nParamCount ; i++ )
+ {
+ Reference< XIdlClass > xParamClass = pInfos[i].aType;
+ Type aParamType( xParamClass->getTypeClass(), xParamClass->getName() );
+ pParamTypes[ i ] = aParamType;
+ pParamModes[ i ] = pInfos[i].aMode;
+ }
+ }
+}
+
+
+// XIdlClassProvider
+
+// XTypeProvider
+Sequence< Type > SAL_CALL Invocation_Impl::getTypes(void) throw( RuntimeException )
+{
+ // TODO !!!!
+
+ return Sequence< Type > ();
+}
+
+Sequence< sal_Int8 > SAL_CALL Invocation_Impl::getImplementationId( ) throw( RuntimeException)
+{
+ static OImplementationId *pId = 0;
+ if( ! pId )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pId )
+ {
+ static OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+/*
+Sequence< Reference<XIdlClass> > Invocation_Impl::getIdlClasses(void) throw( RuntimeException )
+{
+ Reflection * ppReflection[7];
+ Usal_Int16 i = 0;
+ ppReflection[i++] = XInvocation_getReflection();
+ if( _xElementAccess.is() )
+ ppReflection[i++] = XElementAccess_getReflection();
+ if( _xEnumerationAccess.is() )
+ ppReflection[i++] = XEnumerationAccess_getReflection();
+ if( _xIndexAccess.is() )
+ ppReflection[i++] = XIndexAccess_getReflection();
+ if( _xNameAccess.is() )
+ ppReflection[i++] = XNameAccess_getReflection();
+ if( _xIndexContainer.is() )
+ ppReflection[i++] = XIndexContainer_getReflection();
+ if( _xNameContainer.is() )
+ ppReflection[i++] = XNameContainer_getReflection();
+
+ // Ivocation does not support XExactName, if direct object supports
+ // XInvocation, but not XExactName.
+ if ((_xDirect.is() && _xENDirect.is()) ||
+ (!_xDirect.is() && (_xENIntrospection.is() || _xENNameAccess.is())))
+ {
+ ppReflection[i++] = XExactName_getReflection();
+ }
+
+ Reference<XIdlClass> xClass = createStandardClass( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.Invocation")),
+ OWeakObject::getStaticIdlClass(), i,
+ ppReflection );
+ return Sequence<Reference<XIdlClass>>( &xClass, 1 );
+}
+*/
+//==================================================================================================
+//==================================================================================================
+//==================================================================================================
+class InvocationService
+ : public OWeakObject
+ , public XSingleServiceFactory
+ , public XServiceInfo
+{
+public:
+ InvocationService( const Reference<XMultiServiceFactory> & rSMgr )
+ : mxSMgr( rSMgr )
+ , xTypeConverter( Reference<XTypeConverter>::query( rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.Converter")) ) ) )
+ , xIntrospection( Reference<XIntrospection>::query( rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.Introspection")) ) ) )
+ , xCoreReflection( Reference<XIdlReflection>::query( rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.CoreReflection")) ) ) )
+ {}
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type & aType ) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw() { OWeakObject::release(); }
+ //void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+ // XIdlClassProvider
+ // virtual Sequence< Reference<XIdlClass> > SAL_CALL getIdlClasses(void) throw( RuntimeException );
+ // XTypeProvider
+ virtual Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( )
+ throw(RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId( )
+ throw( RuntimeException);
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName() throw( RuntimeException );
+ static OUString SAL_CALL getImplementationName_Static() throw( RuntimeException )
+ {
+ return OUString::createFromAscii( IMPL_NAME );
+ }
+ sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException );
+ Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( RuntimeException );
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static(void) throw( RuntimeException );
+
+ // XSingleServiceFactory
+ Reference<XInterface> SAL_CALL createInstance(void) throw( Exception, RuntimeException );
+ Reference<XInterface> SAL_CALL createInstanceWithArguments(
+ const Sequence<Any>& rArguments ) throw( Exception, RuntimeException );
+private:
+
+ Reference<XMultiServiceFactory> mxSMgr;
+ Reference<XTypeConverter> xTypeConverter;
+ Reference<XIntrospection> xIntrospection;
+ Reference<XIdlReflection> xCoreReflection;
+};
+
+//--------------------------------------------------------------------------------------------------
+Any SAL_CALL InvocationService::queryInterface( const Type & aType )
+ throw( RuntimeException )
+{
+ // PropertySet-Implementation
+ Any a = cppu::queryInterface( aType,
+ SAL_STATIC_CAST(XSingleServiceFactory*, this),
+ SAL_STATIC_CAST(XServiceInfo*, this) );
+ if( a.hasValue() )
+ {
+ return a;
+ }
+
+ return OWeakObject::queryInterface( aType );
+}
+
+
+// XTypeProvider
+Sequence< Type > SAL_CALL InvocationService::getTypes(void) throw( RuntimeException )
+{
+ static OTypeCollection *pCollection = 0;
+ if( ! pCollection )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pCollection )
+ {
+ static OTypeCollection collection(
+ getCppuType( (Reference< XSingleServiceFactory> * )0),
+ getCppuType( (Reference< XServiceInfo > * ) 0 ) );
+ pCollection = &collection;
+ }
+ }
+
+ return (*pCollection).getTypes();
+}
+
+Sequence< sal_Int8 > SAL_CALL InvocationService::getImplementationId( ) throw( RuntimeException)
+{
+ static OImplementationId *pId = 0;
+ if( ! pId )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pId )
+ {
+ static OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+// // XIdlClassProvider
+// Sequence< Reference<XIdlClass> > InvocationService::getIdlClasses(void) throw( RuntimeException )
+// {
+// Sequence< Reference<XIdlClass> > aSeq( &getStaticIdlClass(), 1 );
+// return aSeq;
+// }
+
+
+// XServiceInfo
+OUString InvocationService::getImplementationName() throw( RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+// XServiceInfo
+sal_Bool InvocationService::supportsService(const OUString& ServiceName) throw( RuntimeException )
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+// XServiceInfo
+Sequence< OUString > InvocationService::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+// ORegistryServiceManager_Static
+Sequence< OUString > InvocationService::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString::createFromAscii( SERVICE_NAME );
+ return aSNS;
+}
+
+//--------------------------------------------------------------------------------------------------
+Reference<XInterface> InvocationService::createInstance(void) throw( Exception, RuntimeException )
+{
+ //TODO:throw( Exception(OUString( RTL_CONSTASCII_USTRINGPARAM("no default construction of invocation adapter possible!")), *this) );
+ return Reference<XInterface>(); // dummy
+}
+
+//--------------------------------------------------------------------------------------------------
+Reference<XInterface> InvocationService::createInstanceWithArguments(
+ const Sequence<Any>& rArguments ) throw( Exception, RuntimeException )
+{
+ if (rArguments.getLength() == 1)
+ {
+ return Reference< XInterface >
+ ( *new Invocation_Impl( *rArguments.getConstArray(),
+ xTypeConverter, xIntrospection, xCoreReflection ) );
+ }
+ else
+ {
+ //TODO:throw( Exception(OUString( RTL_CONSTASCII_USTRINGPARAM("no default construction of invocation adapter possible!")), *this) );
+ return Reference<XInterface>();
+ }
+}
+
+
+//*************************************************************************
+Reference<XInterface> SAL_CALL InvocationService_CreateInstance( const Reference<XMultiServiceFactory> & rSMgr )
+ throw( RuntimeException )
+{
+ Reference<XInterface> xService = Reference< XInterface > ( *new InvocationService( rSMgr ) );
+ return xService;
+}
+
+}
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii( "/" IMPL_NAME "/UNO/SERVICES" ) ) );
+
+ const Sequence< OUString > & rSNL =
+ stoc_inv::InvocationService::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPL_NAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ stoc_inv::InvocationService_CreateInstance,
+ stoc_inv::InvocationService::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
diff --git a/stoc/source/invocation/makefile.mk b/stoc/source/invocation/makefile.mk
new file mode 100644
index 000000000000..0980f71e65d9
--- /dev/null
+++ b/stoc/source/invocation/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= inv
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/invocation.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/stoc/source/invocation_adapterfactory/iafactory.cxx b/stoc/source/invocation_adapterfactory/iafactory.cxx
new file mode 100644
index 000000000000..267d16ec501c
--- /dev/null
+++ b/stoc/source/invocation_adapterfactory/iafactory.cxx
@@ -0,0 +1,760 @@
+/*************************************************************************
+ *
+ * $RCSfile: iafactory.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+#ifndef _UNO_DATA_H_
+#include <uno/data.h>
+#endif
+#ifndef _UNO_ANY2_H_
+#include <uno/any2.h>
+#endif
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+#include <com/sun/star/uno/XAggregation.hpp>
+#include <com/sun/star/script/XInvocationAdapterFactory.hpp>
+#include <com/sun/star/script/XInvocationAdapterFactory2.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/reflection/InvocationTargetException.hpp>
+
+using namespace cppu;
+using namespace rtl;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::script;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::lang;
+
+#define SERVICENAME "com.sun.star.script.InvocationAdapterFactory"
+#define IMPLNAME "com.sun.star.comp.stoc.InvocationAdapterFactory"
+
+namespace stoc_invadp
+{
+
+//--------------------------------------------------------------------------------------------------
+static inline Sequence< OUString > getSupportedServiceNames()
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME ) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//==================================================================================================
+class FactoryImpl
+ : public WeakImplHelper3< XServiceInfo, XInvocationAdapterFactory, XInvocationAdapterFactory2 >
+{
+ Mapping _aUno2Cpp;
+ Mapping _aCpp2Uno;
+
+public:
+ FactoryImpl();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException);
+
+ // XInvocationAdapterFactory
+ virtual Reference< XInterface > SAL_CALL createAdapter(
+ const Reference< XInvocation > & xReceiver,
+ const Type & rType ) throw (RuntimeException);
+ // XInvocationAdapterFactory2
+ virtual Reference< XInterface > SAL_CALL createAdapter(
+ const Reference< XInvocation > & xReceiver,
+ const Sequence< Type > & rTypes ) throw (RuntimeException);
+};
+
+struct AdapterImpl;
+//==================================================================================================
+struct InterfaceAdapterImpl : public uno_Interface
+{
+ AdapterImpl * pAdapter;
+ typelib_InterfaceTypeDescription * pTypeDescr;
+};
+//==================================================================================================
+struct AdapterImpl
+{
+ oslInterlockedCount nRef;
+ uno_Interface * pReceiver; // XInvocation receiver
+
+ sal_Int32 nInterfaces;
+ InterfaceAdapterImpl * pInterfaces;
+
+ // XInvocation calls
+ void getValue( const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException );
+ void setValue( const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException );
+ void invoke( const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException );
+
+ inline ~AdapterImpl();
+
+ static inline uno_Interface * createAdapter(
+ uno_Interface * pReceiver_, const Sequence< Type > & rTypes );
+};
+
+//--------------------------------------------------------------------------------------------------
+inline static sal_Bool coerce_assign(
+ void * pDest, typelib_TypeDescription * pTD, uno_Any * pSource )
+{
+ if (pSource->pType->eTypeClass != typelib_TypeClass_VOID)
+ {
+ if (pTD->eTypeClass == typelib_TypeClass_ANY)
+ return uno_assignData( pDest, pTD, pSource, pTD, 0, 0, 0 );
+ else
+ return uno_type_assignData( pDest, pTD->pWeakRef, pSource->pData, pSource->pType, 0, 0, 0 );
+ }
+ else
+ {
+ uno_constructData( pDest, pTD );
+ return sal_True;
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+static inline void copyUnoAny( uno_Any * pDest, uno_Any * pSource )
+{
+ ::uno_type_any_construct( pDest, pSource->pData, pSource->pType, 0 );
+}
+//--------------------------------------------------------------------------------------------------
+static inline void constructRuntimeException( uno_Any * pExc, const OUString & rMsg )
+{
+ RuntimeException aExc;
+ aExc.Message = rMsg;
+ typelib_TypeDescription * pTD = 0;
+ const Type & rType = ::getCppuType( (const RuntimeException *)0 );
+ // no conversion neeeded due to binary compatibility + no convertable type
+ ::uno_type_any_construct( pExc, &aExc, rType.getTypeLibType(), 0 );
+}
+
+//__________________________________________________________________________________________________
+void AdapterImpl::getValue(
+ const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ // XInvocation type description
+ typelib_InterfaceTypeDescription * pInvocationTD = 0;
+ const Type & rIType = ::getCppuType( (const Reference< XInvocation > *)0 );
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pInvocationTD, rIType.getTypeLibType() );
+ // getValue()
+ typelib_InterfaceMethodTypeDescription * pInvokMethodTD = 0;
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pInvokMethodTD, pInvocationTD->ppMembers[3] );
+ // attribute type
+ typelib_TypeDescription * pAttributeTD = 0;
+ TYPELIB_DANGER_GET( &pAttributeTD, ((typelib_InterfaceAttributeTypeDescription *)pMemberType)->pAttributeTypeRef );
+
+ uno_Any aInvokRet;
+ void * pInvokArgs[1];
+ pInvokArgs[0] = &((typelib_InterfaceMemberTypeDescription *)pMemberType)->pMemberName;
+ uno_Any aInvokExc;
+ uno_Any * pInvokExc = &aInvokExc;
+
+ // getValue()
+ (*pReceiver->pDispatcher)(
+ pReceiver, (typelib_TypeDescription *)pInvokMethodTD,
+ &aInvokRet, pInvokArgs, &pInvokExc );
+
+ if (pInvokExc) // getValue() call exception
+ {
+ copyUnoAny( *ppException, pInvokExc );
+ uno_any_destruct( pInvokExc, 0 ); // cleanup
+ }
+ else // invocation call succeeded
+ {
+ uno_constructData( pReturn, pAttributeTD );
+ if (coerce_assign( pReturn, pAttributeTD, &aInvokRet ))
+ {
+ *ppException = 0; // no exceptions be thrown
+ }
+ else // no assignment possible => throw runtime exception
+ {
+ uno_destructData( pReturn, pAttributeTD, 0 );
+ constructRuntimeException(
+ *ppException,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("cannot coerce return type of attribute get call!") ) );
+ }
+ uno_any_destruct( &aInvokRet, 0 );
+ }
+
+ TYPELIB_DANGER_RELEASE( pAttributeTD );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pInvokMethodTD );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pInvocationTD );
+}
+//__________________________________________________________________________________________________
+void AdapterImpl::setValue(
+ const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ // XInvocation type description
+ typelib_InterfaceTypeDescription * pInvocationTD = 0;
+ const Type & rIType = ::getCppuType( (const Reference< XInvocation > *)0 );
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pInvocationTD, rIType.getTypeLibType() );
+ // setValue()
+ typelib_InterfaceMethodTypeDescription * pInvokMethodTD = 0;
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pInvokMethodTD, pInvocationTD->ppMembers[2] );
+ // attribute type
+ typelib_TypeDescription * pAttributeTD = 0;
+ TYPELIB_DANGER_GET( &pAttributeTD, ((typelib_InterfaceAttributeTypeDescription *)pMemberType)->pAttributeTypeRef );
+
+ uno_Any aInvokVal;
+ uno_any_construct( &aInvokVal, pArgs[0], pAttributeTD, 0 );
+
+ void * pInvokArgs[2];
+ pInvokArgs[0] = &((typelib_InterfaceMemberTypeDescription *)pMemberType)->pMemberName;
+ pInvokArgs[1] = &aInvokVal;
+ uno_Any aInvokExc;
+ uno_Any * pInvokExc = &aInvokExc;
+
+ // setValue()
+ (*pReceiver->pDispatcher)(
+ pReceiver, (typelib_TypeDescription *)pInvokMethodTD,
+ 0, pInvokArgs, &pInvokExc );
+
+ if (pInvokExc) // setValue() call exception
+ {
+ copyUnoAny( *ppException, pInvokExc );
+ uno_any_destruct( pInvokExc, 0 ); // cleanup
+ }
+ else // invocation call succeeded
+ {
+ *ppException = 0; // no exceptions be thrown
+ }
+
+ uno_any_destruct( &aInvokVal, 0 ); // cleanup
+
+ TYPELIB_DANGER_RELEASE( pAttributeTD );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pInvokMethodTD );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pInvocationTD );
+}
+//__________________________________________________________________________________________________
+void AdapterImpl::invoke(
+ const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ // XInvocation type description
+ typelib_InterfaceTypeDescription * pInvocationTD = 0;
+ const Type & rIType = ::getCppuType( (const Reference< XInvocation > *)0 );
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pInvocationTD, rIType.getTypeLibType() );
+ // invoke()
+ typelib_InterfaceMethodTypeDescription * pInvokMethodTD = 0;
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pInvokMethodTD, pInvocationTD->ppMembers[1] );
+
+ sal_Int32 nParams = ((typelib_InterfaceMethodTypeDescription *)pMemberType)->nParams;
+ typelib_MethodParameter * pFormalParams = ((typelib_InterfaceMethodTypeDescription *)pMemberType)->pParams;
+
+ // count in params
+ sal_Int32 nInParams = 0;
+ sal_Int32 nPos;
+ for ( nPos = nParams; nPos--; )
+ {
+ if (pFormalParams[nPos].bIn)
+ ++nInParams;
+ }
+
+ // in params
+ typelib_TypeDescription * pAnySeqTD = 0;
+ const Type & rAnyType = ::getCppuType( (const Sequence< Any > *)0 );
+ TYPELIB_DANGER_GET( &pAnySeqTD, rAnyType.getTypeLibType() );
+ uno_Sequence * pInParamsSeq = 0;
+ uno_sequence_construct( &pInParamsSeq, pAnySeqTD, 0, nInParams, 0 );
+
+ uno_Any * pInAnys = (uno_Any *)pInParamsSeq->elements;
+ typelib_TypeDescription * pAnyTD = 0;
+ TYPELIB_DANGER_GET( &pAnyTD, ((typelib_IndirectTypeDescription *)pAnySeqTD)->pType );
+ sal_Int32 nInParamsPos = nInParams;
+ for ( nPos = nParams; nPos--; )
+ {
+ typelib_MethodParameter & rParam = pFormalParams[nPos];
+ if (rParam.bIn)
+ {
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, rParam.pTypeRef );
+ // assignment to any never fails...
+ uno_assignData( &pInAnys[--nInParamsPos], pAnyTD, pArgs[nPos], pTD, 0, 0, 0 );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ }
+
+ // out params, out indices
+ uno_Sequence * pOutIndices;
+ uno_Sequence * pOutParams;
+ // return
+ uno_Any aInvokRet;
+ // perform call
+ void * pInvokArgs[4];
+ pInvokArgs[0] = &((typelib_InterfaceMemberTypeDescription *)pMemberType)->pMemberName;
+ pInvokArgs[1] = &pInParamsSeq;
+ pInvokArgs[2] = &pOutIndices;
+ pInvokArgs[3] = &pOutParams;
+ uno_Any aInvokExc;
+ uno_Any * pInvokExc = &aInvokExc;
+
+ // invoke() call
+ (*pReceiver->pDispatcher)(
+ pReceiver, (typelib_TypeDescription *)pInvokMethodTD,
+ &aInvokRet, pInvokArgs, &pInvokExc );
+
+ if (pInvokExc)
+ {
+ OUString aInvokExcName( pInvokExc->pType->pTypeName );
+ if (aInvokExcName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.reflection.InvocationTargetException") ))
+ {
+ // unwrap invocation target exception
+ copyUnoAny( *ppException,
+ &((InvocationTargetException *)pInvokExc->pData)->TargetException );
+ }
+ else
+ {
+ // defer original exception to caller
+ copyUnoAny( *ppException, pInvokExc );
+ }
+ uno_any_destruct( pInvokExc, 0 ); // cleanup
+ }
+ else // no invocation exception
+ {
+ typelib_TypeDescription * pShortSeqTD = 0;
+ const Type & rSeqShortType = ::getCppuType( (const Sequence< sal_Int16 > *)0 );
+ TYPELIB_DANGER_GET( &pShortSeqTD, rSeqShortType.getTypeLibType() );
+
+ // write changed out params
+ OSL_ENSHURE( pOutParams->nElements == pOutIndices->nElements, "### out params lens differ!" );
+ if (pOutParams->nElements == pOutIndices->nElements)
+ {
+ sal_Int16 * pIndices = (sal_Int16 *)pOutIndices->elements;
+ uno_Any * pOut = (uno_Any *)pOutParams->elements;
+ for ( nPos = 0; nPos < pOutIndices->nElements; ++nPos )
+ {
+ sal_Int32 nIndex = pIndices[nPos];
+ typelib_TypeDescription * pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, pFormalParams[nIndex].pTypeRef );
+ OSL_ENSHURE( nIndex < nParams, "### illegal index!" );
+ if (! pFormalParams[nIndex].bIn) // is pure out param
+ uno_constructData( pArgs[nIndex], pTD );
+ if (! coerce_assign( pArgs[nIndex], pTD, &pOut[nPos] )) // if fail
+ {
+ // cleanup of out params
+ if (! pFormalParams[nIndex].bIn) // is pure out param
+ uno_destructData( pArgs[nIndex], pTD, 0 );
+ TYPELIB_DANGER_RELEASE( pTD );
+ for ( sal_Int32 n = 0; n < nPos; ++n )
+ {
+ sal_Int32 nIndex = pIndices[n];
+ pTD = 0;
+ TYPELIB_DANGER_GET( &pTD, pFormalParams[nIndex].pTypeRef );
+ OSL_ENSHURE( nIndex < nParams, "### illegal index!" );
+ uno_destructData( pArgs[nIndex], pTD, 0 );
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ break;
+ }
+ TYPELIB_DANGER_RELEASE( pTD );
+ }
+ if (nPos == pOutIndices->nElements) // out param copy ok; write return value
+ {
+ // return value
+ typelib_TypeDescription * pReturnTD = 0;
+ TYPELIB_DANGER_GET( &pReturnTD, ((typelib_InterfaceMethodTypeDescription *)pMemberType)->pReturnTypeRef );
+ uno_constructData( pReturn, pReturnTD );
+ if (coerce_assign( pReturn, pReturnTD, &aInvokRet ))
+ {
+ *ppException = 0; // no exception
+ }
+ else
+ {
+ uno_destructData( pReturn, pReturnTD, 0 );
+ // set runtime exception
+ constructRuntimeException(
+ *ppException,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("failed to coerce return type during invocation call!") ) );
+ }
+ TYPELIB_DANGER_RELEASE( pReturnTD );
+ }
+ else
+ {
+ // set runtime exception
+ constructRuntimeException(
+ *ppException,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("failed to coerce parameter type during invocation call!") ) );
+ }
+ }
+ else
+ {
+ // set runtime exception
+ constructRuntimeException(
+ *ppException,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("out params lengths differ after invocation call!") ) );
+ }
+ // cleanup invok out params
+ uno_destructData( &pOutIndices, pShortSeqTD, 0 );
+ uno_destructData( &pOutParams, pAnySeqTD, 0 );
+ // cleanup invok return value
+ uno_any_destruct( &aInvokRet, 0 );
+
+ TYPELIB_DANGER_RELEASE( pShortSeqTD );
+ }
+ // cleanup constructed in params
+ uno_destructData( &pInParamsSeq, pAnySeqTD, 0 );
+ TYPELIB_DANGER_RELEASE( pAnyTD );
+ TYPELIB_DANGER_RELEASE( pAnySeqTD );
+
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pInvokMethodTD );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pInvocationTD );
+}
+
+//--------------------------------------------------------------------------------------------------
+static inline td_equals(
+ typelib_TypeDescription * pTD, typelib_TypeDescriptionReference * pType )
+{
+ return (pTD->pWeakRef == pType ||
+ (pTD->pTypeName->length == pType->pTypeName->length &&
+ rtl_ustr_compare( pTD->pTypeName->buffer, pType->pTypeName->buffer ) == 0));
+}
+
+extern "C"
+{
+//__________________________________________________________________________________________________
+static void SAL_CALL adapter_acquire( uno_Interface * pUnoI )
+{
+ ::osl_incrementInterlockedCount(
+ & static_cast< InterfaceAdapterImpl * >( pUnoI )->pAdapter->nRef );
+}
+//__________________________________________________________________________________________________
+static void SAL_CALL adapter_release( uno_Interface * pUnoI )
+{
+ AdapterImpl * pThis = static_cast< InterfaceAdapterImpl * >( pUnoI )->pAdapter;
+ if (! osl_decrementInterlockedCount( &pThis->nRef ))
+ {
+ delete pThis;
+ }
+}
+//__________________________________________________________________________________________________
+static void SAL_CALL adapter_dispatch(
+ uno_Interface * pUnoI, const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ AdapterImpl * pThis =
+ static_cast< InterfaceAdapterImpl * >( pUnoI )->pAdapter;
+
+ // query to emulated interface
+ switch (((typelib_InterfaceMemberTypeDescription *)pMemberType)->nPosition)
+ {
+ case 0: // queryInterface()
+ {
+ *ppException = 0; // no exc
+ typelib_TypeDescriptionReference * pDemanded =
+ *(typelib_TypeDescriptionReference **)pArgs[0];
+ // pInterfaces[0] is XInterface
+ for ( sal_Int32 nPos = 0; nPos < pThis->nInterfaces; ++nPos )
+ {
+ typelib_InterfaceTypeDescription * pTD = pThis->pInterfaces[nPos].pTypeDescr;
+ while (pTD)
+ {
+ if (td_equals( (typelib_TypeDescription *)pTD, pDemanded ))
+ {
+ uno_Interface * pUnoI = &pThis->pInterfaces[nPos];
+ ::uno_any_construct(
+ (uno_Any *)pReturn, &pUnoI, (typelib_TypeDescription *)pTD, 0 );
+ return;
+ }
+ pTD = pTD->pBaseTypeDescription;
+ }
+ }
+ ::uno_any_construct( (uno_Any *)pReturn, 0, 0, 0 ); // clear()
+ break;
+ }
+ case 1: // acquire()
+ *ppException = 0; // no exc
+ adapter_acquire( pUnoI );
+ break;
+ case 2: // release()
+ *ppException = 0; // no exc
+ adapter_release( pUnoI );
+ break;
+
+ default:
+ {
+ if (pMemberType->eTypeClass == typelib_TypeClass_INTERFACE_METHOD) // method
+ {
+ pThis->invoke( pMemberType, pReturn, pArgs, ppException );
+ }
+ else // attribute
+ {
+ if (pReturn)
+ pThis->getValue( pMemberType, pReturn, pArgs, ppException );
+ else
+ pThis->setValue( pMemberType, pReturn, pArgs, ppException );
+ }
+ }
+ }
+}
+}
+
+//__________________________________________________________________________________________________
+inline uno_Interface * AdapterImpl::createAdapter(
+ uno_Interface * pReceiver_, const Sequence< Type > & rTypes )
+{
+ AdapterImpl * pThis = new AdapterImpl();
+
+ pThis->nRef = 1;
+
+ (*pReceiver_->acquire)( pReceiver_ );
+ pThis->pReceiver = pReceiver_;
+
+ pThis->nInterfaces = rTypes.getLength();
+ pThis->pInterfaces = new InterfaceAdapterImpl[ rTypes.getLength() ];
+
+ const Type * pTypes = rTypes.getConstArray();
+ for ( sal_Int32 nPos = rTypes.getLength(); nPos--; )
+ {
+ InterfaceAdapterImpl * pInterface = &pThis->pInterfaces[nPos];
+
+ pInterface->pAdapter = pThis;
+ pInterface->pTypeDescr = 0;
+ pTypes[nPos].getDescription( (typelib_TypeDescription **)&pInterface->pTypeDescr );
+ OSL_ASSERT( pInterface->pTypeDescr );
+ //
+ pInterface->acquire = adapter_acquire;
+ pInterface->release = adapter_release;
+ pInterface->pDispatcher = adapter_dispatch;
+ }
+
+ // returns XInterface
+ return &pThis->pInterfaces[0];
+}
+//__________________________________________________________________________________________________
+inline AdapterImpl::~AdapterImpl()
+{
+ for ( sal_Int32 nPos = nInterfaces; nPos--; )
+ {
+ ::typelib_typedescription_release( (typelib_TypeDescription *)pInterfaces[nPos].pTypeDescr );
+ }
+ delete [] pInterfaces;
+ //
+ (*pReceiver->release)( pReceiver );
+}
+
+//__________________________________________________________________________________________________
+FactoryImpl::FactoryImpl()
+{
+ OUString aCppEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ OUString aUnoEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) );
+
+ _aUno2Cpp = Mapping( aUnoEnvTypeName, aCppEnvTypeName );
+ _aCpp2Uno = Mapping( aCppEnvTypeName, aUnoEnvTypeName );
+ OSL_ENSHURE( _aUno2Cpp.is() && _aCpp2Uno.is(), "### no uno / c++ mappings!" );
+}
+
+// XInvocationAdapterFactory
+//__________________________________________________________________________________________________
+Reference< XInterface > FactoryImpl::createAdapter(
+ const Reference< XInvocation > & xReceiver, const Type & rType )
+ throw (RuntimeException)
+{
+ return createAdapter( xReceiver, Sequence< Type >( &rType, 1 ) );
+}
+// XInvocationAdapterFactory2
+//__________________________________________________________________________________________________
+Reference< XInterface > FactoryImpl::createAdapter(
+ const Reference< XInvocation > & xReceiver, const Sequence< Type > & rTypes )
+ throw (RuntimeException)
+{
+ Reference< XInterface > xRet;
+ if (xReceiver.is() && rTypes.getLength())
+ {
+ uno_Interface * pReceiver = (uno_Interface *)_aCpp2Uno.mapInterface(
+ xReceiver.get(), ::getCppuType( &xReceiver ) );
+ if (pReceiver)
+ {
+ uno_Interface * pRet = AdapterImpl::createAdapter( pReceiver, rTypes );
+ _aUno2Cpp.mapInterface( (void **)&xRet, pRet, ::getCppuType( &xRet ) );
+ OSL_ASSERT( xRet.is() );
+ (*pRet->release)( pRet );
+ (*pReceiver->release)( pReceiver );
+ }
+ }
+ return xRet;
+}
+
+// XServiceInfo
+//__________________________________________________________________________________________________
+OUString FactoryImpl::getImplementationName()
+ throw (RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
+}
+//__________________________________________________________________________________________________
+sal_Bool FactoryImpl::supportsService( const OUString & rServiceName )
+ throw (RuntimeException)
+{
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ {
+ if (pArray[nPos] == rServiceName)
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > FactoryImpl::getSupportedServiceNames()
+ throw (RuntimeException)
+{
+ return stoc_invadp::getSupportedServiceNames();
+}
+
+//==================================================================================================
+static Reference< XInterface > SAL_CALL FactoryImpl_create(
+ const Reference< XMultiServiceFactory > & xMgr )
+ throw (Exception)
+{
+ return Reference< XInterface >( *new FactoryImpl() );
+}
+
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL = stoc_invadp::getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
+ stoc_invadp::FactoryImpl_create,
+ stoc_invadp::getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
diff --git a/stoc/source/invocation_adapterfactory/invadp.xml b/stoc/source/invocation_adapterfactory/invadp.xml
new file mode 100644
index 000000000000..6085782ca0c0
--- /dev/null
+++ b/stoc/source/invocation_adapterfactory/invadp.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Daniel Boelzle </Author>
+
+<Name> com.sun.star.comp.stoc.InvocationAdapterFactory </Name>
+
+<Description>
+You can create adapter interfaces of any given type for an invocation
+interface by using an adapter factory instance.
+</Description>
+
+<ModuleName> invadp </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> C++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> com.sun.star.script.InvocationAdapterFactory </SupportedService>
+
+<ServiceDependency></ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal </RuntimeModuleDependency>
+
+<Type> com.sun.star.script.XInvocationAdapterFactory </Type>
+<Type> com.sun.star.script.XInvocationAdapterFactory2 </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.registry.XSimpleRegistry </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.container.XEnumerationAccess </Type>
+<Type> com.sun.star.container.XNameContainer </Type>
+<Type> com.sun.star.container.XIndexContainer </Type>
+<Type> com.sun.star.reflection.InvocationTargetException </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/stoc/source/invocation_adapterfactory/makefile.mk b/stoc/source/invocation_adapterfactory/makefile.mk
new file mode 100644
index 000000000000..f2d9bb52ef17
--- /dev/null
+++ b/stoc/source/invocation_adapterfactory/makefile.mk
@@ -0,0 +1,105 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=stoc
+TARGET=invadp
+USE_DEFFILE=TRUE
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/iafactory.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/stoc/source/javaloader/javaloader.cxx b/stoc/source/javaloader/javaloader.cxx
new file mode 100644
index 000000000000..139e7a4d57df
--- /dev/null
+++ b/stoc/source/javaloader/javaloader.cxx
@@ -0,0 +1,674 @@
+/*************************************************************************
+ *
+ * $RCSfile: javaloader.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <string.h>
+
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+
+#include <rtl/ustring>
+#include <rtl/process.h>
+
+#include <uno/dispatcher.h>
+#include <uno/environment.h>
+#include <uno/mapping.h>
+#include <uno/mapping.hxx>
+
+#include <cppuhelper/servicefactory.hxx>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#ifdef LINUX
+#undef minor
+#undef major
+#endif
+#include <com/sun/star/corba/giop/MessageHeader_1_1.hpp>
+
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+#include <com/sun/star/bridge/XBridge.hpp>
+#include <com/sun/star/bridge/XInstanceProvider.hpp>
+
+#include <com/sun/star/connection/XConnection.hpp>
+
+#include <com/sun/star/java/XJavaVM.hpp>
+#include <com/sun/star/java/XJavaThreadRegister_11.hpp>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <bridges/remote/context.h>
+#include <bridges/remote/connection.h>
+#include <bridges/remote/remote.h>
+
+#include "jni.h"
+
+#include <cppuhelper/factory.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+#include <com/sun/star/loader/XImplementationLoader.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+#include "jthreadpool.hxx"
+
+using namespace ::com::sun::star::bridge;
+using namespace ::com::sun::star::connection;
+using namespace ::com::sun::star::java;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::loader;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::io;
+
+using namespace ::cppu;
+using namespace ::rtl;
+
+namespace loader {
+ class JVMThreadAttach {
+ JavaVM * _pJavaVM;
+ Reference<XJavaThreadRegister_11> _xJavaThreadRegister_11;
+
+ public:
+ JNIEnv * _pJNIEnv;
+
+ JVMThreadAttach(JavaVM * pJavaVM, XJavaThreadRegister_11 * pXJavaThreadRegister_11) throw (RuntimeException);
+ ~JVMThreadAttach() throw (RuntimeException);
+ };
+
+ JVMThreadAttach::JVMThreadAttach(JavaVM * pJavaVM, XJavaThreadRegister_11 * pXJavaThreadRegister_11) throw (RuntimeException)
+ : _pJNIEnv(NULL),
+ _pJavaVM(pJavaVM),
+ _xJavaThreadRegister_11(pXJavaThreadRegister_11)
+ {
+ pXJavaThreadRegister_11->registerThread();
+ pJavaVM->AttachCurrentThread(&_pJNIEnv, NULL);
+ }
+
+ JVMThreadAttach::~JVMThreadAttach() throw (RuntimeException)
+ {
+ _xJavaThreadRegister_11->revokeThread();
+ if(!_xJavaThreadRegister_11->isThreadAttached())
+ _pJavaVM->DetachCurrentThread();
+ }
+
+
+
+ struct ConnectionWrapper : public remote_Connection {
+ sal_Int32 _refCount;
+
+ JavaVM * _pJavaVM;
+ XJavaThreadRegister_11 * _pXJavaThreadRegister_11;
+
+ jclass _jcByteArray;
+ jmethodID _jmConnection_read;
+ jmethodID _jmConnection_write;
+ jmethodID _jmConnection_flush;
+ jmethodID _jmConnection_close;
+ jobject _joConnection;
+
+ ConnectionWrapper(JavaVM * pJavaVM, XJavaThreadRegister_11 * pXJavaThreadRegister_11, jobject joConnection) throw(RuntimeException);
+ ~ConnectionWrapper() throw(RuntimeException);
+
+ };
+
+ void SAL_CALL ConnectionWrapper_acquire(remote_Connection * blb) {
+ ++ ((ConnectionWrapper *)blb)->_refCount;
+ }
+
+ void SAL_CALL ConnectionWrapper_release (remote_Connection * blb) {
+ if(!-- ((ConnectionWrapper *)blb)->_refCount)
+ delete (ConnectionWrapper *)blb;
+ }
+
+ sal_Int32 SAL_CALL ConnectionWrapper_read(remote_Connection * blb, sal_Int8 *pDest, sal_Int32 nSize) {
+ ConnectionWrapper * pC = (ConnectionWrapper *)blb;
+ jint jiRes = -1;
+
+ try {
+ JVMThreadAttach jvm(pC->_pJavaVM, pC->_pXJavaThreadRegister_11);
+
+ try {
+ jobjectArray joDest = jvm._pJNIEnv->NewObjectArray(1, pC->_jcByteArray, 0); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 1"), Reference<XInterface>());
+ jvm._pJNIEnv->SetObjectArrayElement(joDest, 0, jvm._pJNIEnv->NewByteArray(10)); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 2"), Reference<XInterface>());
+
+ jiRes = jvm._pJNIEnv->CallIntMethod(pC->_joConnection, pC->_jmConnection_read, joDest, (jint)nSize); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 3"), Reference<XInterface>());
+
+ jbyteArray jaDest = reinterpret_cast<jbyteArray>(jvm._pJNIEnv->GetObjectArrayElement(joDest, 0)); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 4"), Reference<XInterface>());
+
+ jbyte * pBytes = jvm._pJNIEnv->GetByteArrayElements(jaDest, NULL); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 5"), Reference<XInterface>());
+ memcpy(pDest, pBytes, jiRes * sizeof(sal_Int8));
+ jvm._pJNIEnv->ReleaseByteArrayElements(jaDest, pBytes, 0); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 6"), Reference<XInterface>());
+ }
+ catch(RuntimeException & runtimeException) {
+ if(jvm._pJNIEnv->ExceptionOccurred()) {
+ jvm._pJNIEnv->ExceptionDescribe();
+ jvm._pJNIEnv->ExceptionClear();
+ }
+
+ throw runtimeException;
+ }
+ }
+ catch(RuntimeException &) {
+ osl_trace("ConnectionWrapper_read - runtimeException occurred\n");
+ jiRes = -1;
+ }
+
+ return (sal_Int32)jiRes;
+ }
+
+ sal_Int32 SAL_CALL ConnectionWrapper_write(remote_Connection * blb, const sal_Int8 *pSource, sal_Int32 nSize) {
+ ConnectionWrapper * pC = (ConnectionWrapper *)blb;
+
+ try {
+ JVMThreadAttach jvm(pC->_pJavaVM, pC->_pXJavaThreadRegister_11);
+
+ try {
+ jbyteArray jaSource = jvm._pJNIEnv->NewByteArray(nSize); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 7"), Reference<XInterface>());
+ jbyte * pBytes = jvm._pJNIEnv->GetByteArrayElements(jaSource, NULL); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 8"), Reference<XInterface>());
+ memcpy(pBytes, pSource, nSize * sizeof(jbyte));
+ jvm._pJNIEnv->ReleaseByteArrayElements(jaSource, pBytes, 0); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 9"), Reference<XInterface>());
+
+ jvm._pJNIEnv->CallVoidMethod(pC->_joConnection, pC->_jmConnection_write, jaSource, (jint)nSize); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 10"), Reference<XInterface>());
+ }
+ catch(RuntimeException & runtimeException) {
+ if(jvm._pJNIEnv->ExceptionOccurred()) {
+ jvm._pJNIEnv->ExceptionDescribe();
+ jvm._pJNIEnv->ExceptionClear();
+ }
+
+ throw runtimeException;
+ }
+ }
+ catch(RuntimeException &) {
+ osl_trace("ConnectionWrapper_read - runtimeException occurred\n");
+ nSize = -1;
+ }
+
+ return nSize;
+ }
+
+ void SAL_CALL ConnectionWrapper_flush(remote_Connection * blb) {
+ ConnectionWrapper * pC = (ConnectionWrapper *)blb;
+
+ JVMThreadAttach jvm(pC->_pJavaVM, pC->_pXJavaThreadRegister_11);
+ jvm._pJNIEnv->CallVoidMethod(pC->_joConnection, pC->_jmConnection_flush);
+ if(jvm._pJNIEnv->ExceptionOccurred()) {
+ jvm._pJNIEnv->ExceptionDescribe();
+ jvm._pJNIEnv->ExceptionClear();
+ }
+ }
+
+ void SAL_CALL ConnectionWrapper_close(remote_Connection * blb) {
+ ConnectionWrapper * pC = (ConnectionWrapper *)blb;
+
+ JVMThreadAttach jvm(pC->_pJavaVM, pC->_pXJavaThreadRegister_11);
+ jvm._pJNIEnv->CallVoidMethod(pC->_joConnection, pC->_jmConnection_close);
+ if(jvm._pJNIEnv->ExceptionOccurred()) {
+ jvm._pJNIEnv->ExceptionDescribe();
+ jvm._pJNIEnv->ExceptionClear();
+ }
+ }
+
+ ConnectionWrapper::ConnectionWrapper(JavaVM * pJavaVM, XJavaThreadRegister_11 * pXJavaThreadRegister_11, jobject joConnection) throw(RuntimeException)
+ : _refCount(0),
+ _pJavaVM(pJavaVM),
+ _pXJavaThreadRegister_11(pXJavaThreadRegister_11)
+ {
+ if(!pJavaVM || !pXJavaThreadRegister_11 || !joConnection)
+ throw RuntimeException(OUString::createFromAscii("hier 11"), Reference<XInterface>());
+
+ acquire = ConnectionWrapper_acquire;
+ release = ConnectionWrapper_release;
+ read = ConnectionWrapper_read;
+ write = ConnectionWrapper_write;
+ flush = ConnectionWrapper_flush;
+ close = ConnectionWrapper_close;
+
+ JVMThreadAttach jvm(pJavaVM, pXJavaThreadRegister_11);
+
+ _jcByteArray = jvm._pJNIEnv->FindClass("[B"); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 12"), Reference<XInterface>());
+ _jcByteArray = reinterpret_cast<jclass>(jvm._pJNIEnv->NewGlobalRef(reinterpret_cast<jobject>(_jcByteArray))); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 13"), Reference<XInterface>());
+
+ jclass jcConnection = jvm._pJNIEnv->FindClass("com/sun/star/connection/XConnection"); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 14"), Reference<XInterface>());
+
+ _jmConnection_read = jvm._pJNIEnv->GetMethodID(jcConnection, "read", "([[BI)I"); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 15"), Reference<XInterface>());
+// _jmConnection_read = reinterpret_cast<jmethodID>(jvm._pJNIEnv->NewGlobalRef(reinterpret_cast<jobject>(_jmConnection_read)));
+ _jmConnection_write = jvm._pJNIEnv->GetMethodID(jcConnection, "write", "([B)V"); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 16"), Reference<XInterface>());
+// _jmConnection_write = reinterpret_cast<jmethodID>(jvm._pJNIEnv->NewGlobalRef(reinterpret_cast<jobject>(_jmConnection_write)));
+ _jmConnection_flush = jvm._pJNIEnv->GetMethodID(jcConnection, "flush", "()V"); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 17"), Reference<XInterface>());
+// _jmConnection_flush = reinterpret_cast<jmethodID>(jvm._pJNIEnv->NewGlobalRef(reinterpret_cast<jobject>(_jmConnection_flush)));
+ _jmConnection_close = jvm._pJNIEnv->GetMethodID(jcConnection, "close", "()V"); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 18"), Reference<XInterface>());
+// _jmConnection_close = reinterpret_cast<jmethodID>(jvm._pJNIEnv->NewGlobalRef(reinterpret_cast<jobject>(_jmConnection_close)));
+
+ _joConnection = jvm._pJNIEnv->NewGlobalRef(joConnection); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 19"), Reference<XInterface>());
+ }
+
+ ConnectionWrapper::~ConnectionWrapper() throw(RuntimeException) {
+ JVMThreadAttach jvm(_pJavaVM, _pXJavaThreadRegister_11);
+
+ jvm._pJNIEnv->DeleteGlobalRef(_joConnection); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 20"), Reference<XInterface>());
+
+ jvm._pJNIEnv->DeleteGlobalRef(reinterpret_cast<jobject>(_jmConnection_read)); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 21"), Reference<XInterface>());
+ jvm._pJNIEnv->DeleteGlobalRef(reinterpret_cast<jobject>(_jmConnection_write)); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 22"), Reference<XInterface>());
+ jvm._pJNIEnv->DeleteGlobalRef(reinterpret_cast<jobject>(_jmConnection_flush)); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 23"), Reference<XInterface>());
+ jvm._pJNIEnv->DeleteGlobalRef(reinterpret_cast<jobject>(_jmConnection_close)); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 24"), Reference<XInterface>());
+
+ jvm._pJNIEnv->DeleteGlobalRef(_jcByteArray); if(jvm._pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 25"), Reference<XInterface>());
+ }
+
+
+
+
+ class JavaComponentLoader : public WeakImplHelper2<XImplementationLoader, XServiceInfo> {
+ Reference<XMultiServiceFactory> _xSMgr;
+ Reference<XImplementationLoader> _javaLoader;
+
+ uno_Environment * _pRemote_Environment;
+ protected:
+ JavaComponentLoader(const Reference<XMultiServiceFactory> & rXSMgr) throw(RuntimeException);
+ ~JavaComponentLoader();
+
+ public:
+ static const OUString implname;
+ static const OUString servname;
+ static Reference<XInterface> CreateInstance(const Reference<XMultiServiceFactory> & rSMgr) throw(Exception);
+ static Sequence<OUString> SAL_CALL getSupportedServiceNames_Static();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence<OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XImplementationLoader
+ virtual Reference<XInterface> SAL_CALL activate(const OUString& implementationName, const OUString& implementationLoaderUrl, const OUString& locationUrl, const Reference<XRegistryKey>& xKey) throw(CannotActivateFactoryException, RuntimeException);
+ virtual sal_Bool SAL_CALL writeRegistryInfo(const Reference<XRegistryKey>& xKey, const OUString& implementationLoaderUrl, const OUString& locationUrl) throw(CannotRegisterImplementationException, RuntimeException);
+ };
+
+ const OUString JavaComponentLoader::implname = L"com.sun.star.comp.stoc.JavaComponentLoader";
+ const OUString JavaComponentLoader::servname = L"com.sun.star.loader.Java2";
+
+ Sequence<OUString> SAL_CALL JavaComponentLoader::getSupportedServiceNames_Static() {
+ return Sequence<OUString>(&servname, 1);
+ }
+
+
+ Reference<XInterface> SAL_CALL JavaComponentLoader::CreateInstance(const Reference<XMultiServiceFactory> & rSMgr) throw(Exception)
+ {
+ Reference<XInterface> xRet;
+
+ try {
+ XImplementationLoader *pXLoader = (XImplementationLoader *)new JavaComponentLoader(rSMgr);
+
+ xRet = Reference<XInterface>::query(pXLoader);
+ }
+ catch(RuntimeException & runtimeException) {
+ osl_trace("Could not init javaloader\n");
+ OString message = OUStringToOString(runtimeException.Message, RTL_TEXTENCODING_ASCII_US);
+ fprintf(stderr, "exception: %s\n", (const char *)message);
+ }
+
+ return xRet;
+ }
+
+ JavaComponentLoader::JavaComponentLoader(const Reference<XMultiServiceFactory> & rSMgr) throw(RuntimeException)
+ : _pRemote_Environment(NULL)
+ {
+ Reference<XJavaVM> xJavaVM(rSMgr->createInstance(OUString::createFromAscii("com.sun.star.java.JavaVirtualMachine")), UNO_QUERY);
+
+ Reference<XJavaThreadRegister_11> xJavaThreadRegister_11(xJavaVM, UNO_QUERY);
+
+ JavaVM * pJavaVM;
+
+
+ Sequence<sal_Int8> processID(16);
+ rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8 *>(processID.getArray()));
+
+ pJavaVM = *(JavaVM **)(xJavaVM->getJavaVM(processID).getValue());
+// pJavaVM = *reinterpret_cast<JavaVM **>(xJavaVM->getJavaVM(processID).getValue());
+
+ if(!pJavaVM)
+ throw RuntimeException(OUString::createFromAscii("hier -1"), Reference<XInterface>());
+
+ JNIEnv * pJNIEnv;
+
+ pJavaVM->AttachCurrentThread(&pJNIEnv, (void *)NULL);
+ xJavaThreadRegister_11->registerThread();
+
+ if( ! javaloader_initNativeThreadPool( pJNIEnv, xJavaThreadRegister_11 ) )
+ {
+ throw RuntimeException(
+ OUString::createFromAscii( "native threadpool couldn't be initialzed" ),
+ Reference< XInterface > () );
+ }
+
+ remote_Connection * pRemote_Connection = NULL;
+
+ try {
+ jclass jcServiceManager = pJNIEnv->FindClass("com/sun/star/comp/servicemanager/ServiceManager"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 26"), Reference<XInterface>());
+ jmethodID jmServiceManager_init = pJNIEnv->GetMethodID(jcServiceManager, "<init>", "()V"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 27"), Reference<XInterface>());
+ jobject joServiceManager = pJNIEnv->NewObject(jcServiceManager, jmServiceManager_init); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 28"), Reference<XInterface>());
+
+ // we need to register the need services
+ static const char * neededServices[] = {
+ "com.sun.star.comp.servicemanager.ServiceManager",
+ "com.sun.star.comp.loader.JavaLoader",
+ "com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge",
+ "com.sun.star.comp.connections.PipedConnection",
+ "com.sun.star.comp.connections.ConstantInstanceProvider"
+ };
+
+
+ jclass jcString = pJNIEnv->FindClass("java/lang/String"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 29"), Reference<XInterface>());
+ jobjectArray jaNeededServices = pJNIEnv->NewObjectArray(sizeof(neededServices) / sizeof(char *), jcString, NULL); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 30"), Reference<XInterface>());
+ for(int i = 0; i < sizeof(neededServices) / sizeof(char *); ++ i) {
+ pJNIEnv->SetObjectArrayElement(jaNeededServices, i, pJNIEnv->NewStringUTF(neededServices[i])); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 31"), Reference<XInterface>());
+ }
+
+ jmethodID jmServiceManager_addFactories = pJNIEnv->GetMethodID(jcServiceManager,
+ "addFactories",
+ "([Ljava/lang/String;)V"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 32"), Reference<XInterface>());
+
+ pJNIEnv->CallVoidMethod(joServiceManager, jmServiceManager_addFactories, jaNeededServices); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 33"), Reference<XInterface>());
+
+ //
+ jmethodID jmServiceManager_createInstanceWithArguments = pJNIEnv->GetMethodID(jcServiceManager,
+ "createInstanceWithArguments",
+ "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 34"), Reference<XInterface>());
+
+ // create an instance of our special inprocess connection
+ jmethodID jmServiceManager_createInstance = pJNIEnv->GetMethodID(jcServiceManager,
+ "createInstance",
+ "(Ljava/lang/String;)Ljava/lang/Object;"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 35"), Reference<XInterface>());
+
+ jstring jsConnectionName = pJNIEnv->NewStringUTF("com.sun.star.connection.PipedConnection"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 36"), Reference<XInterface>());
+ jobject joConnection_nativeSide = pJNIEnv->CallObjectMethod(joServiceManager,
+ jmServiceManager_createInstance,
+ jsConnectionName); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 37"), Reference<XInterface>());
+
+ jclass jcObject = pJNIEnv->FindClass("java/lang/Object"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 38"), Reference<XInterface>());
+ jobjectArray jaArgs = pJNIEnv->NewObjectArray(1, jcObject, joConnection_nativeSide);
+ jobject joConnection_javaSide = pJNIEnv->CallObjectMethod(joServiceManager,
+ jmServiceManager_createInstanceWithArguments,
+ jsConnectionName, jaArgs); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 39"), Reference<XInterface>());
+
+ // create an constant service provider with java servicemanager
+ jstring jsInstanceProvider = pJNIEnv->NewStringUTF("com.sun.star.comp.connection.InstanceProvider"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 40"), Reference<XInterface>());
+ jobject joInstanceProvider = pJNIEnv->CallObjectMethod(joServiceManager,
+ jmServiceManager_createInstance,
+ jsInstanceProvider); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 41"), Reference<XInterface>());
+
+ // create the bridge factory && the bridge
+ jaArgs = pJNIEnv->NewObjectArray(3, jcObject, NULL); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 42"), Reference<XInterface>());
+
+ pJNIEnv->SetObjectArrayElement(jaArgs, 0, pJNIEnv->NewStringUTF("iiop")); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 43"), Reference<XInterface>());
+ pJNIEnv->SetObjectArrayElement(jaArgs, 1, joConnection_javaSide); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 44"), Reference<XInterface>());
+ pJNIEnv->SetObjectArrayElement(jaArgs, 2, joInstanceProvider); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 45"), Reference<XInterface>());
+
+ jstring jsBridgeComponent = pJNIEnv->NewStringUTF("com.sun.star.bridge.Bridge"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 46"), Reference<XInterface>());
+ jobject joBridge = pJNIEnv->CallObjectMethod(joServiceManager,
+ jmServiceManager_createInstanceWithArguments,
+ jsBridgeComponent,
+ jaArgs); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 47"), Reference<XInterface>());
+
+ pRemote_Connection = new ConnectionWrapper(pJavaVM, xJavaThreadRegister_11.get(), joConnection_nativeSide);
+ }
+ catch(RuntimeException & runtimeException) {
+ if(pJNIEnv->ExceptionOccurred()) {
+ pJNIEnv->ExceptionDescribe();
+ pJNIEnv->ExceptionClear();
+ }
+
+ throw runtimeException;
+ }
+
+ xJavaThreadRegister_11->revokeThread();
+ if(!xJavaThreadRegister_11->isThreadAttached())
+ pJavaVM->DetachCurrentThread();
+
+
+ //
+ // everything is prepared to map an initial object from remote (java) to here
+ //
+ OString idStr("the id string");
+ OString dcpStr("the description string");
+ remote_Context * pRemote_Context = remote_createContext(pRemote_Connection, idStr.pData, dcpStr.pData, NULL); if(!pRemote_Connection) throw RuntimeException(OUString::createFromAscii("hier 48"), Reference<XInterface>());
+
+ uno_getEnvironment(&_pRemote_Environment, "remote", pRemote_Context); if(!_pRemote_Environment) throw RuntimeException(OUString::createFromAscii("hier 49"), Reference<XInterface>());
+
+ uno_Environment * pUNO_Environment = NULL;
+ uno_getEnvironment(&pUNO_Environment, "uno", NULL); if(!pUNO_Environment) throw RuntimeException(OUString::createFromAscii("hier 50"), Reference<XInterface>());
+
+ Mapping mapping(_pRemote_Environment, pUNO_Environment, OString());
+
+
+
+ OString remoteO("SERVICEMANAGER");
+
+ typelib_InterfaceTypeDescription *pType = 0;
+ getCppuType((Reference <XInterface> *) 0).getDescription((typelib_TypeDescription **) & pType) ; if(!pType) throw RuntimeException(OUString::createFromAscii("hier 51"), Reference<XInterface>());
+
+ remote_Interface *pRemoteI = 0;
+
+ getCppuType( (::com::sun::star::corba::giop::MessageHeader_1_1*)0 );
+
+
+ pRemote_Context->getRemoteInstance(_pRemote_Environment,
+ &pRemoteI,
+ remoteO.pData,
+ pType); if(!pRemoteI) throw RuntimeException(OUString::createFromAscii("hier 52"), Reference<XInterface>());
+
+ // got an interface !
+ uno_Environment *pEnvCpp =0;
+ uno_getEnvironment(&pEnvCpp , CPPU_CURRENT_LANGUAGE_BINDING_NAME , 0); if(!pEnvCpp) throw RuntimeException(OUString::createFromAscii("hier 53"), Reference<XInterface>());
+
+ Mapping map(_pRemote_Environment , pEnvCpp);
+
+ XInterface * pCppI = (XInterface *) map.mapInterface(pRemoteI, pType); if(!pCppI) throw RuntimeException(OUString::createFromAscii("hier 54"), Reference<XInterface>());
+
+ Reference<XInterface> rReturn = Reference<XInterface>(pCppI);
+
+ Reference<XMultiServiceFactory> serviceManager(rReturn, UNO_QUERY); if(!serviceManager.is()) throw RuntimeException(OUString::createFromAscii("hier 55"), Reference<XInterface>());
+
+ Reference<XInterface> javaLoader_xInterface =
+ serviceManager->createInstance(OUString::createFromAscii("com.sun.star.loader.Java")); if(!javaLoader_xInterface.is()) throw RuntimeException(OUString::createFromAscii("hier 56"), Reference<XInterface>());
+ _javaLoader = Reference<XImplementationLoader>(javaLoader_xInterface, UNO_QUERY); if(!_javaLoader.is()) throw RuntimeException(OUString::createFromAscii("hier 57"), Reference<XInterface>());
+ _javaLoader->acquire();
+
+ Reference<XInitialization> javaLoader_xInit(javaLoader_xInterface, UNO_QUERY);
+
+ Any any_smgr;
+ any_smgr <<= rSMgr;
+ javaLoader_xInit->initialize(Sequence<Any>(&any_smgr, 1));
+
+
+ // important: release the context and the environments
+
+ pCppI->release();
+ pEnvCpp->release(pEnvCpp);
+ pRemoteI->release(pRemoteI);
+
+ pUNO_Environment->release(pUNO_Environment);
+ pRemote_Context->aBase.release(reinterpret_cast<uno_Context *>(pRemote_Context));
+ }
+
+
+ JavaComponentLoader::~JavaComponentLoader() {
+ if(_pRemote_Environment)
+ {
+ _pRemote_Environment->dispose(_pRemote_Environment);
+ _pRemote_Environment->release(_pRemote_Environment);
+ }
+
+// JVMThreadAttach jvm(pC->_pJavaVM, pC->_pXJavaThreadRegister_11);
+
+// try {
+// jclass jcThreadPool = jvm._pJNIEnv->FindClass("com/sun/star/lib/uno/environments/remote/ThreadPool"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 1"), Reference<XInterface>());
+// jmethodID jmThreadPool_reset = jvm._pJNIEnv->GetMethodID(jcThreadPool, "reset", "()V"); if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString::createFromAscii("hier 1"), Reference<XInterface>());
+
+// jvm._pJNIEnv->CallStaticVoidMethod(jcThreadPool, jmThreadPool_reset);
+// }
+// catch(
+ }
+
+ // XServiceInfo
+ OUString SAL_CALL JavaComponentLoader::getImplementationName() throw(::com::sun::star::uno::RuntimeException) {
+ return implname;
+ }
+
+ sal_Bool SAL_CALL JavaComponentLoader::supportsService(const OUString & ServiceName) throw(::com::sun::star::uno::RuntimeException) {
+ sal_Bool bSupport = sal_False;
+
+ Sequence<OUString> aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getArray();
+ for(sal_Int32 i = 0; i < aSNL.getLength() && !bSupport; ++ i)
+ bSupport = pArray[i] == ServiceName;
+
+ return bSupport;
+ }
+
+ Sequence<OUString> SAL_CALL JavaComponentLoader::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) {
+ return getSupportedServiceNames_Static();
+ }
+
+
+
+ // XImplementationLoader
+ sal_Bool SAL_CALL JavaComponentLoader::writeRegistryInfo(const Reference<XRegistryKey> & xKey, const OUString & blabla, const OUString & rLibName)
+ throw(CannotRegisterImplementationException, RuntimeException)
+ {
+ sal_Bool bSuccess = sal_False;
+
+ bSuccess = _javaLoader->writeRegistryInfo(xKey, blabla, rLibName);
+
+ return bSuccess;
+ }
+
+
+ Reference<XInterface> SAL_CALL JavaComponentLoader::activate(const OUString & rImplName,
+ const OUString & blabla,
+ const OUString & rLibName,
+ const Reference<XRegistryKey> & xKey)
+ throw(CannotActivateFactoryException, RuntimeException)
+ {
+ return _javaLoader->activate(rImplName, blabla, rLibName, xKey);
+ }
+}
+
+
+extern "C"
+{
+ SAL_DLLEXPORT void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv) {
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+
+ SAL_DLLEXPORT sal_Bool SAL_CALL component_writeInfo(XMultiServiceFactory * pServiceManager, XRegistryKey * pRegistryKey) {
+ sal_Bool bRes = sal_False;
+
+ if (pRegistryKey) {
+ try {
+ OUString x = OUString::createFromAscii("/");
+ x += ::loader::JavaComponentLoader::implname;
+ x += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference<XRegistryKey> xNewKey(pRegistryKey->createKey(x));
+
+ const Sequence<OUString> rSNL = ::loader::JavaComponentLoader::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for (sal_Int32 nPos = rSNL.getLength(); nPos--;)
+ xNewKey->createKey(pArray[nPos]);
+
+ bRes = sal_True;
+ }
+ catch (InvalidRegistryException &) {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+
+ return bRes;
+ }
+
+ SAL_DLLEXPORT void * SAL_CALL component_getFactory(const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, XRegistryKey * pRegistryKey) {
+ void * pRet = 0;
+
+
+ OString xx(::loader::JavaComponentLoader::implname.getStr(), ::loader::JavaComponentLoader::implname.getLength(), RTL_TEXTENCODING_DONTKNOW);
+ if (pServiceManager && rtl_str_compare(pImplName, xx) == 0)
+ {
+ Reference<XSingleServiceFactory> xFactory(createOneInstanceFactory(pServiceManager,
+ OUString::createFromAscii(pImplName),
+ ::loader::JavaComponentLoader::CreateInstance,
+ ::loader::JavaComponentLoader::getSupportedServiceNames_Static()));
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+ }
+}
+
diff --git a/stoc/source/javaloader/makefile.mk b/stoc/source/javaloader/makefile.mk
new file mode 100644
index 000000000000..df9ba3a8b9cd
--- /dev/null
+++ b/stoc/source/javaloader/makefile.mk
@@ -0,0 +1,154 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=bridges
+TARGET=javaloader
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+CPPUMAKERFLAGS += -C
+UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb
+
+# output directory (one dir for each project)
+UNOUCROUT=$(OUT)$/inc
+
+# adding to inludepath
+INCPRE+=$(UNOUCROUT)
+
+UNOTYPES= \
+ com.sun.star.corba.giop.MessageHeader_1_1 \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.registry.XRegistryKey \
+ com.sun.star.bridge.XBridgeFactory \
+ com.sun.star.bridge.XBridge \
+ com.sun.star.bridge.XInstanceProvider \
+ com.sun.star.connection.XConnection \
+ com.sun.star.java.XJavaVM \
+ com.sun.star.java.XJavaThreadRegister_11 \
+ com.sun.star.uno.XWeak \
+ com.sun.star.uno.XAggregation \
+ com.sun.star.lang.XTypeProvider \
+ com.sun.star.loader.XImplementationLoader \
+ com.sun.star.lang.XServiceInfo \
+ com.sun.star.lang.XInitialization
+
+SLOFILES= $(SLO)$/javaloader.obj \
+ $(SLO)$/jthreadpool.obj
+
+SHL1TARGET= $(TARGET)
+
+.IF "$(COM)" == "GCC"
+REMOTE_CONTEXTLIB = -lrmcxt1
+.ELIF "$(COM)" == "C50"
+REMOTE_CONTEXTLIB = -lrmcxt1
+.ELSE
+REMOTE_CONTEXTLIB = irmcxt.lib
+.ENDIF
+
+SHL1STDLIBS=\
+ $(SALLIB)\
+ $(VOSLIB)\
+ $(CPPULIB)\
+ $(CPPUHELPERLIB) \
+ $(REMOTE_CONTEXTLIB)
+
+
+SHL1LIBS=\
+ $(SLB)$/$(TARGET).lib
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+$(MISC)$/$(SHL1TARGET).def: makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo LIBRARY $(SHL1TARGET) >$@
+ @echo EXPORTS >>$@
+ @echo component_getImplementationEnvironment >>$@
+ @echo component_writeInfo >>$@
+ @echo component_getFactory >>$@
+ @echo Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_add >>$@
+ @echo Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_createTicket >>$@
+ @echo Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_dispose >>$@
+ @echo Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_reply >>$@
+ @echo Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_request >>$@
+ @echo Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_retrieve >>$@
+ @echo Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_revoke >>$@
+ @echo Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_stopDispose >>$@
+ @echo Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_waitOnTicket >>$@
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
new file mode 100644
index 000000000000..163286e95070
--- /dev/null
+++ b/stoc/source/javavm/javavm.cxx
@@ -0,0 +1,1641 @@
+/*************************************************************************
+ *
+ * $RCSfile: javavm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#if STLPORT_VERSION < 321
+// #include <tools/presys.h>
+#include <hash_map.h>
+// #include <tools/postsys.h>
+#else
+#include <stl/vector>
+#include <stl/hash_map>
+#include <cstdarg> // std::va_list and friends
+#endif
+
+//#include "jre.hxx"
+#include <jni.h>
+#include <time.h>
+#ifdef UNX
+#include <limits.h>
+#define _MAX_PATH PATH_MAX
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#include <cppuhelper/typeprovider.hxx>
+
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+
+#ifndef _VOS_DIAGNOSE_H_
+#include <vos/diagnose.hxx>
+#endif
+
+#ifndef _VOS_MODULE_HXX_
+#include <vos/module.hxx>
+#endif
+
+#ifndef _VOS_THREAD_HXX_
+#include <vos/thread.hxx>
+#endif
+
+#ifndef _VOS_CONDITN_HXX_
+#include <vos/conditn.hxx>
+#endif
+
+#ifndef ___JSETTINGS
+#include "settings.hxx"
+#endif
+
+#ifndef _VOS_PROFILE_HXX_
+#include <vos/profile.hxx>
+#endif
+
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+
+// #ifndef _STRING_HXX
+// #include <tools/string.hxx>
+// #endif
+
+// #ifndef _ISOLANG_HXX
+// #include <tools/isolang.hxx>
+// #endif
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <com/sun/star/java/XJavaVM.hpp>
+#include <com/sun/star/java/XJavaThreadRegister_11.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/InvalidRegistryException.hpp>
+#include <com/sun/star/frame/XConfigManager.hpp>
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+#ifndef _RTL_PROCESS_H_
+#include <rtl/process.h>
+#endif
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::java;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::frame;
+using namespace vos;
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+
+#define UNRESOLVED_AWT_SYMBOLS
+#if defined(SOLARIS) && defined (UNRESOLVED_AWT_SYMBOLS)
+#include <dlfcn.h>
+#endif
+#if defined(LINUX)
+#include <dlfcn.h>
+#endif
+
+#if defined(OS2)
+#define NOVMTHREAD
+#endif
+
+#include "jvmargs.hxx"
+
+#if defined(WNT) || defined(OS2)
+#define HAS_SETTINGS_FALLBACK
+#endif
+
+#ifdef UNIX
+#define INI_FILE "javarc"
+#define SLASH_INI_FILE "/javarc"
+#else
+#define INI_FILE "java.ini"
+#define SLASH_INI_FILE "/java.ini"
+#endif
+
+#ifdef OS2
+#define JCALL JNICALL0
+#else
+#define JCALL JNICALL
+#endif
+
+//=========================================================================
+static jint JCALL vm_vfprintf( FILE *fp, const char *format, va_list args )
+{
+#ifdef DEBUG
+ char buff[1024];
+
+ vsprintf( buff, format, args );
+
+ VOS_TRACE("%s", buff);
+ return strlen(buff);
+#else
+ return 0;
+#endif
+}
+
+//=========================================================================
+
+static void JCALL vm_exit(jint code)
+{
+ VOS_TRACE("vm_exit: %d\n", code);
+}
+
+static void JCALL vm_abort()
+{
+ VOS_TRACE("vm_abort\n");
+}
+
+class VMException : public Exception
+{
+ OUString errDescription;
+ sal_Int32 errNum;
+
+public:
+ VMException( sal_Int32 val )
+ {
+ errNum = val;
+ errDescription = OUString::createFromAscii("error: #") + OUString::valueOf( val );
+ }
+
+ VMException( sal_Int32 val, const sal_Unicode* what )
+ {
+ errNum = val;
+ errDescription = OUString::createFromAscii("error: #") + OUString::valueOf( val ) + OUString( what );
+ }
+
+ VMException( sal_Int32 val, const char* what )
+ {
+ errNum = val;
+ errDescription = OUString::createFromAscii("error: #") + OUString::valueOf( val ) + OUString::createFromAscii( what );
+
+ }
+
+ sal_Int32 getErrNum()
+ {
+ return errNum;
+ }
+
+/* virtual const sal_Unicode * what() const throw()
+ {
+ return errDescription.getStr();
+ }
+*/
+
+ virtual OUString what() const throw()
+ {
+ return OUString ( errDescription );
+ }
+
+};
+
+typedef ::std::hash_map
+<
+ sal_uInt32,
+ sal_uInt32,
+ ::std::hash<sal_uInt32>,
+ ::std::equal_to<sal_uInt32>
+> UINT32_UINT32_HashMap;
+
+struct JavaVirtualMachine_Mutex
+{
+ OMutex aMutex;
+};
+
+class JavaVirtualMachine_Impl;
+
+class OCreatorThread : public OThread
+{
+private:
+ JavaVirtualMachine_Impl * pJavaVirtualMachine_Impl;
+ JAVAVM * pJVM;
+
+ OCondition start_Condition;
+ OCondition wait_Condition;
+
+ XSimpleRegistry* pJavaReg;
+ XSimpleRegistry* pSOfficeReg;
+
+protected:
+ virtual void SAL_CALL run();
+
+public:
+
+ OCreatorThread(JavaVirtualMachine_Impl * pJavaVirtualMachine_Impl);
+ JAVAVM * createJavaVM( XSimpleRegistry* pJavaReg, XSimpleRegistry* pSOfficeReg );
+ void disposeJavaVM();
+
+};
+
+class JavaVirtualMachine_Impl :
+ public ::com::sun::star::java::XJavaVM,
+ public ::com::sun::star::java::XJavaThreadRegister_11,
+ public ::com::sun::star::lang::XServiceInfo,
+ public ::com::sun::star::lang::XTypeProvider,
+ public JavaVirtualMachine_Mutex,
+ public ::cppu::OWeakObject
+{
+public:
+ int error;
+
+ JavaVirtualMachine_Impl( const Reference< XMultiServiceFactory> & rSMgr );
+ ~JavaVirtualMachine_Impl();
+
+ virtual Any SAL_CALL queryInterface( const Type & aType )
+ throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw()
+ { OWeakObject::release(); }
+
+ // XTypeProvider
+ virtual Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw(RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw( RuntimeException);
+
+ // XJavaVM
+ virtual Any SAL_CALL getJavaVM( const Sequence<sal_Int8>& processID )
+ throw(RuntimeException);
+ virtual sal_Bool SAL_CALL isVMStarted(void)
+ throw( RuntimeException);
+ virtual sal_Bool SAL_CALL isVMEnabled(void)
+ throw( RuntimeException);
+
+ // XJavaThreadRegister_11
+ virtual sal_Bool SAL_CALL isThreadAttached(void)
+ throw( RuntimeException);
+ virtual void SAL_CALL registerThread(void)
+ throw( RuntimeException);
+ virtual void SAL_CALL revokeThread(void)
+ throw( RuntimeException);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw( RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName)
+ throw( RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
+ throw( RuntimeException);
+
+
+ static OUString SAL_CALL getImplementationName_Static()
+ {
+ return OUString::createFromAscii("com.sun.star.comp.stoc.JavaVirtualMachine");
+ }
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static()
+ {
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString::createFromAscii("com.sun.star.java.JavaVirtualMachine");
+ return aSNS;
+ }
+
+ JAVAVM * createJavaVM( XSimpleRegistry* pJavaReg, XSimpleRegistry* pSOfficeReg );
+ void disposeJavaVM();
+
+private:
+ void setError(int);
+
+#ifndef NOVMTHREAD
+ OCreatorThread creatorThread;
+#endif
+
+ OModule aJavaLib;
+
+ JAVAVM * pJavaVM; /* denotes a Java VM */
+ Reference<XMultiServiceFactory> xSMgr;
+ UINT32_UINT32_HashMap aRegisterdThreadMap;
+
+ void readINetSection( XSimpleRegistry* pOfficeReg, JVM * pJVM ) throw (VMException);
+ void readJavaSection( XSimpleRegistry* pJavaReg, JVM * pJVM );
+ void setLanguageAndCountrySection( XSimpleRegistry* pOfficeReg, JVM* pjvm );
+
+ sal_Bool getSettings( JSettings & rSettings,
+ const Reference<XRegistryKey> xRegistryKey );
+
+ OUString getJavaIniFileName( const Reference<XSimpleRegistry>& xSofficeReg,
+ const Reference<XConfigManager>& xConfigManager );
+
+};
+
+void JavaVirtualMachine_Impl::setError(int error)
+{
+ this->error = error;
+}
+
+OCreatorThread::OCreatorThread( JavaVirtualMachine_Impl * pJavaVirtualMachine_Impl )
+ : pJVM(NULL)
+{
+ this->pJavaVirtualMachine_Impl = pJavaVirtualMachine_Impl;
+}
+
+void OCreatorThread::run()
+{
+ start_Condition.wait();
+ start_Condition.reset();
+ pJVM = pJavaVirtualMachine_Impl->createJavaVM( pJavaReg, pSOfficeReg );
+ wait_Condition.set();
+
+#if defined(WNT) || defined(OS2)
+ suspend();
+
+#else
+ start_Condition.wait();
+ start_Condition.reset();
+
+ if ( pJVM )
+ {
+ pJavaVirtualMachine_Impl->disposeJavaVM();
+ }
+
+ wait_Condition.set();
+#endif
+}
+
+JAVAVM * OCreatorThread::createJavaVM( XSimpleRegistry* pJavaReg, XSimpleRegistry* pSOfficeReg )
+{
+ this->pJavaReg = pJavaReg;
+ this->pSOfficeReg = pSOfficeReg;
+
+ create();
+
+ if ( !pJVM )
+ {
+ start_Condition.set();
+
+ wait_Condition.wait();
+ wait_Condition.reset();
+ }
+ return pJVM;
+}
+
+void OCreatorThread::disposeJavaVM()
+{
+ start_Condition.set(); // start disposing vm
+
+#ifdef UNX
+ wait_Condition.wait(); // wait until disposed
+ wait_Condition.reset();
+#endif
+}
+
+
+//*************************************************************************
+//
+// CLASS JAVA_VM IMPLEMENTATION
+//
+
+
+//*************************************************************************
+// JavaVirtualMachine_Impl_CreateInstance()
+static Reference< XInterface> SAL_CALL JavaVirtualMachine_Impl_createInstance( const Reference< XMultiServiceFactory> & rSMgr )
+ throw (VMException)
+{
+ XJavaVM *pJVM= SAL_STATIC_CAST( XJavaVM*, new JavaVirtualMachine_Impl( rSMgr ));
+ return Reference<XInterface> ( SAL_STATIC_CAST( XInterface*, pJVM));
+
+}
+
+
+
+Sequence< Type > SAL_CALL JavaVirtualMachine_Impl::getTypes(void)
+ throw( RuntimeException )
+{
+ static OTypeCollection *pCollection = 0;
+ if ( ! pCollection )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if ( ! pCollection )
+ {
+ static OTypeCollection collection(
+ getCppuType( (Reference < XTypeProvider > * ) 0 ),
+ getCppuType( (Reference < XJavaVM > * ) 0 ),
+ getCppuType( (Reference < XServiceInfo > *)0 ) ,
+ getCppuType( (Reference < XJavaThreadRegister_11 > *) 0 ) );
+ pCollection = &collection;
+ }
+ }
+
+ return (*pCollection).getTypes();
+}
+
+Sequence< sal_Int8 > SAL_CALL JavaVirtualMachine_Impl::getImplementationId( )
+ throw( RuntimeException )
+{
+ static OImplementationId *pId = 0;
+ if ( ! pId )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if ( ! pId )
+ {
+ static OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//*************************************************************************/
+//
+Any SAL_CALL JavaVirtualMachine_Impl::queryInterface( const Type &aType )
+ throw( RuntimeException )
+
+{
+ Any a = ::cppu::queryInterface( aType,
+ SAL_STATIC_CAST( XJavaVM * ,this),
+ SAL_STATIC_CAST( XServiceInfo *, this),
+ SAL_STATIC_CAST( XJavaThreadRegister_11 *, this ),
+ SAL_STATIC_CAST( XTypeProvider *, this) );
+ if ( a.hasValue() )
+ {
+ return a;
+ }
+ return OWeakObject::queryInterface( aType );
+}
+
+// XServiceInfo
+OUString SAL_CALL JavaVirtualMachine_Impl::getImplementationName()
+ throw( RuntimeException )
+{
+ return JavaVirtualMachine_Impl::getImplementationName_Static();
+}
+
+// XServiceInfo
+sal_Bool SAL_CALL JavaVirtualMachine_Impl::supportsService( const OUString& ServiceName )
+ throw( RuntimeException )
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+
+ for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if ( pArray[i] == ServiceName )
+ return sal_True;
+
+ return sal_False;
+}
+
+// XServiceInfo
+Sequence< OUString > SAL_CALL JavaVirtualMachine_Impl::getSupportedServiceNames()
+ throw( RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+
+static OUString getValue( const Reference<XRegistryKey>& xRegistryRootKey, const OUString& rKey )
+{
+ OUString aEntryValue;
+
+ if ( xRegistryRootKey.is() && xRegistryRootKey->isValid() )
+ {
+ try
+ {
+ Reference<XRegistryKey> aEntry = xRegistryRootKey->openKey( rKey );
+
+ if ( aEntry.is() && aEntry->isValid() )
+ {
+ aEntryValue = aEntry->getStringValue();
+ }
+ }
+ catch (InvalidRegistryException e)
+ {
+ }
+ catch (InvalidValueException e)
+ {
+ }
+ }
+
+ return aEntryValue;
+}
+
+JavaVirtualMachine_Impl::JavaVirtualMachine_Impl( const Reference<XMultiServiceFactory> & rSMgr)
+ : pJavaVM(NULL),
+ xSMgr(rSMgr),
+ error(0)
+#ifndef NOVMTHREAD
+ , creatorThread(this)
+#endif
+{
+}
+
+JavaVirtualMachine_Impl::~JavaVirtualMachine_Impl()
+{
+ if ( pJavaVM )
+ {
+#ifndef NOVMTHREAD
+ creatorThread.disposeJavaVM();
+#else
+ disposeJavaVM();
+#endif
+ }
+}
+
+// XJavaVM
+Any JavaVirtualMachine_Impl::getJavaVM( const Sequence<sal_Int8> & processId ) throw (RuntimeException)
+{
+ OGuard aGuard( aMutex );
+
+ Sequence<sal_Int8> localProcessID(16);
+ rtl_getGlobalProcessId( (sal_uInt8*) localProcessID.getArray() );
+
+ if ( localProcessID == processId && !pJavaVM && !error )
+ {
+ Reference<XInterface> xInterfaceRef_1( xSMgr->createInstance( OUString::createFromAscii("com.sun.star.config.SpecialConfigManager") ) );
+ Reference<XSimpleRegistry> xSofficeReg(xInterfaceRef_1, UNO_QUERY);
+
+ // now we try to open it
+ // sal_Char buffer[_MAX_PATH] = "";
+
+// OUString aOfficeIni;
+// OProfile::getProfileName( aOfficeIni, OUString::createFromAscii( "soffice" ),
+// OUString::createFromAscii( STAROFFICE_SVERSION_KEY ) );
+
+ //OProfile::getProfileName( buffer, _MAX_PATH, 0, STAROFFICE_SVERSION_KEY );
+
+ try
+ {
+ // xSofficeReg->open( aOfficeIni, sal_True, sal_False );
+
+ if ( ! xSofficeReg->isValid() )
+ {
+ InvalidRegistryException e;
+ e.Message = OUString::createFromAscii("can not open ");
+// e.Message += aOfficeIni;
+ throw e;
+ }
+ }
+ catch ( InvalidRegistryException e )
+ {
+ e.Message = OUString::createFromAscii("can not open ");
+// e.Message += aOfficeIni;
+ throw e;
+
+ }
+
+ OUString aJavaIniFileName;
+ // get name for java.ini
+ if ( xSofficeReg.is() && xSofficeReg->isValid() )
+ {
+ Reference<XConfigManager> xConfigManager( xInterfaceRef_1, UNO_QUERY );
+ aJavaIniFileName = getJavaIniFileName( xSofficeReg, xConfigManager );
+ }
+
+ if ( ! aJavaIniFileName.len() ) // search the java.ini beneath the executable
+ {
+ aJavaIniFileName = OUString::createFromAscii( INI_FILE );
+ }
+
+ Reference<XInterface> xInterfaceRef_2( xSMgr->createInstance(
+ OUString::createFromAscii("com.sun.star.config.ConfigManager") ) );
+ Reference<XSimpleRegistry> xJavaReg( xInterfaceRef_2, UNO_QUERY );
+
+ try
+ {
+ OUString tmpJavaIni;
+ File::getFileURLFromNormalizedPath( aJavaIniFileName, tmpJavaIni );
+ xJavaReg->open( tmpJavaIni, sal_True, sal_False );
+
+ if ( xJavaReg->isValid() )
+ {
+ sal_Bool bIsVMEnabled = sal_False;
+
+ Reference<XRegistryKey> xJavaIni = xJavaReg->getRootKey();
+
+ OUString aEntryValue = getValue( xJavaIni, OUString::createFromAscii("Java/Java") );
+
+#ifdef HAS_SETTINGS_FALLBACK
+ bIsVMEnabled = aEntryValue.len() == 0 || aEntryValue.compareToAscii("1") == 0;
+#else
+ bIsVMEnabled = aEntryValue.len() > 0 && aEntryValue.compareToAscii("1") == 0;
+#endif
+
+ if ( bIsVMEnabled )
+ {
+#ifndef NOVMTHREAD
+ pJavaVM = creatorThread.createJavaVM( xJavaReg.get(), xSofficeReg.get() );
+#else
+ pJavaVM = createJavaVM( xJavaReg, xSofficeReg );
+#endif
+ }
+
+ xJavaReg->close();
+ }
+ else
+ {
+ InvalidRegistryException e;
+ e.Message = OUString::createFromAscii("can not open ");
+ e.Message += aJavaIniFileName;
+ throw e;
+ }
+ }
+ catch ( InvalidRegistryException e )
+ {
+ e.Message = OUString::createFromAscii("can not open ");
+ e.Message += aJavaIniFileName;
+ throw e;
+ }
+
+ // don't close soffice
+ // if ( xSofficeReg.is() && xSofficeReg->isValid() )
+ // {
+ // xSofficeReg->close();
+ // }
+ }
+ Any aRet;
+ if( sizeof( pJavaVM ) == sizeof( sal_Int32 ) )
+ {
+ // 32 bit system
+ sal_Int32 nP = (sal_Int32)pJavaVM;
+ aRet <<= nP;
+ }
+ else if( sizeof( pJavaVM ) == sizeof( sal_Int64 ) )
+ {
+ // 64 bit system
+ sal_Int64 nP = (sal_Int64)pJavaVM;
+ aRet <<= nP;
+ }
+ return aRet;
+}
+
+// XJavaVM
+sal_Bool JavaVirtualMachine_Impl::isVMStarted(void)
+ throw ( RuntimeException )
+{
+ return pJavaVM != NULL;
+}
+
+// XJavaVM
+sal_Bool JavaVirtualMachine_Impl::isVMEnabled(void)
+ throw ( RuntimeException)
+{
+ Reference<XInterface> xInterfaceRef_1( xSMgr->createInstance(
+ OUString::createFromAscii("com.sun.star.config.SpecialConfigManager") ) );
+ Reference<XSimpleRegistry> xSofficeReg( xInterfaceRef_1, UNO_QUERY );
+
+ // now we try to open it
+ // sal_Char buffer[_MAX_PATH] = "";
+ // OProfile::getProfileName( buffer, _MAX_PATH, 0, STAROFFICE_SVERSION_KEY );
+
+// OUString aOfficeIni;
+// OProfile::getProfileName( aOfficeIni, OUString::createFromAscii( "soffice" ),
+// OUString::createFromAscii( STAROFFICE_SVERSION_KEY ) );
+
+ try
+ {
+ // xSofficeReg->open( aOfficeIni, sal_True, sal_False );
+
+ if ( ! xSofficeReg->isValid() )
+ {
+ InvalidRegistryException e;
+ e.Message = OUString::createFromAscii("can not open ");
+// e.Message += aOfficeIni;
+ throw e;
+ }
+ }
+ catch ( InvalidRegistryException e )
+ {
+ e.Message = OUString::createFromAscii("can not open ");
+// e.Message += aOfficeIni;
+ throw e;
+ }
+
+ OUString aJavaIniFileName;
+ // get name for java.ini
+ if ( xSofficeReg.is() && xSofficeReg->isValid() )
+ {
+ Reference<XConfigManager> xConfigManager( xInterfaceRef_1, UNO_QUERY );
+ aJavaIniFileName = getJavaIniFileName( xSofficeReg, xConfigManager );
+ }
+
+ if ( ! aJavaIniFileName.len() ) // search the java.ini beneath the executable
+ {
+ aJavaIniFileName = OUString::createFromAscii( INI_FILE );
+ }
+
+ Reference<XInterface> xInterfaceRef_2( xSMgr->createInstance(
+ OUString::createFromAscii("com.sun.star.config.ConfigManager") ) );
+ Reference<XSimpleRegistry> xJavaReg( xInterfaceRef_2, UNO_QUERY );
+
+ try
+ {
+ xJavaReg->open( aJavaIniFileName, sal_True, sal_False );
+ if ( xJavaReg->isValid() )
+ {
+ Reference<XRegistryKey> xJavaIni = xJavaReg->getRootKey();
+ OUString aEntryValue = getValue( xJavaIni, OUString::createFromAscii("Java/Java") );
+ xJavaReg->close();
+
+#ifdef HAS_SETTINGS_FALLBACK
+ return aEntryValue.len() == 0 || aEntryValue.compareToAscii("1") == 0;
+#else
+ return aEntryValue.len() > 0 && aEntryValue.compareToAscii("1") == 0;
+#endif
+ }
+ else
+ {
+ InvalidRegistryException e;
+ e.Message = OUString::createFromAscii("can not open ");
+ e.Message += aJavaIniFileName;
+ throw e;
+ }
+
+ }
+ catch ( InvalidRegistryException e )
+ {
+ e.Message = OUString::createFromAscii("can not open ");
+ e.Message += aJavaIniFileName;
+ throw e;
+ }
+
+ return sal_False;
+}
+
+// XJavaThreadRegister_11
+sal_Bool JavaVirtualMachine_Impl::isThreadAttached( void )
+ throw ( RuntimeException)
+{
+ sal_Int32 nThreadID = OThread::getCurrentIdentifier();
+
+ // Mutex holen
+ OGuard aGuard(aMutex);
+ return aRegisterdThreadMap.end() != aRegisterdThreadMap.find(nThreadID);
+}
+
+// XJavaThreadRegister_11
+void JavaVirtualMachine_Impl::registerThread(void)
+ throw ( RuntimeException)
+{
+ sal_Int32 nThreadID = OThread::getCurrentIdentifier();
+
+ // Mutex holen
+ OGuard aGuard(aMutex);
+
+ UINT32_UINT32_HashMap::iterator aIt = aRegisterdThreadMap.find(nThreadID);
+
+ if ( aIt == aRegisterdThreadMap.end() )
+ aRegisterdThreadMap[nThreadID] = 1;
+ else
+ (*aIt).second++;
+}
+
+// XJavaThreadRegister_11
+void JavaVirtualMachine_Impl::revokeThread(void)
+ throw ( RuntimeException)
+{
+ sal_Int32 nThreadID = OThread::getCurrentIdentifier();
+
+ // Mutex holen
+ OGuard aGuard(aMutex);
+
+ UINT32_UINT32_HashMap::iterator aIt = aRegisterdThreadMap.find(nThreadID);
+ VOS_ASSERT( aIt != aRegisterdThreadMap.end() );
+ if ( aIt != aRegisterdThreadMap.end() )
+ {
+ if ( 0 == --((*aIt).second) )
+ aRegisterdThreadMap.erase( nThreadID );
+ }
+}
+
+sal_Bool JavaVirtualMachine_Impl::getSettings( JSettings& rSettings, const Reference<XRegistryKey> xRegistryRootKey)
+{
+ char * pJavaDebug = getenv( "STAR_JAVADEBUG" );
+ sal_Bool bSettingsOk = sal_False;
+
+
+ if (pJavaDebug)
+ {
+ rSettings.setDebug( sal_True );
+ rSettings.setDebugPort( atoi(pJavaDebug) );
+ }
+
+ if ( rSettings.getDebug() && pJavaDebug )
+ {
+ char * pClassPath = getenv ("CLASSPATH");
+
+ if (pClassPath)
+ rSettings.classPath = OUString::createFromAscii( pClassPath );
+ }
+
+
+ OUString aDebug = getValue( xRegistryRootKey, OUString::createFromAscii("Java/Debug") );
+
+ if ( aDebug.len() && aDebug.compareToAscii("1") == 0 )
+ rSettings.setDebug(sal_True);
+
+ OUString aJavaVmHome = getValue( xRegistryRootKey, OUString::createFromAscii("Java/Home") );
+
+// fprintf(stderr, "#### GetSettings: home - %s\n", OUStringToOString(aJavaVmHome, CHARSET_SYSTEM).GetStr());
+ OUString aJavaVmVersion = getValue( xRegistryRootKey, OUString::createFromAscii("Java/Version") );
+ OUString aJavaVmName = getValue( xRegistryRootKey, OUString::createFromAscii("Java/RuntimeLib") );
+
+// fprintf(stderr, "JavaVirtualMachine_Impl::getSettings: %s\n", aJavaVmName.getStr());
+
+ rSettings.setRuntimeLib( aJavaVmName );
+
+ if ( aJavaVmName.len() )
+ bSettingsOk = GetVmNameSettings( rSettings, aJavaVmName, aJavaVmVersion, rSettings.getDebug() );
+ if ( !bSettingsOk && aJavaVmHome.len() )
+ bSettingsOk = GetVmHomeSettings( rSettings, aJavaVmHome, aJavaVmVersion, rSettings.getDebug() );
+ if ( !bSettingsOk )
+ bSettingsOk = GetDefaultSettings( rSettings, aJavaVmVersion, rSettings.getDebug() );
+
+ OUString aEntryValue;
+
+ aEntryValue = getValue( xRegistryRootKey, OUString::createFromAscii("Java/RuntimeLib") );
+
+ if ( aEntryValue.len() )
+ rSettings.setRuntimeLib( aEntryValue );
+
+ aEntryValue = getValue( xRegistryRootKey, OUString::createFromAscii("Java/SystemClasspath") );
+
+ if ( aEntryValue.len() )
+ rSettings.classPath = aEntryValue;
+
+ aEntryValue = getValue( xRegistryRootKey, OUString::createFromAscii("Java/UserClasspath") );
+
+ if ( aEntryValue.len() )
+ {
+#ifdef UNX
+ // #68287# Semikolona to colon
+ sal_Int32 tokenCount = aEntryValue.getTokenCount();
+ OUString path;
+
+ for ( sal_Int32 i = 0; i < tokenCount; ++i )
+ {
+ if ( path.len() )
+ path += OUString::createFromAscii(":");
+
+ path += aEntryValue.getToken(i);
+ }
+
+ aEntryValue = path;
+#endif
+ rSettings.classPath = rSettings.classPath + OUString(ENV_DEL) + aEntryValue;
+ }
+
+ return bSettingsOk;
+}
+
+#ifdef SOLARIS
+#include <sys/utsname.h>
+/* getSolarisRelease
+ * make a single integer from solaris release string
+ */
+
+int getSolarisRelease()
+{
+ struct utsname aRelease;
+ static int nRelease = 0;
+
+ if ( nRelease != 0 )
+ {
+ /* computed once, returned many */
+ return nRelease;
+ }
+ else
+ if ( uname( &aRelease ) > -1 )
+ {
+ int nTokens;
+ int nMajor, nMinor, nMMinor;
+
+ /* release will be something like 5.5.1 or 5.6 */
+ nTokens = sscanf(aRelease.release, "%i.%i.%i\n",
+ &nMajor, &nMinor, &nMMinor );
+
+ switch ( nTokens )
+ {
+ case 0: nMajor = 0;
+ /* fall thru */
+ case 1: nMinor = 0;
+ /* fall thru */
+ case 2: nMMinor = 0;
+ break;
+ case 3:
+ default:
+ /* 3 tokens cannot match more than 3 times */
+ break;
+ }
+
+ /* will be something like 551 or 560, dont expect a minor release
+ * number larger than 9 */
+ nRelease = nMajor * 100 + nMinor * 10 + nMMinor;
+
+ /* okay, the paranoic case */
+ if ( nRelease == 0 )
+ nRelease = -1;
+ }
+ else
+ {
+ /* never saw uname fail, but just in case
+ * (must be very old solaris) */
+ nRelease = -1;
+ }
+
+ return nRelease;
+}
+#endif
+
+#ifdef UNX
+static OUString preOpen( sal_Bool bDebug,
+ const OUString & usLibraryPath,
+ const OUString & usRuntimeLib,
+ const OUString & rCompiler)
+{
+ //**************************************************************************************/
+ // now try to load the java lib ********************************************************/
+
+ OUString usCompiler = rCompiler;
+ char * error = NULL;
+
+ dlerror(); // CLEAR
+
+#if defined(LINUX)
+
+ OString sRuntime = OUStringToOString( usLibraryPath + usRuntimeLib, RTL_TEXTENCODING_ASCII_US );
+ dlopen( sRuntime.getStr(), RTLD_LAZY | RTLD_GLOBAL );
+ error = dlerror();
+
+ if (error) throw VMException( -1, error );
+
+ if (bDebug)
+ {
+ OString sAgent = OUStringToOString(usLibraryPath, RTL_TEXTENCODING_ASCII_US) + "libagent_g.so";
+
+ void *handle = dlopen( sAgent.getStr(), RTLD_GLOBAL | RTLD_LAZY);
+ error = dlerror();
+ if (error) throw VMException( -2, error );
+ }
+#endif // LINUX
+
+// String sLibZip = OUStringToOString( usLibraryPath + OUString::createFromAscii("libzip.so") );
+// void * libzipso = dlopen(sLibZip.GetStr(), RTLD_LAZY | RTLD_GLOBAL);
+// error = dlerror();
+// if (error)
+// fprintf (stderr, "preOpen - %s: %s\n", sLibZip.GetStr(), error);
+
+
+#if defined(SOLARIS) && defined(UNRESOLVED_AWT_SYMBOLS)
+ OString sRuntime = OUStringToOString(usLibraryPath + usRuntimeLib, RTL_TEXTENCODING_ASCII_US);
+
+ if ( !dlopen(sRuntime.getStr(), RTLD_LAZY | RTLD_GLOBAL) )
+ {
+ error = dlerror();
+ throw VMException( -3, error );
+ }
+
+ void* libJITHandel;
+
+ if ( ! usCompiler.equalsIgnoreCase( OUString::createFromAscii("NONE") ) )
+ {
+#if defined(INTEL)
+ OUString preopen;
+ if ( usCompiler.len() )
+ usCompiler = OUString::createFromAscii("sunwjit");
+
+ preopen = OUString::createFromAscii("lib") + usCompiler + OUString::createFromAscii(".so");
+ OString sAgent = OUStringToOString( usLibraryPath + preopen, RTL_TEXTENCODING_ASCII_US );
+ libJITHandel = dlopen(sAgent.getStr(), RTLD_GLOBAL | RTLD_LAZY);
+
+#elif defined(SPARC)
+ int release = getSolarisRelease();
+ OUString preopen;
+
+ if ( release < 560 )
+ { // seems to be solaris 2.5.x or less
+ //fprintf(stderr, "seems to be solaris 2.5.x\n");
+
+ if ( usCompiler.len() )
+ { // enable JIT only if recommendet by user (entry in sofficerc)
+ preopen = OUString::createFromAscii("lib") + usCompiler + OUString::createFromAscii(".so");
+ OString sAgent = OUStringToOString(preopen, RTL_TEXTENCODING_ASCII_US);
+ //fprintf(stderr, "TRY to open %s\n", sAgent.GetStr());
+ libJITHandel = dlopen(sAgent.getStr(), RTLD_GLOBAL | RTLD_LAZY);
+ }
+ else
+ {
+ //fprintf(stderr, "no compiler set: set to NONE");
+ usCompiler = OUString::createFromAscii("NONE");
+ }
+ }
+ else
+ {
+ //fprintf(stderr, "seems to be solaris 2.6.x\n");
+
+ if ( !usCompiler.len() )
+ {
+ usCompiler = OUString::createFromAscii("sunwjit");
+ preopen = OUString::createFromAscii("libjit.so");
+ }
+ else
+ preopen = OUString::createFromAscii("lib") + usCompiler + OUString::createFromAscii(".so");
+
+ OString sJIT = OUStringToOString( preopen, RTL_TEXTENCODING_ASCII_US );
+
+ libJITHandel = dlopen(sJIT.getStr(), RTLD_GROUP | RTLD_LAZY);
+ }
+
+#endif // SPARC
+ if ( !usCompiler.equalsIgnoreCase( OUString::createFromAscii("NONE") ) )
+ {
+// error = dlerror();
+
+// if (error)
+// fprintf (stderr, "preopen JIT DLL: %s\n", error);
+
+// if ( libJITHandel == NULL )
+// usCompiler = OUString::createFromAscii("NONE";
+ }
+ }
+#endif
+ return usCompiler;
+}
+#endif // UNX
+
+
+inline sal_Bool IsEqualToAscii( const OUString & rString, const sal_Char* anotherString )
+{
+ return rString.compareToAscii( anotherString ) == 0;
+}
+
+void JavaVirtualMachine_Impl::readJavaSection( XSimpleRegistry* pJavaReg, JVM* pjvm )
+{
+ sal_Bool bSetDefaultToolkit = sal_True;
+ sal_Bool bSetDefaultTKTLib = sal_True;
+
+ //if ( pJavaReg->isValid() )
+ //{
+ // try
+ // {
+ Reference<XRegistryKey> xJavaSection = pJavaReg->getRootKey()->openKey( OUString::createFromAscii("Java") );
+
+ if ( xJavaSection.is() && xJavaSection->isValid() )
+ {
+ Sequence< OUString > aJavaProperties = xJavaSection->getKeyNames();
+ OUString* pSectionEntry = aJavaProperties.getArray();
+ sal_Int32 nCount = aJavaProperties.getLength();
+
+ for ( sal_Int32 i=0; i<nCount; i++ )
+ {
+ OUString aEntryValue = ( xJavaSection->openKey( pSectionEntry[i] ))->getStringValue();
+
+ if ( !pSectionEntry[i].len() )
+ ;
+ else if ( pSectionEntry[i] == OUString::createFromAscii("Debug") )
+ pjvm->setDebug( IsEqualToAscii( aEntryValue, "1" ) );
+ else if ( IsEqualToAscii(pSectionEntry[i], "Java") )
+ ;
+ else if ( IsEqualToAscii(pSectionEntry[i], "Version") )
+ ;
+ else if ( IsEqualToAscii(pSectionEntry[i], "Home") )
+ ;
+ else if ( IsEqualToAscii(pSectionEntry[i], "SystemClasspath") )
+ ;
+ else if ( IsEqualToAscii(pSectionEntry[i], "awt.toolkit") )
+ {
+ bSetDefaultToolkit = sal_False;
+
+ pjvm->pushProp( pSectionEntry[i] + OUString::createFromAscii("=") + aEntryValue );
+ }
+ else if ( IsEqualToAscii(pSectionEntry[i], "java.compiler") )
+ pjvm->setCompiler( aEntryValue );
+
+ else if ( IsEqualToAscii(pSectionEntry[i], "DisableAsyncGC") )
+ pjvm->disableAsyncGC(IsEqualToAscii( aEntryValue, "1") );
+
+ else if ( IsEqualToAscii(pSectionEntry[i], "EnableClassGC") )
+ pjvm->enableClassGC(IsEqualToAscii(aEntryValue, "0") );
+
+ else if ( IsEqualToAscii(pSectionEntry[i], "EnableVerboseGC") )
+ pjvm->enableVerboseGC(IsEqualToAscii(aEntryValue, "1") );
+
+ else if ( IsEqualToAscii(pSectionEntry[i], "Verbose") )
+ pjvm->verbose(IsEqualToAscii(aEntryValue, "1") );
+
+ else if ( pSectionEntry[i] == OUString::createFromAscii("NativeStackSize") )
+ pjvm->nativeStackSize( aEntryValue.toInt32() );
+
+ else if ( IsEqualToAscii(pSectionEntry[i], "JavaStackSize") )
+ pjvm->javaStackSize( aEntryValue.toInt32() );
+
+ else if ( IsEqualToAscii(pSectionEntry[i], "VerifyMode") )
+ pjvm->verifyMode( aEntryValue );
+
+ else if ( IsEqualToAscii(pSectionEntry[i], "MinHeapSize") )
+ pjvm->minHeapSize( aEntryValue.toInt32() );
+
+ else if ( IsEqualToAscii(pSectionEntry[i], "MaxHeapSize") )
+ pjvm->maxHeapSize( aEntryValue.toInt32() );
+
+ else if ( IsEqualToAscii(pSectionEntry[i], "DebugPort") )
+ pjvm->setDebugPort( aEntryValue.toInt32() );
+ else
+ {
+ if ( aEntryValue.len() )
+ pSectionEntry[i] = pSectionEntry[i] + OUString::createFromAscii("=") + aEntryValue;
+
+ pjvm->pushProp( pSectionEntry[i] );
+ }
+ }
+ }
+ else
+ {
+ InvalidRegistryException e;
+ e.Message = OUString::createFromAscii("no Java Section found");
+ throw e;
+ }
+}
+
+void JavaVirtualMachine_Impl::setLanguageAndCountrySection( XSimpleRegistry* pOfficeReg, JVM* pjvm )
+{
+// TEMPORARY DISABLED
+// OUString aValue;
+
+// Reference<XRegistryKey> xRegistryRootKey = pOfficeReg->getRootKey();
+// aValue = getValue( xRegistryRootKey, OUString::createFromAscii("User/Language") );
+
+// if ( aValue.len() )
+// {
+// OUString aLanguage;
+// OUString aCountry;
+
+// // LanguageType aLangNum = (LanguageType) String( OUStringToOString( aValue, RTL_TEXTENCODING_ASCII_US) );
+// LanguageType aLangNum = (LanguageType) aValue.toInt32();
+
+// {
+// String langStr;
+// String countryStr;
+
+// ConvertLanguageToIsoNames( aLangNum, langStr, countryStr );
+
+// aLanguage = OUString( langStr );
+// aCountry = OUString( countryStr );
+// }
+
+// if ( aLanguage.getLength() ) pjvm->pushProp( OUString::createFromAscii("user.language=") + aLanguage );
+
+// if ( aCountry.getLength() ) pjvm->pushProp( OUString::createFromAscii("user.region=") + aCountry );
+// }
+}
+
+void JavaVirtualMachine_Impl::readINetSection( XSimpleRegistry* pOfficeReg, JVM* pjvm ) throw (VMException)
+{
+ Reference<XRegistryKey> xRegistryRootKey = pOfficeReg->getRootKey();
+
+ // HTTPProxyHost, HTTPProxyPort, FTPProxyHost, FTPProxyPort
+ // Reading proxy and port values in the INet section
+
+ OUString aValue;
+
+ // HTTPProxy
+ aValue = getValue( xRegistryRootKey, OUString::createFromAscii("INet/HTTPProxy") );
+ if ( aValue.len() ) pjvm->pushProp( OUString::createFromAscii("http.proxyHost=") + aValue );
+
+ // HTTPProxyPort
+ aValue = getValue( xRegistryRootKey, OUString::createFromAscii("INet/HTTPProxyPort") );
+ if ( aValue.len() ) pjvm->pushProp( OUString::createFromAscii("http.proxyPort=") + aValue );
+
+ // FTPPProxy
+ aValue = getValue( xRegistryRootKey, OUString::createFromAscii("INet/FTPProxy" ) );
+ if ( aValue.len() ) pjvm->pushProp( OUString::createFromAscii("ftpProxyHost=") + aValue );
+
+ // FTPProxyPort
+ aValue = getValue( xRegistryRootKey, OUString::createFromAscii("INet/FTPProxyPort" ) );
+ if ( aValue.len() ) pjvm->pushProp( OUString::createFromAscii("FTPProxyPort=") + aValue );
+}
+
+static void initSJSettings( JNIEnv * pJNIEnv ) throw (VMException)
+{
+ // init SjSettings -> SecurityManager
+ jclass jcSjSettings = pJNIEnv->FindClass("stardiv/controller/SjSettings");
+ if (!jcSjSettings) throw VMException( -9, "Can't find class \"stardiv/controller/SjSettings\"." );
+
+ jmethodID jmChangeProperties = pJNIEnv->GetStaticMethodID( jcSjSettings , "changeProperties", "(Ljava/util/Properties;)V" );
+ if ( !jmChangeProperties ) throw VMException( -9, "Can't find method \"changeProperties\" of class \"stardiv/controller/SjSettingss\"." );
+
+ pJNIEnv->CallStaticVoidMethod( jcSjSettings, jmChangeProperties, NULL );
+
+ if ( pJNIEnv->ExceptionOccurred() )
+ {
+ pJNIEnv->ExceptionClear();
+ throw VMException( -9, "An exception occured when calling method \"changeProperties\" of class \"stardiv/controller/SjSettingss\".");
+ }
+}
+
+
+static void setTimeZone( JVM * pjvm )
+{
+ /* A Bug in the Java function
+ ** struct Hjava_util_Properties * java_lang_System_initProperties(
+ ** struct Hjava_lang_System *this,
+ ** struct Hjava_util_Properties *props);
+ ** This function doesn't detect MEZ, MET or "W. Europe Standard Time"
+ */
+ struct tm *tmData;
+ time_t clock = time(NULL);
+ tzset();
+ tmData = localtime(&clock);
+ char * p = tzname[0];
+#ifdef WNT
+ if ( OString( "MET" ) == p )
+#else
+ if ( OString( "MEZ" ) == p )
+#endif
+ {
+ pjvm->pushProp( OUString::createFromAscii("user.timezone=ECT") );
+ }
+}
+
+static void setVMLibraryPath(const OString & usLibraryPath, JNIEnv * pJNIEnv)
+{
+ // setzte den privaten LD_LIBRARY_PATH an java.lang.Runtime
+ jclass jcRuntime = pJNIEnv->FindClass("java/lang/Runtime"); if (pJNIEnv->ExceptionOccurred()) return;
+ jmethodID jmGetRuntime = pJNIEnv->GetStaticMethodID(jcRuntime,
+ "getRuntime",
+ "()Ljava/lang/Runtime;"); if (pJNIEnv->ExceptionOccurred()) return;
+ jobject joRuntime = pJNIEnv->CallStaticObjectMethod(jcRuntime, jmGetRuntime); if (pJNIEnv->ExceptionOccurred()) return;
+
+ jfieldID jfPaths = pJNIEnv->GetFieldID(jcRuntime, "paths", "[Ljava/lang/String;"); if (pJNIEnv->ExceptionOccurred()) return;
+
+// jstring jsJavaLibPath = pJNIEnv->NewStringUTF(usLibraryPath.GetStr()); if (pJNIEnv->ExceptionOccurred()) return;
+ jstring jsJavaLibPath = pJNIEnv->NewStringUTF(usLibraryPath); if (pJNIEnv->ExceptionOccurred()) return;
+ jstring jsOfficeLibPath = pJNIEnv->NewStringUTF(""); if (pJNIEnv->ExceptionOccurred()) return;
+
+
+ jclass jcString = pJNIEnv->FindClass("java/lang/String"); if (pJNIEnv->ExceptionOccurred()) return;
+ jarray jaPaths = pJNIEnv->NewObjectArray(2, jcString, NULL); if (pJNIEnv->ExceptionOccurred()) return;
+ pJNIEnv->SetObjectArrayElement((jobjectArray)jaPaths, 0, jsJavaLibPath); if (pJNIEnv->ExceptionOccurred()) return;
+ pJNIEnv->SetObjectArrayElement((jobjectArray)jaPaths, 1, jsOfficeLibPath); if (pJNIEnv->ExceptionOccurred()) return;
+
+ pJNIEnv->SetObjectField(joRuntime, jfPaths, jaPaths); if (pJNIEnv->ExceptionOccurred()) return;
+}
+
+#ifdef UNX
+#include <limits.h>
+#define _MAX_PATH PATH_MAX
+#endif
+
+/*
+static OUString pathExpansion()
+{
+ OUString aClassPath;
+
+ // Application home
+ char buf[_MAX_PATH];
+ if ( OStartupInfo::E_None == OStartupInfo().getExecutableFile(buf, _MAX_PATH ) )
+ {
+ OString aPath = buf;
+ sal_Int16 nPos = aPath.getLength();
+ if ( nPos )
+ {
+ while ( nPos-- && aPath[nPos] != PATH_DEL[0] );
+
+
+// #ifdef UNX
+// // cut /bin too
+// while( nPos-- && aPath[nPos] != PATH_DEL[0] )
+// ;
+// #endif
+
+// aPath.Erase( nPos );
+ aPath= aPath.copy( 0, nPos+1); // last character is the path delimiter
+ }
+
+ OUString aAppHome = OUString::createFromAscii( aPath );
+ // classpath is set by the java INI
+ // aClassPath += ENV_DEL + aAppHome + OUString::createFromAscii("classes") + PATH_DEL + OUString::createFromAscii("classes.jar");
+ // aClassPath += ENV_DEL + aAppHome + OUString::createFromAscii("classes") + PATH_DEL + OUString::createFromAscii("sandbox.jar");
+ }
+
+ return aClassPath;
+}
+*/
+
+JAVAVM * JavaVirtualMachine_Impl::createJavaVM( XSimpleRegistry* pJavaReg, XSimpleRegistry* pOfficeReg)
+{
+ try
+ {
+ JSettings aSettings;
+
+ try
+ {
+ Reference<XRegistryKey> xJavaIni( pJavaReg->getRootKey(), UNO_QUERY );
+
+ // test if Java is enabled
+ OUString aEntryValue = getValue( xJavaIni, OUString::createFromAscii("Java/Java") );
+
+ if ( aEntryValue.len() == 0 || aEntryValue == OUString::createFromAscii("0") ) throw VMException( -4, "Can't find entry \"Java\" in section \"Java\".");
+ if ( ! getSettings( aSettings, xJavaIni ) ) throw VMException( -5, "An exception occured while reading JVM settings.");
+
+#ifdef UNX
+ OUString usCompiler = getValue( xJavaIni, OUString::createFromAscii("Java/java.compiler") );
+
+ if ( usCompiler.len() != 0 )
+ aSettings.setCompiler( usCompiler );
+
+ aSettings.setCompiler(preOpen( aSettings.getDebug(),
+ aSettings.getLibraryPath(),
+ aSettings.getRuntimeLib(),
+ aSettings.getCompiler()
+ )
+ );
+#endif
+
+ sal_Bool bLoaded = aJavaLib.load( aSettings.getLibraryPath() + aSettings.getRuntimeLib() );
+
+ if ( !bLoaded )
+ {
+ throw VMException( -6, OUString::createFromAscii("can't load ") +
+ aSettings.getLibraryPath() +
+ aSettings.getRuntimeLib() );
+ }
+
+ JNI_InitArgs_Type * initArgs = (JNI_InitArgs_Type *) aJavaLib.getSymbol(OUString::createFromAscii("JNI_GetDefaultJavaVMInitArgs"));
+
+ if ( !initArgs ) throw VMException( -7, "can't load symbol \"JNI_GetDefaultJavaVMInitArgs\"." );
+
+ JVM jvm(initArgs);
+ readJavaSection( pJavaReg, &jvm );
+
+ if ( aSettings.getCompiler().len() )
+ {
+ jvm.setCompiler( aSettings.getCompiler() );
+ }
+
+ // read out the INet section in the soffice.ini / sofficerc
+ readINetSection( pOfficeReg, &jvm );
+ setLanguageAndCountrySection( pOfficeReg, &jvm );
+
+ // security settings
+ jvm.pushProp( OUString::createFromAscii("stardiv.security.defaultSecurityManager=true") );
+ jvm.pushProp( OUString::createFromAscii("stardiv.security.noExit=true") );
+ jvm.pushProp( OUString::createFromAscii("stardiv.controller.installConsole=true") );
+
+ OUString aClassPath( aSettings.classPath );
+ //aClassPath = aClassPath + pathExpansion();
+
+ jvm.classPath( OUStringToOString(aClassPath, RTL_TEXTENCODING_ASCII_US) );
+
+ jvm.abort(vm_abort);
+ jvm.exit(vm_exit);
+ jvm.vfprintf(vm_vfprintf);
+
+ setTimeZone( &jvm );
+
+ JNI_CreateVM_Type * pCreateJavaVM = (JNI_CreateVM_Type *) aJavaLib.getSymbol( OUString::createFromAscii("JNI_CreateJavaVM") );
+ if ( !pCreateJavaVM ) throw VMException( -8, "Can't load symbol \"JNI_CreateJavaVM\"." );
+
+ JNIEnv * pJNIEnv = NULL;
+ jint err = pCreateJavaVM( &pJavaVM, &pJNIEnv, (void *)jvm.getJDK1_1InitArgs() );
+
+ if ( err ) throw VMException( -9, "Can't create Java VM" );
+
+ initSJSettings( pJNIEnv );
+
+ }
+ catch ( InvalidRegistryException e )
+ {
+ }
+ }
+ catch ( VMException e )
+ {
+ setError( e.getErrNum() );
+ fprintf(stderr, "error - could not load java, cause %s.", e.what());
+ }
+
+ return pJavaVM;
+}
+
+void JavaVirtualMachine_Impl::disposeJavaVM()
+{
+ if ( pJavaVM )
+ {
+// pJavaVM->DestroyJavaVM();
+ pJavaVM = NULL;
+ }
+}
+
+OUString JavaVirtualMachine_Impl::getJavaIniFileName( const Reference<XSimpleRegistry>& xSofficeReg,
+ const Reference<XConfigManager>& xConfigManager )
+{
+ OUString iniFileName;
+ sal_Bool bIniFound = sal_False;
+
+ if ( xSofficeReg.is() && xSofficeReg->isValid() )
+ {
+ Reference<XRegistryKey> xRegistryRootKey = xSofficeReg->getRootKey();
+
+ if ( xRegistryRootKey.is() && xRegistryRootKey->isValid() )
+ {
+ try
+ {
+ ::osl::DirectoryItem aJavaIni;
+
+ try
+ {
+ OUString tmpFileName;
+ OUString fileName;
+ tmpFileName = getValue( xRegistryRootKey, OUString::createFromAscii("Directories/UserConfig-Path") );
+ tmpFileName = xConfigManager->substituteVariables( tmpFileName );
+
+ File::normalizePath( tmpFileName, fileName );
+ fileName += OUString::createFromAscii(SLASH_INI_FILE);
+ bIniFound = DirectoryItem::get( fileName, aJavaIni ) == FileBase::E_None;
+
+ }
+ catch ( Exception e )
+ {
+ bIniFound = sal_False;
+ }
+
+ if ( !bIniFound )
+ {
+ OUString tmpFileName;
+ OUString fileName;
+ tmpFileName = getValue( xRegistryRootKey, OUString::createFromAscii("Directories/Config-Dir") );
+ tmpFileName = xConfigManager->substituteVariables( tmpFileName );
+
+ File::normalizePath( tmpFileName, fileName );
+ fileName += OUString::createFromAscii(SLASH_INI_FILE);
+ bIniFound = DirectoryItem::get( fileName, aJavaIni ) == FileBase::E_None;
+ }
+
+ if ( bIniFound )
+ {
+ FileStatus fileStatus( FileStatusMask_FilePath /*FileStatusMask_NativePath*/ );
+
+ if ( FileBase::E_None == aJavaIni.getFileStatus( fileStatus ) )
+ iniFileName = fileStatus.getFilePath();
+ //iniFileName = fileStatus.getNativePath();
+ else
+ bIniFound = sal_False;
+ }
+
+ }
+ catch (Exception e)
+ {
+ bIniFound = sal_False;
+ }
+ }
+ }
+
+ if ( ! bIniFound )
+ {
+ iniFileName = OUString::createFromAscii("");
+ }
+
+ return iniFileName;
+}
+
+// ***************************************************************************************
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii("/") +
+ JavaVirtualMachine_Impl::getImplementationName_Static() +
+ OUString::createFromAscii("/UNO/SERVICES" )) );
+
+ const Sequence< OUString > & rSNL =
+ JavaVirtualMachine_Impl::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if ( JavaVirtualMachine_Impl::getImplementationName_Static().equals(OUString::createFromAscii(pImplName)) )
+ {
+ Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ JavaVirtualMachine_Impl::getImplementationName_Static(),
+ JavaVirtualMachine_Impl_createInstance,
+ JavaVirtualMachine_Impl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+#ifdef __cplusplus
+} // END of extern "C"
+#endif
+
diff --git a/stoc/source/javavm/jen.xml b/stoc/source/javavm/jen.xml
new file mode 100644
index 000000000000..02624e740613
--- /dev/null
+++ b/stoc/source/javavm/jen.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Juergen Schmidt </Author>
+
+<Name> com.sun.star.comp.stoc.JavaVirtualMachine </Name>
+
+<Description>
+ This component provides ...
+</Description>
+
+<ModuleName> jen </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> com.sun.star.java.JavaVirtualMachine </SupportedService>
+
+<ServiceDependency> ... </ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> tools </ProjectBuildDependency>
+<ProjectBuildDependency> vos </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu1 </RuntimeModuleDependency>
+<RuntimeModuleDependency> tl(COM) </RuntimeModuleDependency>
+<RuntimeModuleDependency> vos1$(COM) </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal1 </RuntimeModuleDependency>
+
+<Type> com.sun.star.java.XJavaVM </Type>
+<Type> com.sun.star.java.XJavaVM </Type>
+<Type> com.sun.star.java.XJavaThreadRegister_11 </Type>
+<Type> com.sun.star.frame.XConfigManager </Type>
+<Type> com.sun.star.container.XNameAccess </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.registry.XSimpleRegistry </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/stoc/source/javavm/jvmargs.cxx b/stoc/source/javavm/jvmargs.cxx
new file mode 100644
index 000000000000..8c28679e8e0d
--- /dev/null
+++ b/stoc/source/javavm/jvmargs.cxx
@@ -0,0 +1,303 @@
+/*************************************************************************
+ *
+ * $RCSfile: jvmargs.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "jvmargs.hxx"
+
+
+JVM::JVM(JNI_InitArgs_Type * pVMInitArgs)
+ : debug(sal_False)
+{
+ /*
+ ** The following is used to specify that we require at least
+ ** JNI version 1.1. Currently, this field is not checked but
+ ** will be starting with JDK/JRE 1.2. The value returned after
+ ** calling JNI_GetDefaultJavaVMInitArgs() is the actual JNI version
+ ** supported, and is always higher that the requested version.
+ */
+
+
+ jDK1_1InitArgs.version = JNI_VERSION_1_1;
+ pVMInitArgs(&jDK1_1InitArgs);
+
+ javaVMInitArgs.nOptions = 0;
+ javaVMInitArgs.options = NULL;
+ jiDebugPort = 1199;
+}
+
+JVM::~JVM()
+{
+ if(javaVMInitArgs.options)
+ {
+ for(size_t i = 0; i < javaVMInitArgs.nOptions; i++)
+ {
+ free(javaVMInitArgs.options[i].optionString);
+ }
+
+ free(javaVMInitArgs.options);
+ javaVMInitArgs.nOptions = 0;
+ javaVMInitArgs.options = NULL;
+ }
+
+ size_t i = 0;
+ if(jDK1_1InitArgs.properties)
+ {
+ while(jDK1_1InitArgs.properties[i])
+ free(jDK1_1InitArgs.properties[i ++]);
+
+ free(jDK1_1InitArgs.properties);
+ }
+}
+
+void JVM::pushPProp(OUString uString, void * extraInfo)
+{
+ JavaVMOption javaVMOption;
+
+ javaVMOption.optionString = strdup(OUStringToOString(uString, RTL_TEXTENCODING_ASCII_US));
+ javaVMOption.extraInfo = extraInfo;
+
+ p_props.push_back(javaVMOption);
+}
+
+void JVM::pushProp(const OUString & uString)
+{
+ props.push_back(uString);
+}
+
+void JVM::disableAsyncGC(jboolean jbFlag)
+{
+ jDK1_1InitArgs.disableAsyncGC = jbFlag;
+}
+
+void JVM::enableClassGC(jboolean jbFlag)
+{
+ jDK1_1InitArgs.enableClassGC = jbFlag;
+ if(!jbFlag)
+ {
+ OUString tmpStr( RTL_CONSTASCII_USTRINGPARAM("-Xnoclassgc") );
+ pushPProp(tmpStr);
+ }
+}
+
+void JVM::enableVerboseGC(jboolean jbFlag)
+{
+ jDK1_1InitArgs.enableVerboseGC = jbFlag;
+ pushPProp( OUString(RTL_CONSTASCII_USTRINGPARAM("-verbose:gc")));
+}
+
+void JVM::verbose(jboolean jbFlag)
+{
+ jDK1_1InitArgs.verbose = jbFlag;
+ pushPProp(OUString(RTL_CONSTASCII_USTRINGPARAM("-verbose:class")));
+}
+
+void JVM::nativeStackSize(jint jiSize)
+{
+ jDK1_1InitArgs.nativeStackSize = jiSize;
+}
+
+void JVM::javaStackSize(jint jiSize)
+{
+ jDK1_1InitArgs.javaStackSize = jiSize;
+}
+
+void JVM::verifyMode(OUString uStr)
+{
+ pushPProp( OUString(RTL_CONSTASCII_USTRINGPARAM("-Xverify:")) + uStr );
+
+ if( uStr.compareToAscii("none") == 0 )
+ jDK1_1InitArgs.verifyMode = 0;
+ else if( uStr.compareToAscii("remote") == 0)
+ jDK1_1InitArgs.verifyMode = 1;
+ else if( uStr.compareToAscii("all") == 0 )
+ jDK1_1InitArgs.verifyMode = 2;
+}
+
+void JVM::minHeapSize(jint jiSize)
+{
+ // Workaround ! Der neue Wert wird nur uebernommen, wenn dieser ueber dem
+ // DefaultSize ( 1 MB ) liegt. Ein zu kleiner initialer HeapSize f’hrt unter Solaris Sparc zum Deadlock.
+ if(jiSize > (sal_uInt32) jDK1_1InitArgs.minHeapSize)
+ jDK1_1InitArgs.minHeapSize = jiSize;
+
+ pushPProp( OUString(RTL_CONSTASCII_USTRINGPARAM("-Xms")) + OUString::valueOf((sal_Int32) jiSize) );
+}
+
+void JVM::maxHeapSize(jint jiSize)
+{
+ jDK1_1InitArgs.maxHeapSize = jiSize;
+ pushPProp( OUString(RTL_CONSTASCII_USTRINGPARAM("-Xmx")) + OUString::valueOf((sal_Int32)jiSize) );
+}
+
+void JVM::setDebug(sal_Bool flag)
+{
+ fprintf(stderr, "#### JVM::setDebug: %d\n", flag);
+ debug = flag;
+}
+
+sal_Bool JVM::getDebug()
+{
+ return debug;
+}
+
+void JVM::setDebugPort(jint jiPort)
+{
+ jiDebugPort = jiPort;
+}
+
+void JVM::setCompiler(const OUString & usCompiler)
+{
+ this->usCompiler = usCompiler;
+}
+
+OUString JVM::getCompiler()
+{
+ return usCompiler;
+}
+
+void JVM::classPath( OString str )
+{
+// jDK1_1InitArgs.classpath = strdup(str.GetStr());
+ jDK1_1InitArgs.classpath = strdup(str);
+ pushPProp( OUString(RTL_CONSTASCII_USTRINGPARAM("java.class.path=")) + OStringToOUString(str, RTL_TEXTENCODING_ASCII_US ) );
+}
+
+void JVM::vfprintf(JNIvfprintf vfprintf)
+{
+ jDK1_1InitArgs.vfprintf = vfprintf;
+ pushPProp( OUString(RTL_CONSTASCII_USTRINGPARAM("vfprintf")), (void *)vfprintf );
+}
+
+void JVM::exit(JNIexit exit)
+{
+ jDK1_1InitArgs.exit = exit;
+ pushPProp( OUString(RTL_CONSTASCII_USTRINGPARAM("exit")), (void *)exit );
+}
+
+void JVM::abort(JNIabort abort)
+{
+ jDK1_1InitArgs.abort = abort;
+ pushPProp( OUString(RTL_CONSTASCII_USTRINGPARAM("abort=")), (void *)abort );
+}
+
+
+const JDK1_1InitArgs * JVM::getJDK1_1InitArgs()
+{
+ if( usCompiler.getLength() )
+ pushProp( OUString(RTL_CONSTASCII_USTRINGPARAM("java.compiler=")) + usCompiler);
+
+ if(debug)
+ {
+ jDK1_1InitArgs.debugging = JNI_TRUE;
+ jDK1_1InitArgs.debugPort = jiDebugPort;
+ pushPProp( OUString(RTL_CONSTASCII_USTRINGPARAM("-Xdebug")), &jiDebugPort);
+ }
+
+ if(!jDK1_1InitArgs.properties)
+ {
+ size_t size = props.size() + 1;
+ jDK1_1InitArgs.properties = (char **) calloc(sizeof(const char *), props.size() + 1);
+
+ for(size_t i = 0; i < props.size(); i++)
+ {
+ OUString str = props[i];
+
+ jDK1_1InitArgs.properties[i] = strdup( OUStringToOString(str, RTL_TEXTENCODING_ASCII_US) );
+ }
+
+ jDK1_1InitArgs.properties[props.size()] = NULL;
+ }
+
+ return &jDK1_1InitArgs;
+}
+
+const JavaVMInitArgs * JVM::getJavaVMInitArgs()
+{
+ if(usCompiler.getLength())
+ pushProp( OUString(RTL_CONSTASCII_USTRINGPARAM("java.compiler=")) + usCompiler);
+
+ javaVMInitArgs.version = JNI_VERSION_1_2;
+ javaVMInitArgs.nOptions = props.size() + p_props.size();
+ javaVMInitArgs.ignoreUnrecognized = JNI_TRUE;
+
+ javaVMInitArgs.options = (JavaVMOption *)calloc(sizeof(JavaVMOption), javaVMInitArgs.nOptions);
+
+ size_t i;
+
+ for(i = 0; i < p_props.size(); i++)
+ {
+ javaVMInitArgs.options[i] = p_props[i];
+ }
+
+
+ for(;i < javaVMInitArgs.nOptions; i++)
+ {
+ OUString str = props[i - p_props.size()];
+
+ if( str.copy(0, 2).compareToAscii("-D") != 0 && str.copy(0, 2).compareToAscii("-X") != 0 )
+ str = OUString(RTL_CONSTASCII_USTRINGPARAM("-D")) + str;
+
+ javaVMInitArgs.options[i].optionString = strdup( OUStringToOString(str, RTL_TEXTENCODING_ASCII_US) );
+ javaVMInitArgs.options[i].extraInfo = NULL;
+ }
+
+ return &javaVMInitArgs;
+}
+
diff --git a/stoc/source/javavm/jvmargs.hxx b/stoc/source/javavm/jvmargs.hxx
new file mode 100644
index 000000000000..617755fba8cf
--- /dev/null
+++ b/stoc/source/javavm/jvmargs.hxx
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * $RCSfile: jvmargs.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef __JVM
+#define __JVM
+
+#if STLPORT_VERSION < 321
+#include <tools/presys.h>
+#include <vector.h>
+#include <tools/postsys.h>
+#else
+#include <cstdarg>
+#include <stl/vector>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#include "jni.h"
+
+using namespace ::rtl;
+
+#ifndef JNI_VERSION_1_2
+
+#define JNI_VERSION_1_1 0x00010001
+#define JNI_VERSION_1_2 0x00010002
+
+#define JNI_EDETACHED (-2) /* thread detached from the VM */
+#define JNI_EVERSION (-3) /* JNI version error */
+#define JNI_ENOMEM (-4) /* not enough memory */
+#define JNI_EEXIST (-5) /* VM already created */
+#define JNI_EINVAL (-6) /* invalid arguments */
+
+
+struct JNIInvokeInterface12_;
+struct JavaVM12_;
+
+typedef JavaVM12_ JavaVM12;
+#define JAVAVM JavaVM12
+
+struct JNIInvokeInterface12_
+{
+ void *reserved0;
+ void *reserved1;
+ void *reserved2;
+
+ jint (JNICALL *DestroyJavaVM)(JavaVM12 *vm);
+ jint (JNICALL *AttachCurrentThread)(JavaVM12 *vm, void **penv, void *args);
+ jint (JNICALL *DetachCurrentThread)(JavaVM12 *vm);
+ jint (JNICALL *GetEnv)(JavaVM12 *vm, void **penv, jint version);
+};
+
+struct JavaVM12_
+{
+ const struct JNIInvokeInterface12_ *functions;
+
+ jint DestroyJavaVM()
+ {
+ return functions->DestroyJavaVM(this);
+ }
+
+ jint AttachCurrentThread(void **penv, void *args)
+ {
+ return functions->AttachCurrentThread(this, penv, args);
+ }
+
+ jint DetachCurrentThread()
+ {
+ return functions->DetachCurrentThread(this);
+ }
+
+ jint GetEnv(void **penv, jint version)
+ {
+ return functions->GetEnv(this, penv, version);
+ }
+};
+
+typedef struct JavaVMOption
+{
+ char *optionString;
+ void *extraInfo;
+} JavaVMOption;
+
+typedef struct JavaVMInitArgs
+{
+ jint version;
+
+ jint nOptions;
+ JavaVMOption *options;
+ jboolean ignoreUnrecognized;
+} JavaVMInitArgs;
+
+typedef struct JavaVMAttachArgs
+{
+ jint version;
+
+ char *name;
+ jobject group;
+} JavaVMAttachArgs;
+
+#else
+#define JAVAVM JavaVM
+#endif
+
+typedef jint (JNICALL *JNIvfprintf)(FILE *fp, const char *format, va_list args);
+typedef void (JNICALL *JNIexit)(jint code);
+typedef void (JNICALL *JNIabort)(void);
+
+extern "C" {
+
+#ifdef OS2
+typedef jint JNICALL0 JNI_InitArgs_Type(void *);
+typedef jint JNICALL0 JNI_CreateVM_Type(JAVAVM **, JNIEnv **, void *);
+#else
+typedef jint JNICALL JNI_InitArgs_Type(void *);
+typedef jint JNICALL JNI_CreateVM_Type(JAVAVM **, JNIEnv **, void *);
+#endif
+
+}
+
+class JVM
+{
+ ::std::vector<JavaVMOption> p_props;
+
+ JavaVMInitArgs javaVMInitArgs;
+ JDK1_1InitArgs jDK1_1InitArgs;
+
+ ::std::vector<OUString> props;
+
+ sal_Bool debug;
+ jint jiDebugPort;
+ OUString usCompiler;
+
+protected:
+ void pushPProp(OUString uString, void * extraInfo = NULL);
+
+public:
+ JVM(JNI_InitArgs_Type * pVMInitArgs) ;
+ ~JVM() ;
+
+ void pushProp(const OUString & uString);
+
+ void disableAsyncGC(jboolean jbFlag);
+ void enableClassGC(jboolean jbFlag);
+ void enableVerboseGC(jboolean jbFlag);
+ void verbose(jboolean jbFlag);
+
+ void setCompiler(const OUString & usCompiler);
+ void nativeStackSize(jint jiSize);
+ void javaStackSize(jint jiSize);
+ void verifyMode(OUString uStr);
+ void minHeapSize(jint jiSize);
+ void maxHeapSize(jint jiSize);
+ void setDebug(sal_Bool flag);
+ void setDebugPort(jint jiDebugPort);
+ void classPath(OString str);
+ void vfprintf(JNIvfprintf vfprintf);
+ void exit(JNIexit exit);
+ void abort(JNIabort abort);
+
+ sal_Bool getDebug();
+ OUString getCompiler();
+
+ const JavaVMInitArgs * getJavaVMInitArgs();
+
+ const JDK1_1InitArgs * getJDK1_1InitArgs();
+};
+
+#endif
diff --git a/stoc/source/javavm/makefile.mk b/stoc/source/javavm/makefile.mk
new file mode 100644
index 000000000000..6016289ff455
--- /dev/null
+++ b/stoc/source/javavm/makefile.mk
@@ -0,0 +1,147 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=stoc
+TARGET=jen
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+# Kollision zwischen bool.h aus Java und bool.h aus der STL.
+# Das Problem tritt fuer alle Plattformen auf, aber anscheinend stolpert nur der
+# GCC darueber
+.IF "$(COM)" == "GCC"
+CDEFS += -D__SGI_STL_BOOL_H
+.ENDIF
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES= \
+ com.sun.star.uno.Exception \
+ com.sun.star.uno.XInterface \
+ com.sun.star.java.XJavaVM \
+ com.sun.star.uno.XWeak \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.java.XJavaThreadRegister_11 \
+ com.sun.star.lang.XServiceInfo \
+ com.sun.star.lang.XTypeProvider \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.container.XNameAccess \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.registry.XRegistryKey \
+ com.sun.star.registry.XSimpleRegistry \
+ com.sun.star.frame.XConfigManager
+
+SLOFILES= \
+ $(SLO)$/settings.obj \
+ $(SLO)$/javavm.obj \
+ $(SLO)$/jvmargs.obj \
+ $(SLO)$/jen_desc.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(UNOLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="WNT"
+SHL1STDLIBS += advapi32.lib
+.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : $(BIN)$/jen.rdb \
+ $(MISC)$/jen_desc.cxx \
+ ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+$(BIN)$/jen.rdb: $(SOLARBINDIR)$/applicat.rdb
+ +rdbmaker -BUCR -O$(BIN)$/jen.rdb $(foreach,i,$(UNOTYPES) -T$i ) $(SOLARBINDIR)$/applicat.rdb
+
+$(MISC)$/jen_desc.cxx: jen.xml
+ +xml2cmp -func $(MISC)$/jen_desc.cxx jen.xml
+
+
diff --git a/stoc/source/loader/dllcomponentloader.cxx b/stoc/source/loader/dllcomponentloader.cxx
new file mode 100644
index 000000000000..50374afca311
--- /dev/null
+++ b/stoc/source/loader/dllcomponentloader.cxx
@@ -0,0 +1,560 @@
+/*************************************************************************
+ *
+ * $RCSfile: dllcomponentloader.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MODULE_H_
+#include <osl/module.h>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#ifndef _UNO_ENVIRONMENT_H_
+#include <uno/environment.h>
+#endif
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+#include <com/sun/star/loader/XImplementationLoader.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::loader;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace cppu;
+using namespace rtl;
+
+namespace stoc_loader
+{
+
+#define SERVICENAME "com.sun.star.loader.SharedLibrary"
+#define IMPLNAME "com.sun.star.comp.stoc.DLLComponentLoader"
+
+//*************************************************************************
+// DllComponentLoader
+//*************************************************************************
+class DllComponentLoader
+ : public WeakImplHelper3< XImplementationLoader,
+ XInitialization,
+ XServiceInfo >
+{
+public:
+ DllComponentLoader( const Reference<XMultiServiceFactory> & rXSMgr );
+ ~DllComponentLoader();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( );
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XImplementationLoader
+ virtual Reference<XInterface> SAL_CALL activate( const OUString& implementationName, const OUString& implementationLoaderUrl, const OUString& locationUrl, const Reference<XRegistryKey>& xKey ) throw(CannotActivateFactoryException, RuntimeException);
+ virtual sal_Bool SAL_CALL writeRegistryInfo( const Reference<XRegistryKey>& xKey, const OUString& implementationLoaderUrl, const OUString& locationUrl ) throw(CannotRegisterImplementationException, RuntimeException);
+
+private:
+ Reference<XMultiServiceFactory> m_xSMgr;
+};
+
+//*************************************************************************
+DllComponentLoader::DllComponentLoader( const Reference<XMultiServiceFactory> & rXSMgr )
+ : m_xSMgr( rXSMgr )
+{
+}
+
+//*************************************************************************
+DllComponentLoader::~DllComponentLoader()
+{
+}
+
+//*************************************************************************
+OUString SAL_CALL DllComponentLoader::getImplementationName( )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL DllComponentLoader::supportsService( const OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL DllComponentLoader::getSupportedServiceNames( )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL DllComponentLoader::getSupportedServiceNames_Static( )
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//*************************************************************************
+void DllComponentLoader::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArgs )
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ if( aArgs.getLength() != 1 )
+ {
+ throw IllegalArgumentException();
+ }
+
+ Reference< XMultiServiceFactory > rServiceManager;
+
+ if( aArgs.getConstArray()[0].getValueType().getTypeClass() == TypeClass_INTERFACE )
+ {
+ aArgs.getConstArray()[0] >>= rServiceManager;
+ }
+
+ if( !rServiceManager.is() )
+ {
+ throw IllegalArgumentException();
+ }
+
+ m_xSMgr = rServiceManager;
+}
+
+//*************************************************************************
+Reference<XInterface> SAL_CALL DllComponentLoader::activate(
+ const OUString & rImplName, const OUString &, const OUString & rLibName,
+ const Reference< XRegistryKey > & xKey )
+
+ throw(CannotActivateFactoryException, RuntimeException)
+{
+ Reference< XSingleServiceFactory > xRet;
+ OUString sMessage;
+
+ oslModule lib = osl_loadModule( rLibName.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
+
+ if (lib)
+ {
+ void * pSym;
+
+ // ========================= LATEST VERSION =========================
+ OUString aGetEnvName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_GETENV) );
+ if (pSym = osl_getSymbol( lib, aGetEnvName.pData ))
+ {
+ uno_Environment * pCurrentEnv = 0;
+ uno_Environment * pEnv = 0;
+ const sal_Char * pEnvTypeName = 0;
+ (*((component_getImplementationEnvironmentFunc)pSym))( &pEnvTypeName, &pEnv );
+
+ sal_Bool bNeedsMapping =
+ (pEnv || 0 != rtl_str_compare( pEnvTypeName, CPPU_CURRENT_LANGUAGE_BINDING_NAME ));
+
+ OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) );
+
+ if (bNeedsMapping)
+ {
+ if (! pEnv)
+ uno_getEnvironment( &pEnv, aEnvTypeName.pData, 0 );
+ if (pEnv)
+ {
+ OUString aCppEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ uno_getEnvironment( &pCurrentEnv, aCppEnvTypeName.pData, 0 );
+ if (pCurrentEnv)
+ bNeedsMapping = (pEnv != pCurrentEnv);
+ }
+ }
+
+ OUString aGetFactoryName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_GETFACTORY) );
+ if (pSym = osl_getSymbol( lib, aGetFactoryName.pData ))
+ {
+ OString aImplName( OUStringToOString( rImplName, RTL_TEXTENCODING_ASCII_US ) );
+
+ if (bNeedsMapping)
+ {
+ if (pEnv && pCurrentEnv)
+ {
+ Mapping aCurrent2Env( pCurrentEnv, pEnv );
+ Mapping aEnv2Current( pEnv, pCurrentEnv );
+
+ if (aCurrent2Env.is() && aEnv2Current.is())
+ {
+ void * pSMgr = aCurrent2Env.mapInterface(
+ m_xSMgr.get(), ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ) );
+ void * pKey = aCurrent2Env.mapInterface(
+ xKey.get(), ::getCppuType( (const Reference< XRegistryKey > *)0 ) );
+
+ void * pSSF = (*((component_getFactoryFunc)pSym))(
+ aImplName.getStr(), pSMgr, pKey );
+
+ if (pKey)
+ (*pEnv->pExtEnv->releaseInterface)( pEnv->pExtEnv, pKey );
+ if (pSMgr)
+ (*pEnv->pExtEnv->releaseInterface)( pEnv->pExtEnv, pSMgr );
+
+ if (pSSF)
+ {
+ XSingleServiceFactory * pRet = (XSingleServiceFactory *)
+ aEnv2Current.mapInterface(
+ pSSF, ::getCppuType( (const Reference< XSingleServiceFactory > *)0 ) );
+ if (pRet)
+ {
+ xRet = pRet;
+ pRet->release();
+ }
+ (*pEnv->pExtEnv->releaseInterface)( pEnv->pExtEnv, pSSF );
+ }
+ }
+ }
+ }
+ else
+ {
+ XSingleServiceFactory * pRet = (XSingleServiceFactory *)
+ (*((component_getFactoryFunc)pSym))(
+ aImplName.getStr(), m_xSMgr.get(), xKey.get() );
+ if (pRet)
+ {
+ xRet = pRet;
+ pRet->release();
+ }
+ }
+ } else
+ {
+ sMessage = OUString::createFromAscii("symbol \"");
+ sMessage += aGetFactoryName;
+ sMessage += OUString::createFromAscii("\" could not be found in \"");
+ sMessage += rLibName;
+ sMessage += OUString::createFromAscii("\"");
+ }
+
+ if (pEnv)
+ (*pEnv->release)( pEnv );
+ if (pCurrentEnv)
+ (*pCurrentEnv->release)( pCurrentEnv );
+ }
+ else
+ {
+ sMessage = OUString::createFromAscii("symbol \"");
+ sMessage += aGetEnvName;
+ sMessage += OUString::createFromAscii("\" could not be found in \"");
+ sMessage += rLibName;
+ sMessage += OUString::createFromAscii("\"");
+ }
+
+ if (!xRet.is() && !sMessage.getLength())
+ {
+ sMessage = OUString::createFromAscii("got no factory from component \"");
+ sMessage += rLibName;
+ sMessage += OUString::createFromAscii("\"!");
+ }
+
+ if (! xRet.is())
+ osl_unloadModule( lib );
+ } else
+ {
+ sMessage = OUString::createFromAscii("component library \"");
+ sMessage += rLibName;
+ sMessage += OUString::createFromAscii("\" could not be loaded");
+ }
+
+ if (! xRet.is())
+ {
+ CannotActivateFactoryException e;
+ e.Message = OUString( RTL_CONSTASCII_USTRINGPARAM("component could not be activated: ") ) + sMessage;
+ throw e;
+ }
+
+ return xRet;
+}
+
+
+//*************************************************************************
+sal_Bool SAL_CALL DllComponentLoader::writeRegistryInfo(
+ const Reference< XRegistryKey > & xKey, const OUString &, const OUString & rLibName )
+
+ throw(CannotRegisterImplementationException, RuntimeException)
+{
+ sal_Bool bRet = sal_False;
+ OUString sMessage;
+
+ oslModule lib = osl_loadModule( rLibName.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
+
+ if (lib)
+ {
+ void * pSym;
+
+ // ========================= LATEST VERSION =========================
+ OUString aGetEnvName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_GETENV) );
+ if (pSym = osl_getSymbol( lib, aGetEnvName.pData ))
+ {
+ uno_Environment * pCurrentEnv = 0;
+ uno_Environment * pEnv = 0;
+ const sal_Char * pEnvTypeName = 0;
+ (*((component_getImplementationEnvironmentFunc)pSym))( &pEnvTypeName, &pEnv );
+
+ sal_Bool bNeedsMapping =
+ (pEnv || 0 != rtl_str_compare( pEnvTypeName, CPPU_CURRENT_LANGUAGE_BINDING_NAME ));
+
+ OUString aEnvTypeName( OUString::createFromAscii( pEnvTypeName ) );
+
+ if (bNeedsMapping)
+ {
+ if (! pEnv)
+ uno_getEnvironment( &pEnv, aEnvTypeName.pData, 0 );
+ if (pEnv)
+ {
+ OUString aCppEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ uno_getEnvironment( &pCurrentEnv, aCppEnvTypeName.pData, 0 );
+ if (pCurrentEnv)
+ bNeedsMapping = (pEnv != pCurrentEnv);
+ }
+ }
+
+ OUString aWriteInfoName( RTL_CONSTASCII_USTRINGPARAM(COMPONENT_WRITEINFO) );
+ if (pSym = osl_getSymbol( lib, aWriteInfoName.pData ))
+ {
+ if (bNeedsMapping)
+ {
+ if (pEnv && pCurrentEnv)
+ {
+ Mapping aCurrent2Env( pCurrentEnv, pEnv );
+ if (aCurrent2Env.is())
+ {
+ void * pSMgr = aCurrent2Env.mapInterface(
+ m_xSMgr.get(), ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ) );
+ void * pKey = aCurrent2Env.mapInterface(
+ xKey.get(), ::getCppuType( (const Reference< XRegistryKey > *)0 ) );
+ // key is mandatory
+ if (pKey)
+ {
+ bRet = (*((component_writeInfoFunc)pSym))( pSMgr, pKey );
+ (*pEnv->pExtEnv->releaseInterface)( pEnv->pExtEnv, pKey );
+ }
+
+ if (pSMgr)
+ (*pEnv->pExtEnv->releaseInterface)( pEnv->pExtEnv, pSMgr );
+ }
+ }
+ }
+ else
+ {
+ // key is mandatory
+ if (xKey.is())
+ bRet = (*((component_writeInfoFunc)pSym))( m_xSMgr.get(), xKey.get() );
+ }
+ } else
+ {
+ sMessage = OUString::createFromAscii("symbol \"");
+ sMessage += aWriteInfoName;
+ sMessage += OUString::createFromAscii("\" could not be found in \"");
+ sMessage += rLibName;
+ sMessage += OUString::createFromAscii("\"");
+ }
+
+ if (pEnv)
+ (*pEnv->release)( pEnv );
+ if (pCurrentEnv)
+ (*pCurrentEnv->release)( pCurrentEnv );
+ }
+ else
+ {
+ sMessage = OUString::createFromAscii("symbol \"");
+ sMessage += aGetEnvName;
+ sMessage += OUString::createFromAscii("\" could not be found in \"");
+ sMessage += rLibName;
+ sMessage += OUString::createFromAscii("\"");
+ }
+
+ if (!bRet && !sMessage.getLength())
+ {
+ sMessage = OUString::createFromAscii("calling symbol \"");
+ sMessage += OUString::createFromAscii( COMPONENT_WRITEINFO );
+ sMessage += OUString::createFromAscii("\" found in \"");
+ sMessage += rLibName;
+ sMessage += OUString::createFromAscii("\" returned FALSE");
+ }
+ } else
+ {
+ sMessage = OUString::createFromAscii("component library \"");
+ sMessage += rLibName;
+ sMessage += OUString::createFromAscii("\" could not be loaded");
+ }
+
+ if (! bRet)
+ {
+ CannotRegisterImplementationException e;
+ e.Message = OUString( RTL_CONSTASCII_USTRINGPARAM("component could not be registered: ") ) + sMessage;
+ throw e;
+ }
+
+ return bRet;
+}
+
+
+//*************************************************************************
+Reference<XInterface> SAL_CALL DllComponentLoader_CreateInstance( const Reference<XMultiServiceFactory> & rSMgr ) throw(Exception)
+{
+ Reference<XInterface> xRet;
+
+ XImplementationLoader *pXLoader = (XImplementationLoader *)new DllComponentLoader(rSMgr);
+
+ if (pXLoader)
+ {
+ xRet = Reference<XInterface>::query(pXLoader);
+ }
+
+ return xRet;
+}
+
+}
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL =
+ ::stoc_loader::DllComponentLoader::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
+ ::stoc_loader::DllComponentLoader_CreateInstance,
+ ::stoc_loader::DllComponentLoader::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
+
+
diff --git a/stoc/source/loader/makefile.mk b/stoc/source/loader/makefile.mk
new file mode 100644
index 000000000000..fe8393882519
--- /dev/null
+++ b/stoc/source/loader/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= cpld
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+BOOTSTRAP_SERVICE=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+SLOFILES= \
+ $(SLO)$/dllcomponentloader.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(VOSLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/source/namingservice/makefile.mk b/stoc/source/namingservice/makefile.mk
new file mode 100644
index 000000000000..381a73adb179
--- /dev/null
+++ b/stoc/source/namingservice/makefile.mk
@@ -0,0 +1,105 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= namingservice
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+SLOFILES= \
+ $(SLO)$/namingservice.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/source/namingservice/namingservice.cxx b/stoc/source/namingservice/namingservice.cxx
new file mode 100644
index 000000000000..6c351fc6d3bc
--- /dev/null
+++ b/stoc/source/namingservice/namingservice.cxx
@@ -0,0 +1,301 @@
+/*************************************************************************
+ *
+ * $RCSfile: namingservice.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stl/hash_map>
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+using namespace cppu;
+using namespace rtl;
+using namespace osl;
+using namespace std;
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+#define SERVICENAME "com.sun.star.uno.NamingService"
+#define IMPLNAME "com.sun.star.comp.stoc.NamingService"
+
+namespace stoc_namingservice
+{
+
+struct equalOWString_Impl
+{
+ sal_Bool operator()(const OUString & s1, const OUString & s2) const
+ { return s1 == s2; }
+};
+
+struct hashOWString_Impl
+{
+ size_t operator()(const OUString & rName) const
+ { return rName.hashCode(); }
+};
+
+typedef hash_map
+<
+ OUString,
+ Reference<XInterface >,
+ hashOWString_Impl,
+ equalOWString_Impl
+> HashMap_OWString_Interface;
+
+//==================================================================================================
+class NamingService_Impl
+ : public WeakImplHelper2 < XServiceInfo, XNamingService >
+{
+ Mutex aMutex;
+ HashMap_OWString_Interface aMap;
+public:
+ NamingService_Impl();
+ ~NamingService_Impl();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static()
+ {
+ OUString aStr( OUString::createFromAscii( SERVICENAME ) );
+ return Sequence< OUString >( &aStr, 1 );
+ }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRegisteredObject( const ::rtl::OUString& Name );
+ virtual void SAL_CALL registerObject( const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Object );
+ virtual void SAL_CALL revokeObject( const ::rtl::OUString& Name );
+};
+
+//==================================================================================================
+static Reference<XInterface> SAL_CALL NamingService_Impl_create( const Reference<XMultiServiceFactory> & )
+{
+ static Reference<XNamingService> * pNS = 0;
+
+ if( !pNS )
+ {
+ Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
+ // only one Naming Service for the hole process
+ static Reference<XNamingService> xNS = new NamingService_Impl();
+ pNS = &xNS;
+ }
+
+ return *pNS;
+}
+
+//==================================================================================================
+NamingService_Impl::NamingService_Impl()
+{
+}
+
+//==================================================================================================
+NamingService_Impl::~NamingService_Impl()
+{
+}
+
+// XServiceInfo
+OUString NamingService_Impl::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return OUString::createFromAscii( IMPLNAME );
+}
+
+// XServiceInfo
+sal_Bool NamingService_Impl::supportsService( const OUString & rServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ {
+ if (pArray[nPos] == rServiceName)
+ return sal_True;
+ }
+ return sal_False;
+}
+
+// XServiceInfo
+Sequence< OUString > NamingService_Impl::getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+// XServiceInfo
+Reference< XInterface > NamingService_Impl::getRegisteredObject( const OUString& Name )
+{
+ Guard< Mutex > aGuard( aMutex );
+ Reference< XInterface > xRet;
+ HashMap_OWString_Interface::iterator aIt = aMap.find( Name );
+ if( aIt != aMap.end() )
+ xRet = (*aIt).second;
+ return xRet;
+}
+
+// XServiceInfo
+void NamingService_Impl::registerObject( const OUString& Name, const Reference< XInterface >& Object )
+{
+ Guard< Mutex > aGuard( aMutex );
+ aMap[ Name ] = Object;
+}
+
+// XServiceInfo
+void NamingService_Impl::revokeObject( const OUString& Name )
+{
+ Guard< Mutex > aGuard( aMutex );
+ aMap.erase( Name );
+}
+
+}
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ // NamingService
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii( "/" IMPLNAME "/UNO/SERVICES" ) ) );
+
+ Sequence< OUString > & rSNL =
+ ::stoc_namingservice::NamingService_Impl::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ ::stoc_namingservice::NamingService_Impl_create,
+ ::stoc_namingservice::NamingService_Impl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
diff --git a/stoc/source/namingservice/namingservice.xml b/stoc/source/namingservice/namingservice.xml
new file mode 100644
index 000000000000..a76cd213abd2
--- /dev/null
+++ b/stoc/source/namingservice/namingservice.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Juergen Schmidt </Author>
+
+<Name> com.sun.star.comp.stoc.NamingService </Name>
+
+<Description>
+ This component provides ...
+</Description>
+
+<ModuleName> namingservice </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> com.sun.star.uno.NamingService </SupportedService>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu1 </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal1 </RuntimeModuleDependency>
+
+<Type> com.sun.star.lang.XComponent </Type>
+<Type> com.sun.star.lang.IllegalArgumentException </Type>
+<Type> com.sun.star.lang.XInitialization </Type>
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> com.sun.star.uno.XNamingService </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/stoc/source/proxy_factory/makefile.mk b/stoc/source/proxy_factory/makefile.mk
new file mode 100644
index 000000000000..819e463ba543
--- /dev/null
+++ b/stoc/source/proxy_factory/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:34 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=stoc
+TARGET=proxyfac
+USE_DEFFILE=TRUE
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/proxyfac.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET=$(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB=i$(TARGET)
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/stoc/source/proxy_factory/proxyfac.cxx b/stoc/source/proxy_factory/proxyfac.cxx
new file mode 100644
index 000000000000..41c904127ef2
--- /dev/null
+++ b/stoc/source/proxy_factory/proxyfac.cxx
@@ -0,0 +1,459 @@
+/*************************************************************************
+ *
+ * $RCSfile: proxyfac.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+
+#include <uno/dispatcher.h>
+#include <uno/data.h>
+#include <uno/any2.h>
+#include <uno/mapping.hxx>
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/weakagg.hxx>
+#include <cppuhelper/queryinterface.hxx>
+
+#include <stl/vector>
+
+#include <com/sun/star/uno/XAggregation.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/util/XProxyFactory.hpp>
+
+using namespace std;
+using namespace rtl;
+using namespace osl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::util;
+using namespace com::sun::star::registry;
+
+#define SERVICENAME "com.sun.star.util.ProxyFactory"
+#define IMPLNAME "com.sun.star.comp.util.ProxyFactory"
+
+namespace stoc_proxyfac
+{
+
+//--------------------------------------------------------------------------------------------------
+static inline uno_Interface * uno_queryInterface(
+ uno_Interface * pUnoI, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ uno_Interface * pRet = 0;
+
+ void * pArgs[1];
+
+ typelib_InterfaceTypeDescription * pTXInterfaceDescr = 0;
+ const Type & rXIType = ::getCppuType( (const Reference<XInterface > *)0 );
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pTXInterfaceDescr, rXIType.getTypeLibType() );
+ OSL_ASSERT( pTXInterfaceDescr->ppAllMembers );
+ typelib_TypeDescription * pMTqueryInterface = 0;
+ TYPELIB_DANGER_GET( &pMTqueryInterface, pTXInterfaceDescr->ppAllMembers[0] );
+
+ Type aType( ((typelib_TypeDescription *)pTypeDescr)->pWeakRef );
+ pArgs[0] = &aType;
+
+ uno_Any aRetI, aExc;
+ uno_Any * pExc = &aExc;
+
+ (*((uno_Interface *)pUnoI)->pDispatcher)(
+ (uno_Interface *)pUnoI, pMTqueryInterface, &aRetI, pArgs, &pExc );
+
+ OSL_ENSHURE( !pExc, "### Exception occured during queryInterface()!" );
+ if (pExc) // cleanup exception
+ {
+ uno_any_destruct( pExc, 0 );
+ }
+ else
+ {
+ if (aRetI.pType->eTypeClass == typelib_TypeClass_INTERFACE)
+ {
+ pRet = *(uno_Interface **)aRetI.pData;
+ (*pRet->acquire)( pRet );
+ }
+ uno_any_destruct( &aRetI, 0 );
+ }
+
+ TYPELIB_DANGER_RELEASE( pMTqueryInterface );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pTXInterfaceDescr );
+ return pRet;
+}
+
+struct ProxyRoot;
+struct FactoryImpl;
+
+//==================================================================================================
+struct uno_Proxy : public uno_Interface
+{
+ ProxyRoot * pRoot;
+ uno_Interface * pTarget;
+ typelib_InterfaceTypeDescription * pTypeDescr;
+};
+typedef vector< uno_Proxy * > t_InterfaceVector;
+
+//==================================================================================================
+struct ProxyRoot : public OWeakAggObject
+{
+ FactoryImpl * pFactory;
+ Mutex aMutex;
+ t_InterfaceVector aInterfaces;
+
+ uno_Interface * pTarget;
+
+ inline ProxyRoot( FactoryImpl * pFactory_, const Reference< XInterface > & xTarget_ );
+ virtual ~ProxyRoot();
+
+ virtual Any SAL_CALL queryAggregation( const Type & rType ) throw (RuntimeException);
+};
+//==================================================================================================
+struct FactoryImpl : public WeakImplHelper2< XServiceInfo, XProxyFactory >
+{
+ Mapping aUno2Cpp;
+ Mapping aCpp2Uno;
+
+ FactoryImpl();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException);
+
+ // XProxyFactory
+ virtual Reference< XAggregation > SAL_CALL createProxy( const Reference< XInterface > & xTarget ) throw (RuntimeException);
+};
+
+extern "C"
+{
+//__________________________________________________________________________________________________
+static void SAL_CALL uno_proxy_dispatch(
+ uno_Interface * pUnoI, const typelib_TypeDescription * pMemberType,
+ void * pReturn, void * pArgs[], uno_Any ** ppException )
+{
+ uno_Proxy * pThis = static_cast< uno_Proxy * >( pUnoI );
+
+ try
+ {
+ switch (((typelib_InterfaceMemberTypeDescription *)pMemberType)->nPosition)
+ {
+ case 0: // queryInterface()
+ {
+ Any aRet( pThis->pRoot->queryInterface( * reinterpret_cast< const Type * >( pArgs[0] ) ) );
+ const Type & rAnyType = ::getCppuType( &aRet );
+ uno_type_copyAndConvertData(
+ pReturn, &aRet, rAnyType.getTypeLibType(), pThis->pRoot->pFactory->aCpp2Uno.get() );
+ *ppException = 0; // no exc
+ break;
+ }
+ case 1: // acquire()
+ pThis->pRoot->acquire();
+ *ppException = 0; // no exc
+ break;
+ case 2: // release()
+ pThis->pRoot->release();
+ *ppException = 0; // no exc
+ break;
+ default:
+ (*pThis->pTarget->pDispatcher)( pThis->pTarget, pMemberType, pReturn, pArgs, ppException );
+ }
+ }
+ catch (...)
+ {
+ RuntimeException aExc;
+ aExc.Message = OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected exception occured!" ) );
+ aExc.Context = (XAggregation *)pThis->pRoot;
+ const Type & rExcType = ::getCppuType( &aExc );
+ uno_type_any_constructAndConvert( *ppException, &aExc, rExcType.getTypeLibType(),
+ pThis->pRoot->pFactory->aCpp2Uno.get() );
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL uno_proxy_acquire( uno_Interface * pUnoI )
+{
+ static_cast< uno_Proxy * >( pUnoI )->pRoot->acquire();
+}
+//--------------------------------------------------------------------------------------------------
+static void SAL_CALL uno_proxy_release( uno_Interface * pUnoI )
+{
+ static_cast< uno_Proxy * >( pUnoI )->pRoot->release();
+}
+}
+
+//__________________________________________________________________________________________________
+inline ProxyRoot::ProxyRoot( FactoryImpl * pFactory_, const Reference< XInterface > & xTarget_ )
+ : pFactory( pFactory_ )
+ , pTarget( 0 )
+{
+ pFactory->acquire();
+ pFactory->aCpp2Uno.mapInterface( (void **)&pTarget, xTarget_.get(), ::getCppuType( &xTarget_ ) );
+ OSL_ENSHURE( pTarget, "### mapping interface failed!" );
+ aInterfaces.reserve( 8 );
+}
+//__________________________________________________________________________________________________
+ProxyRoot::~ProxyRoot()
+{
+ for ( t_InterfaceVector::const_iterator iPos( aInterfaces.begin() );
+ iPos != aInterfaces.end(); ++iPos )
+ {
+ uno_Proxy * p = *iPos;
+ (*p->pTarget->release)( p->pTarget );
+ typelib_typedescription_release( (typelib_TypeDescription *)p->pTypeDescr );
+ delete p;
+ }
+ (*pTarget->release)( pTarget );
+ pFactory->release();
+}
+
+//--------------------------------------------------------------------------------------------------
+static inline sal_Bool type_equals(
+ const Type & rType, typelib_InterfaceTypeDescription * pTypeDescr )
+{
+ typelib_TypeDescriptionReference * p1 = rType.getTypeLibType();
+ typelib_TypeDescriptionReference * p2 = (typelib_TypeDescriptionReference *)pTypeDescr;
+
+ return (p1 == p2 ||
+ (p1->pTypeName->length == p2->pTypeName->length &&
+ rtl_ustr_compare( p1->pTypeName->buffer, p2->pTypeName->buffer ) == 0));
+}
+//__________________________________________________________________________________________________
+Any ProxyRoot::queryAggregation( const Type & rType )
+ throw (RuntimeException)
+{
+ Any aRet( OWeakAggObject::queryAggregation( rType ) );
+ if (! aRet.hasValue())
+ {
+ // query existing interfaces
+ MutexGuard aGuard( aMutex );
+ for ( t_InterfaceVector::const_iterator iPos( aInterfaces.begin() );
+ iPos != aInterfaces.end(); ++iPos )
+ {
+ uno_Proxy * p = *iPos;
+ typelib_InterfaceTypeDescription * pTypeDescr = p->pTypeDescr;
+ while (pTypeDescr)
+ {
+ if (type_equals( rType, pTypeDescr ))
+ {
+ Reference< XInterface > xRet;
+ pFactory->aUno2Cpp.mapInterface( (void **)&xRet, (uno_Interface *)p, pTypeDescr );
+ aRet.setValue( &xRet, (typelib_TypeDescription *)pTypeDescr );
+ return aRet;
+ }
+ pTypeDescr = pTypeDescr->pBaseTypeDescription;
+ }
+ }
+ // else perform query
+ typelib_InterfaceTypeDescription * pTypeDescr = 0;
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pTypeDescr, rType.getTypeLibType() );
+ uno_Interface * pProxyTarget = uno_queryInterface( pTarget, pTypeDescr );
+ if (pProxyTarget)
+ {
+ uno_Proxy * p = new uno_Proxy();
+ p->acquire = uno_proxy_acquire;
+ p->release = uno_proxy_release;
+ p->pDispatcher = uno_proxy_dispatch;
+ //
+ p->pRoot = this;
+ p->pTarget = pProxyTarget;
+ typelib_typedescription_acquire( (typelib_TypeDescription *)pTypeDescr );
+ p->pTypeDescr = pTypeDescr;
+
+ Reference< XInterface > xRet;
+ pFactory->aUno2Cpp.mapInterface( (void **)&xRet, (uno_Interface *)p, pTypeDescr );
+ OSL_ENSHURE( xRet.is(), "### mapping interface failed!" );
+ aInterfaces.push_back( p );
+ aRet.setValue( &xRet, (typelib_TypeDescription *)pTypeDescr );
+ }
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pTypeDescr );
+ }
+ return aRet;
+}
+
+//##################################################################################################
+//##################################################################################################
+
+//--------------------------------------------------------------------------------------------------
+inline static Sequence< OUString > getSupportedServiceNames()
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//__________________________________________________________________________________________________
+FactoryImpl::FactoryImpl()
+ : aUno2Cpp( OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ) )
+ , aCpp2Uno( OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ) )
+{
+ OSL_ENSHURE( aUno2Cpp.is(), "### cannot get bridge uno <-> C++!" );
+ OSL_ENSHURE( aCpp2Uno.is(), "### cannot get bridge C++ <-> uno!" );
+}
+
+// XProxyFactory
+//__________________________________________________________________________________________________
+Reference< XAggregation > FactoryImpl::createProxy( const Reference< XInterface > & xTarget )
+ throw (RuntimeException)
+{
+ return new ProxyRoot( this, xTarget );
+}
+// XServiceInfo
+//__________________________________________________________________________________________________
+OUString FactoryImpl::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
+}
+//__________________________________________________________________________________________________
+sal_Bool FactoryImpl::supportsService( const OUString & rServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ {
+ if (pArray[nPos] == rServiceName)
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > FactoryImpl::getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return stoc_proxyfac::getSupportedServiceNames();
+}
+
+//==================================================================================================
+static Reference< XInterface > SAL_CALL FactoryImpl_create( const Reference< XMultiServiceFactory > & xMgr )
+ throw(::com::sun::star::uno::Exception)
+{
+ return Reference< XInterface >( *new FactoryImpl() );
+}
+
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL = stoc_proxyfac::getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
+ stoc_proxyfac::FactoryImpl_create,
+ stoc_proxyfac::getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
diff --git a/stoc/source/proxy_factory/proxyfac.xml b/stoc/source/proxy_factory/proxyfac.xml
new file mode 100644
index 000000000000..98892ec1f147
--- /dev/null
+++ b/stoc/source/proxy_factory/proxyfac.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Daniel Boelzle </Author>
+
+<Name> com.sun.star.comp.stoc.ProxyFactory </Name>
+
+<Description>
+Specifies a factory object to create proxy objects.
+These proxy object represent a given target object and can be
+be aggregated. The proxy objects act UNO conform and do NOT provide
+original target interfaces on queryInterface() calls.
+</Description>
+
+<ModuleName> proxyfac </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> C++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> com.sun.star.util.ProxyFactory </SupportedService>
+
+<ServiceDependency> </ServiceDependency>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal </RuntimeModuleDependency>
+
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.registry.XSimpleRegistry </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.util.XProxyFactory </Type>
+
+</COMPONENTDESCRIPTION>
+
diff --git a/stoc/source/registry_tdprovider/base.hxx b/stoc/source/registry_tdprovider/base.hxx
new file mode 100644
index 000000000000..a1c32dc8f1e4
--- /dev/null
+++ b/stoc/source/registry_tdprovider/base.hxx
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * $RCSfile: base.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef __REGISTRY_REFLREAD_HXX__
+#include <registry/reflread.hxx>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+
+#include <stl/vector>
+
+#include <com/sun/star/reflection/XTypeDescription.hpp>
+#include <com/sun/star/reflection/XInterfaceTypeDescription.hpp>
+#include <com/sun/star/reflection/XCompoundTypeDescription.hpp>
+#include <com/sun/star/reflection/XEnumTypeDescription.hpp>
+#include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+
+using namespace std;
+using namespace rtl;
+using namespace osl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+using namespace com::sun::star::reflection;
+
+
+namespace stoc_rdbtdp
+{
+
+//--------------------------------------------------------------------------------------------------
+inline sal_Int32 getRTValueAsInt32( const RTConstValue & rVal )
+{
+ switch (rVal.m_type)
+ {
+ case RT_TYPE_BYTE:
+ return rVal.m_value.aByte;
+ case RT_TYPE_INT16:
+ return rVal.m_value.aShort;
+ case RT_TYPE_UINT16:
+ return rVal.m_value.aUShort;
+ case RT_TYPE_INT32:
+ return rVal.m_value.aLong;
+ case RT_TYPE_UINT32:
+ return rVal.m_value.aULong;
+ }
+ OSL_ENSHURE( sal_False, "### unexpected value type!" );
+ return 0;
+}
+//--------------------------------------------------------------------------------------------------
+inline Any getRTValue( const RTConstValue & rVal )
+{
+ switch (rVal.m_type)
+ {
+ case RT_TYPE_BOOL:
+ return Any( &rVal.m_value.aBool, ::getCppuBooleanType() );
+ case RT_TYPE_BYTE:
+ return Any( &rVal.m_value.aByte, ::getCppuType( (const sal_Int8 *)0 ) );
+ case RT_TYPE_INT16:
+ return Any( &rVal.m_value.aShort, ::getCppuType( (const sal_Int16 *)0 ) );
+ case RT_TYPE_UINT16:
+ return Any( &rVal.m_value.aUShort, ::getCppuType( (const sal_uInt16 *)0 ) );
+ case RT_TYPE_INT32:
+ return Any( &rVal.m_value.aLong, ::getCppuType( (const sal_Int32 *)0 ) );
+ case RT_TYPE_UINT32:
+ return Any( &rVal.m_value.aULong, ::getCppuType( (const sal_uInt32 *)0 ) );
+ case RT_TYPE_FLOAT:
+ return Any( &rVal.m_value.aFloat, ::getCppuType( (const float *)0 ) );
+ case RT_TYPE_DOUBLE:
+ return Any( &rVal.m_value.aDouble, ::getCppuType( (const double *)0 ) );
+ case RT_TYPE_STRING:
+ {
+ OUString aStr( rVal.m_value.aString );
+ return Any( &aStr, ::getCppuType( (const OUString *)0 ) );
+ }
+ }
+ OSL_ENSHURE( sal_False, "### unexpected RTValue!" );
+ return Any();
+}
+
+//==================================================================================================
+struct MethodInit
+{
+// WeakReference< XInterfaceMemberTypeDescription > wxMember;
+ //
+ OUString aTypeName;
+ OUString aMemberName;
+ OUString aReturnTypeName;
+ sal_uInt16 nMethodIndex;
+ sal_Bool bOneWay;
+};
+//==================================================================================================
+struct AttributeInit
+{
+// WeakReference< XInterfaceMemberTypeDescription > wxMember;
+ //
+ OUString aTypeName;
+ OUString aMemberName;
+ OUString aMemberTypeName;
+ sal_Bool bReadOnly;
+};
+
+//==================================================================================================
+class TypeDescriptionImpl : public WeakImplHelper1< XTypeDescription >
+{
+ TypeClass _eTypeClass;
+ OUString _aName;
+
+public:
+ TypeDescriptionImpl( TypeClass eTypeClass, const OUString & rName )
+ : _eTypeClass( eTypeClass )
+ , _aName( rName )
+ {}
+
+ // XTypeDescription
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class InterfaceTypeDescriptionImpl : public WeakImplHelper1< XInterfaceTypeDescription >
+{
+ Reference< XHierarchicalNameAccess > _xTDMgr;
+ Sequence< sal_Int8 > _aBytes;
+
+ OUString _aName;
+ Uik _aUik;
+
+ OUString _aBaseType;
+ Mutex _aBaseTypeMutex;
+ Reference< XTypeDescription > _xBaseTD;
+
+ Mutex _aMembersMutex;
+ sal_Int32 _nBaseOffset;
+ vector< AttributeInit > * _pAttributes;
+ vector< MethodInit > * _pMethods;
+
+public:
+ InterfaceTypeDescriptionImpl( const Reference< XHierarchicalNameAccess > & xTDMgr,
+ const OUString & rName, const OUString & rBaseType,
+ const RTUik & rUik, const Sequence< sal_Int8 > & rBytes );
+ virtual ~InterfaceTypeDescriptionImpl();
+
+ // XTypeDescription
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+
+ // XInterfaceTypeDescription
+ virtual Uik SAL_CALL getUik() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XTypeDescription > SAL_CALL getBaseType() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XInterfaceMemberTypeDescription > > SAL_CALL getMembers() throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class CompoundTypeDescriptionImpl : public WeakImplHelper1< XCompoundTypeDescription >
+{
+ Reference< XHierarchicalNameAccess > _xTDMgr;
+ TypeClass _eTypeClass;
+ Sequence< sal_Int8 > _aBytes;
+ OUString _aName;
+
+ OUString _aBaseType;
+ Mutex _aBaseTypeMutex;
+ Reference< XTypeDescription > _xBaseTD;
+
+ Mutex _aMembersMutex;
+ Sequence< Reference< XTypeDescription > > * _pMembers;
+
+ Mutex _aMemberNamesMutex;
+ Sequence< OUString > * _pMemberNames;
+
+public:
+ CompoundTypeDescriptionImpl( const Reference< XHierarchicalNameAccess > & xTDMgr,
+ TypeClass eTypeClass,
+ const OUString & rName, const OUString & rBaseName,
+ const Sequence< sal_Int8 > & rBytes )
+ : _xTDMgr( xTDMgr )
+ , _eTypeClass( eTypeClass )
+ , _aBytes( rBytes )
+ , _aName( rName )
+ , _aBaseType( rBaseName )
+ , _pMembers( 0 )
+ , _pMemberNames( 0 )
+ {}
+ virtual ~CompoundTypeDescriptionImpl();
+
+ // XTypeDescription
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+
+ // XCompoundTypeDescription
+ virtual Reference< XTypeDescription > SAL_CALL getBaseType() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XTypeDescription > > SAL_CALL getMemberTypes() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getMemberNames() throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class EnumTypeDescriptionImpl : public WeakImplHelper1< XEnumTypeDescription >
+{
+ Reference< XHierarchicalNameAccess > _xTDMgr;
+ Sequence< sal_Int8 > _aBytes;
+
+ OUString _aName;
+ sal_Int32 _nDefaultValue;
+
+ Mutex _aEnumNamesMutex;
+ Sequence< OUString > * _pEnumNames;
+ Mutex _aEnumValuesMutex;
+ Sequence< sal_Int32 > * _pEnumValues;
+
+public:
+ EnumTypeDescriptionImpl( const Reference< XHierarchicalNameAccess > & xTDMgr,
+ const OUString & rName, sal_Int32 nDefaultValue,
+ const Sequence< sal_Int8 > & rBytes )
+ : _xTDMgr( xTDMgr )
+ , _aName( rName )
+ , _nDefaultValue( nDefaultValue )
+ , _aBytes( rBytes )
+ , _pEnumNames( 0 )
+ , _pEnumValues( 0 )
+ {}
+ virtual ~EnumTypeDescriptionImpl();
+
+ // XTypeDescription
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+
+ // XEnumTypeDescription
+ virtual sal_Int32 SAL_CALL getDefaultEnumValue() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getEnumNames() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int32 > SAL_CALL getEnumValues() throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class TypedefTypeDescriptionImpl : public WeakImplHelper1< XIndirectTypeDescription >
+{
+ Reference< XHierarchicalNameAccess > _xTDMgr;
+ OUString _aName;
+
+ Mutex _aRefTDMutex;
+ OUString _aRefName;
+ Reference< XTypeDescription > _xRefTD;
+
+public:
+ TypedefTypeDescriptionImpl( const Reference< XHierarchicalNameAccess > & xTDMgr,
+ const OUString & rName, const OUString & rRefName )
+ : _xTDMgr( xTDMgr )
+ , _aName( rName )
+ , _aRefName( rRefName )
+ {}
+
+ // XTypeDescription
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+
+ // XIndirectTypeDescription
+ virtual Reference< XTypeDescription > SAL_CALL getReferencedType() throw(::com::sun::star::uno::RuntimeException);
+};
+
+}
+
+
diff --git a/stoc/source/registry_tdprovider/makefile.mk b/stoc/source/registry_tdprovider/makefile.mk
new file mode 100644
index 000000000000..db99fa4f856a
--- /dev/null
+++ b/stoc/source/registry_tdprovider/makefile.mk
@@ -0,0 +1,112 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= rdbtdp
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+BOOTSTRAP_SERVICE=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/tdprovider.obj \
+ $(SLO)$/tdef.obj \
+ $(SLO)$/tdenum.obj \
+ $(SLO)$/tdcomp.obj \
+ $(SLO)$/tdiface.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/source/registry_tdprovider/tdcomp.cxx b/stoc/source/registry_tdprovider/tdcomp.cxx
new file mode 100644
index 000000000000..86c0693f92b1
--- /dev/null
+++ b/stoc/source/registry_tdprovider/tdcomp.cxx
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * $RCSfile: tdcomp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "base.hxx"
+
+namespace stoc_rdbtdp
+{
+
+//__________________________________________________________________________________________________
+CompoundTypeDescriptionImpl::~CompoundTypeDescriptionImpl()
+{
+ delete _pMembers;
+ delete _pMemberNames;
+}
+
+// XTypeDescription
+//__________________________________________________________________________________________________
+TypeClass CompoundTypeDescriptionImpl::getTypeClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _eTypeClass;
+}
+//__________________________________________________________________________________________________
+OUString CompoundTypeDescriptionImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aName;
+}
+
+// XCompoundTypeDescription
+//__________________________________________________________________________________________________
+Reference< XTypeDescription > CompoundTypeDescriptionImpl::getBaseType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (!_xBaseTD.is() && _aBaseType.getLength())
+ {
+ MutexGuard aGuard( _aBaseTypeMutex );
+ if (!_xBaseTD.is() && _aBaseType.getLength())
+ {
+ try
+ {
+ if (extractInterface( _xBaseTD, _xTDMgr->getByHierarchicalName( _aBaseType ) ))
+ return _xBaseTD;
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ // never try again, if no base td was found
+ _aBaseType = OUString();
+ }
+ }
+ return _xBaseTD;
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XTypeDescription > > CompoundTypeDescriptionImpl::getMemberTypes()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pMembers)
+ {
+ MutexGuard aGuard( _aMembersMutex );
+ if (! _pMembers)
+ {
+ RegistryTypeReaderLoader aLoader;
+ RegistryTypeReader aReader( aLoader, (const sal_uInt8 *)_aBytes.getConstArray(),
+ _aBytes.getLength(), sal_False );
+
+ sal_uInt16 nFields = (sal_uInt16)aReader.getFieldCount();
+ Sequence< Reference< XTypeDescription > > * pTempMembers =
+ new Sequence< Reference< XTypeDescription > >( nFields );
+ Reference< XTypeDescription > * pMembers = pTempMembers->getArray();
+
+ while (nFields--)
+ {
+ try
+ {
+ extractInterface(
+ pMembers[nFields],
+ _xTDMgr->getByHierarchicalName(
+ aReader.getFieldType( nFields ).replace( '/', '.' ) ) );
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ OSL_ENSHURE( pMembers[nFields].is(), "### compound member unknown!" );
+ }
+
+ _pMembers = pTempMembers;
+ }
+ }
+ return *_pMembers;
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > CompoundTypeDescriptionImpl::getMemberNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pMemberNames)
+ {
+ MutexGuard aGuard( _aMemberNamesMutex );
+ if (! _pMemberNames)
+ {
+ RegistryTypeReaderLoader aLoader;
+ RegistryTypeReader aReader( aLoader, (const sal_uInt8 *)_aBytes.getConstArray(),
+ _aBytes.getLength(), sal_False );
+
+ sal_uInt16 nFields = (sal_uInt16)aReader.getFieldCount();
+ Sequence< OUString > * pTempMemberNames = new Sequence< OUString >( nFields );
+ OUString * pMemberNames = pTempMemberNames->getArray();
+
+ while (nFields--)
+ {
+ pMemberNames[nFields] = aReader.getFieldName( nFields );
+ }
+
+ _pMemberNames = pTempMemberNames;
+ }
+ }
+ return *_pMemberNames;
+}
+
+}
+
+
diff --git a/stoc/source/registry_tdprovider/tdef.cxx b/stoc/source/registry_tdprovider/tdef.cxx
new file mode 100644
index 000000000000..412338c5ad45
--- /dev/null
+++ b/stoc/source/registry_tdprovider/tdef.cxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * $RCSfile: tdef.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "base.hxx"
+
+namespace stoc_rdbtdp
+{
+
+// XTypeDescription
+//__________________________________________________________________________________________________
+TypeClass TypedefTypeDescriptionImpl::getTypeClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return TypeClass_TYPEDEF;
+}
+//__________________________________________________________________________________________________
+OUString TypedefTypeDescriptionImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aName;
+}
+
+// XIndirectTypeDescription
+//__________________________________________________________________________________________________
+Reference< XTypeDescription > TypedefTypeDescriptionImpl::getReferencedType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (!_xRefTD.is() && _aRefName.getLength())
+ {
+ MutexGuard aGuard( _aRefTDMutex );
+ if (!_xRefTD.is() && _aRefName.getLength())
+ {
+ try
+ {
+ if (extractInterface( _xRefTD, _xTDMgr->getByHierarchicalName( _aRefName ) ))
+ return _xRefTD;
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ // never try again, if no base td was found
+ _aRefName = OUString();
+ }
+ }
+ return _xRefTD;
+}
+
+}
+
+
diff --git a/stoc/source/registry_tdprovider/tdenum.cxx b/stoc/source/registry_tdprovider/tdenum.cxx
new file mode 100644
index 000000000000..5d07495a1a72
--- /dev/null
+++ b/stoc/source/registry_tdprovider/tdenum.cxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * $RCSfile: tdenum.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "base.hxx"
+
+namespace stoc_rdbtdp
+{
+
+//__________________________________________________________________________________________________
+EnumTypeDescriptionImpl::~EnumTypeDescriptionImpl()
+{
+ delete _pEnumNames;
+ delete _pEnumValues;
+}
+
+// XTypeDescription
+//__________________________________________________________________________________________________
+TypeClass EnumTypeDescriptionImpl::getTypeClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return TypeClass_ENUM;
+}
+//__________________________________________________________________________________________________
+OUString EnumTypeDescriptionImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aName;
+}
+
+// XEnumTypeDescription
+//__________________________________________________________________________________________________
+sal_Int32 EnumTypeDescriptionImpl::getDefaultEnumValue()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _nDefaultValue;
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > EnumTypeDescriptionImpl::getEnumNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pEnumNames)
+ {
+ MutexGuard aGuard( _aEnumNamesMutex );
+ if (! _pEnumNames)
+ {
+ RegistryTypeReaderLoader aLoader;
+ RegistryTypeReader aReader( aLoader, (const sal_uInt8 *)_aBytes.getConstArray(),
+ _aBytes.getLength(), sal_False );
+
+ sal_uInt16 nFields = (sal_uInt16)aReader.getFieldCount();
+ Sequence< OUString > * pTempEnumNames = new Sequence< OUString >( nFields );
+ OUString * pEnumNames = pTempEnumNames->getArray();
+
+ while (nFields--)
+ {
+ pEnumNames[nFields] = aReader.getFieldName( nFields );
+ }
+
+ _pEnumNames = pTempEnumNames;
+ }
+ }
+ return *_pEnumNames;
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int32 > EnumTypeDescriptionImpl::getEnumValues()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pEnumValues)
+ {
+ MutexGuard aGuard( _aEnumValuesMutex );
+ if (! _pEnumValues)
+ {
+ RegistryTypeReaderLoader aLoader;
+ RegistryTypeReader aReader( aLoader, (const sal_uInt8 *)_aBytes.getConstArray(),
+ _aBytes.getLength(), sal_False );
+
+ sal_uInt16 nFields = (sal_uInt16)aReader.getFieldCount();
+ Sequence< sal_Int32 > * pTempEnumValues = new Sequence< sal_Int32 >( nFields );
+ sal_Int32 * pEnumValues = pTempEnumValues->getArray();
+
+ while (nFields--)
+ {
+ pEnumValues[nFields] = getRTValueAsInt32( aReader.getFieldConstValue( nFields ) );
+ }
+
+ _pEnumValues = pTempEnumValues;
+ }
+ }
+ return *_pEnumValues;
+}
+
+}
+
+
diff --git a/stoc/source/registry_tdprovider/tdiface.cxx b/stoc/source/registry_tdprovider/tdiface.cxx
new file mode 100644
index 000000000000..ea97705607c3
--- /dev/null
+++ b/stoc/source/registry_tdprovider/tdiface.cxx
@@ -0,0 +1,662 @@
+/*************************************************************************
+ *
+ * $RCSfile: tdiface.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#include <com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp>
+#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription.hpp>
+#include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
+#include <com/sun/star/reflection/XMethodParameter.hpp>
+
+#include "base.hxx"
+
+
+namespace stoc_rdbtdp
+{
+
+//==================================================================================================
+class MethodParameterImpl : public WeakImplHelper1< XMethodParameter >
+{
+ Reference< XHierarchicalNameAccess > _xTDMgr;
+
+ OUString _aName;
+ OUString _aTypeName;
+ Mutex _aTypeMutex;
+ Reference< XTypeDescription > _xType;
+
+ sal_Bool _bIn;
+ sal_Bool _bOut;
+ sal_Int32 _nPosition;
+
+public:
+ MethodParameterImpl( const Reference< XHierarchicalNameAccess > & xTDMgr,
+ const OUString & rParamName, const OUString & rParamType,
+ sal_Bool bIn, sal_Bool bOut, sal_Int32 nPosition )
+ : _xTDMgr( xTDMgr )
+ , _aName( rParamName )
+ , _aTypeName( rParamType )
+ , _bIn( bIn )
+ , _bOut( bOut )
+ , _nPosition( nPosition )
+ {}
+
+ // XMethodParameter
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XTypeDescription > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isIn() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isOut() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPosition() throw(::com::sun::star::uno::RuntimeException);
+};
+
+// XMethodParameter
+//__________________________________________________________________________________________________
+OUString MethodParameterImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aName;
+}
+//__________________________________________________________________________________________________
+Reference<XTypeDescription > MethodParameterImpl::getType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (!_xType.is() && _aTypeName.getLength())
+ {
+ MutexGuard aGuard( _aTypeMutex );
+ if (!_xType.is() && _aTypeName.getLength())
+ {
+ try
+ {
+ if (extractInterface( _xType, _xTDMgr->getByHierarchicalName( _aTypeName ) ))
+ return _xType;
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ // never try again, if no td was found
+ _aTypeName = OUString();
+ }
+ }
+ return _xType;
+}
+//__________________________________________________________________________________________________
+sal_Bool MethodParameterImpl::isIn()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _bIn;
+}
+//__________________________________________________________________________________________________
+sal_Bool MethodParameterImpl::isOut()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _bOut;
+}
+//__________________________________________________________________________________________________
+sal_Int32 MethodParameterImpl::getPosition()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _nPosition;
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//==================================================================================================
+class InterfaceMethodImpl : public WeakImplHelper1< XInterfaceMethodTypeDescription >
+{
+ Reference< XHierarchicalNameAccess > _xTDMgr;
+
+ OUString _aTypeName;
+ OUString _aMemberName;
+
+ OUString _aReturnType;
+ Mutex _aReturnTypeMutex;
+ Reference< XTypeDescription > _xReturnTD;
+
+ Sequence< sal_Int8 > _aBytes;
+ sal_uInt16 _nMethodIndex;
+ Mutex _aParamsMutex;
+ Sequence< Reference< XMethodParameter > > * _pParams;
+ Mutex _aExcMutex;
+ Sequence< Reference< XTypeDescription > > * _pExceptions;
+
+ sal_Bool _bIsOneWay;
+ sal_Int32 _nPosition;
+
+public:
+ InterfaceMethodImpl( const Reference< XHierarchicalNameAccess > & xTDMgr,
+ const OUString & rTypeName,
+ const OUString & rMemberName,
+ const OUString & rReturnType,
+ const Sequence< sal_Int8 > & rBytes,
+ sal_uInt16 nMethodIndex,
+ sal_Bool bIsOneWay,
+ sal_Int32 nPosition )
+ : _xTDMgr( xTDMgr )
+ , _aTypeName( rTypeName )
+ , _aMemberName( rMemberName )
+ , _aReturnType( rReturnType )
+ , _aBytes( rBytes )
+ , _nMethodIndex( nMethodIndex )
+ , _pParams( 0 )
+ , _pExceptions( 0 )
+ , _bIsOneWay( bIsOneWay )
+ , _nPosition( nPosition )
+ {}
+ virtual ~InterfaceMethodImpl();
+
+ // XTypeDescription
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+
+ // XInterfaceMemberTypeDescription
+ virtual OUString SAL_CALL getMemberName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPosition() throw(::com::sun::star::uno::RuntimeException);
+
+ // XInterfaceMethodTypeDescription
+ virtual Reference< XTypeDescription > SAL_CALL getReturnType() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isOneway() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XMethodParameter > > SAL_CALL getParameters() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< Reference< XTypeDescription > > SAL_CALL getExceptions() throw(::com::sun::star::uno::RuntimeException);
+};
+//__________________________________________________________________________________________________
+InterfaceMethodImpl::~InterfaceMethodImpl()
+{
+ delete _pParams;
+ delete _pExceptions;
+}
+
+// XTypeDescription
+//__________________________________________________________________________________________________
+TypeClass InterfaceMethodImpl::getTypeClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return TypeClass_INTERFACE_METHOD;
+}
+//__________________________________________________________________________________________________
+OUString InterfaceMethodImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aTypeName;
+}
+
+// XInterfaceMemberTypeDescription
+//__________________________________________________________________________________________________
+OUString InterfaceMethodImpl::getMemberName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aMemberName;
+}
+//__________________________________________________________________________________________________
+sal_Int32 InterfaceMethodImpl::getPosition()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _nPosition;
+}
+
+// XInterfaceMethodTypeDescription
+//__________________________________________________________________________________________________
+Reference<XTypeDescription > InterfaceMethodImpl::getReturnType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (!_xReturnTD.is() && _aReturnType.getLength())
+ {
+ MutexGuard aGuard( _aReturnTypeMutex );
+ if (!_xReturnTD.is() && _aReturnType.getLength())
+ {
+ try
+ {
+ if (extractInterface( _xReturnTD, _xTDMgr->getByHierarchicalName( _aReturnType ) ))
+ return _xReturnTD;
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ // never try again, if no td was found
+ _aReturnType = OUString();
+ }
+ }
+ return _xReturnTD;
+}
+//__________________________________________________________________________________________________
+sal_Bool InterfaceMethodImpl::isOneway()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _bIsOneWay;
+}
+//__________________________________________________________________________________________________
+Sequence<Reference<XMethodParameter > > InterfaceMethodImpl::getParameters()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pParams)
+ {
+ MutexGuard aGuard( _aParamsMutex );
+ if (! _pParams)
+ {
+ RegistryTypeReaderLoader aLoader;
+ RegistryTypeReader aReader( aLoader, (const sal_uInt8 *)_aBytes.getConstArray(),
+ _aBytes.getLength(), sal_False );
+
+ sal_uInt16 nParams = (sal_uInt16)aReader.getMethodParamCount( _nMethodIndex );
+ Sequence< Reference< XMethodParameter > > * pTempParams =
+ new Sequence< Reference< XMethodParameter > >( nParams );
+ Reference< XMethodParameter > * pParams = pTempParams->getArray();
+
+ while (nParams--)
+ {
+ RTParamMode eMode = aReader.getMethodParamMode( _nMethodIndex, nParams );
+
+ pParams[nParams] = new MethodParameterImpl(
+ _xTDMgr,
+ aReader.getMethodParamName( _nMethodIndex, nParams ),
+ aReader.getMethodParamType( _nMethodIndex, nParams ).replace( '/', '.' ),
+ (eMode == RT_PARAM_IN || eMode == RT_PARAM_INOUT),
+ (eMode == RT_PARAM_OUT || eMode == RT_PARAM_INOUT),
+ nParams );
+ }
+
+ _pParams = pTempParams;
+ }
+ }
+ return *_pParams;
+}
+//__________________________________________________________________________________________________
+Sequence<Reference<XTypeDescription > > InterfaceMethodImpl::getExceptions()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pExceptions)
+ {
+ MutexGuard aGuard( _aExcMutex );
+ if (! _pExceptions)
+ {
+ RegistryTypeReaderLoader aLoader;
+ RegistryTypeReader aReader( aLoader, (const sal_uInt8 *)_aBytes.getConstArray(),
+ _aBytes.getLength(), sal_False );
+
+ sal_uInt16 nExc = (sal_uInt16)aReader.getMethodExcCount( _nMethodIndex );
+ Sequence< Reference< XTypeDescription > > * pExceptions =
+ new Sequence< Reference< XTypeDescription > >( nExc );
+ Reference< XTypeDescription > * pExc = pExceptions->getArray();
+
+ while (nExc--)
+ {
+ try
+ {
+ OUString aMethodExcName( aReader.getMethodExcType( _nMethodIndex, nExc ) );
+
+ extractInterface(
+ pExc[nExc], _xTDMgr->getByHierarchicalName( aMethodExcName.replace( '/', '.' ) ) );
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ OSL_ENSHURE( pExc[nExc].is(), "### exception type unknown!" );
+ }
+
+ _pExceptions = pExceptions;
+ }
+ }
+ return *_pExceptions;
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//==================================================================================================
+class InterfaceAttributeImpl : public WeakImplHelper1< XInterfaceAttributeTypeDescription >
+{
+ Reference< XHierarchicalNameAccess > _xTDMgr;
+
+ OUString _aTypeName;
+ OUString _aMemberName;
+
+ OUString _aMemberTypeName;
+ Mutex _aMemberTypeMutex;
+ Reference< XTypeDescription > _xMemberTD;
+
+ sal_Bool _bReadOnly;
+ sal_Int32 _nPosition;
+
+public:
+ InterfaceAttributeImpl( const Reference< XHierarchicalNameAccess > & xTDMgr,
+ const OUString & rTypeName,
+ const OUString & rMemberName,
+ const OUString & rMemberTypeName,
+ sal_Bool bReadOnly,
+ sal_Int32 nPosition )
+ : _xTDMgr( xTDMgr )
+ , _aTypeName( rTypeName )
+ , _aMemberName( rMemberName )
+ , _aMemberTypeName( rMemberTypeName )
+ , _bReadOnly( bReadOnly )
+ , _nPosition( nPosition )
+ {}
+
+ // XTypeDescription
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+
+ // XInterfaceMemberTypeDescription
+ virtual OUString SAL_CALL getMemberName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPosition() throw(::com::sun::star::uno::RuntimeException);
+
+ // XInterfaceAttributeTypeDescription
+ virtual sal_Bool SAL_CALL isReadOnly() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference< XTypeDescription > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
+};
+
+// XTypeDescription
+//__________________________________________________________________________________________________
+TypeClass InterfaceAttributeImpl::getTypeClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return TypeClass_INTERFACE_ATTRIBUTE;
+}
+//__________________________________________________________________________________________________
+OUString InterfaceAttributeImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aTypeName;
+}
+
+// XInterfaceMemberTypeDescription
+//__________________________________________________________________________________________________
+OUString InterfaceAttributeImpl::getMemberName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aMemberName;
+}
+//__________________________________________________________________________________________________
+sal_Int32 InterfaceAttributeImpl::getPosition()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _nPosition;
+}
+
+// XInterfaceAttributeTypeDescription
+//__________________________________________________________________________________________________
+sal_Bool InterfaceAttributeImpl::isReadOnly()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _bReadOnly;
+}
+//__________________________________________________________________________________________________
+Reference<XTypeDescription > InterfaceAttributeImpl::getType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (!_xMemberTD.is() && _aMemberTypeName.getLength())
+ {
+ MutexGuard aGuard( _aMemberTypeMutex );
+ if (!_xMemberTD.is() && _aMemberTypeName.getLength())
+ {
+ try
+ {
+ if (extractInterface( _xMemberTD, _xTDMgr->getByHierarchicalName( _aMemberTypeName ) ))
+ return _xMemberTD;
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ // never try again, if no td was found
+ _aMemberTypeName = OUString();
+ }
+ }
+ return _xMemberTD;
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//__________________________________________________________________________________________________
+InterfaceTypeDescriptionImpl::InterfaceTypeDescriptionImpl(
+ const Reference< XHierarchicalNameAccess > & xTDMgr,
+ const OUString & rName, const OUString & rBaseType,
+ const RTUik & rUik, const Sequence< sal_Int8 > & rBytes )
+ : _xTDMgr( xTDMgr )
+ , _aName( rName )
+ , _aBaseType( rBaseType )
+ , _aBytes( rBytes )
+ , _pAttributes( 0 )
+ , _pMethods( 0 )
+{
+ // uik
+ _aUik.m_Data1 = rUik.m_Data1;
+ _aUik.m_Data2 = rUik.m_Data2;
+ _aUik.m_Data3 = rUik.m_Data3;
+ _aUik.m_Data4 = rUik.m_Data4;
+ _aUik.m_Data5 = rUik.m_Data5;
+}
+//__________________________________________________________________________________________________
+InterfaceTypeDescriptionImpl::~InterfaceTypeDescriptionImpl()
+{
+ delete _pAttributes;
+ delete _pMethods;
+}
+
+// XTypeDescription
+//__________________________________________________________________________________________________
+TypeClass InterfaceTypeDescriptionImpl::getTypeClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return TypeClass_INTERFACE;
+}
+//__________________________________________________________________________________________________
+OUString InterfaceTypeDescriptionImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aName;
+}
+
+// XInterfaceTypeDescription
+//__________________________________________________________________________________________________
+Reference< XTypeDescription > InterfaceTypeDescriptionImpl::getBaseType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (!_xBaseTD.is() && _aBaseType.getLength())
+ {
+ MutexGuard aGuard( _aBaseTypeMutex );
+ if (!_xBaseTD.is() && _aBaseType.getLength())
+ {
+ try
+ {
+ if (extractInterface( _xBaseTD, _xTDMgr->getByHierarchicalName( _aBaseType ) ))
+ return _xBaseTD;
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ // never try again, if no base td was found
+ _aBaseType = OUString();
+ }
+ }
+ return _xBaseTD;
+}
+//__________________________________________________________________________________________________
+Uik SAL_CALL InterfaceTypeDescriptionImpl::getUik()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aUik;
+}
+//__________________________________________________________________________________________________
+Sequence< Reference< XInterfaceMemberTypeDescription > > InterfaceTypeDescriptionImpl::getMembers()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (! _pMethods)
+ {
+ MutexGuard aGuard( _aMembersMutex );
+ if (! _pMethods)
+ {
+ RegistryTypeReaderLoader aLoader;
+ RegistryTypeReader aReader( aLoader, (const sal_uInt8 *)_aBytes.getConstArray(),
+ _aBytes.getLength(), sal_False );
+ sal_uInt16 nMethods = (sal_uInt16)aReader.getMethodCount();
+ sal_uInt16 nFields = (sal_uInt16)aReader.getFieldCount();
+
+ vector< AttributeInit > * pAttributes = new vector< AttributeInit >( nFields );
+ vector< MethodInit > * pMethods = new vector< MethodInit >( nMethods );
+
+ OUString aInterfaceName( getName() );
+
+ // base offsets
+ _nBaseOffset = 0;
+
+ Reference< XTypeDescription > xBase( getBaseType(), UNO_QUERY );
+ while (xBase.is())
+ {
+ Reference< XInterfaceTypeDescription > xBaseInterface( xBase, UNO_QUERY );
+ Sequence< Reference< XInterfaceMemberTypeDescription > > aBaseMembers( xBaseInterface->getMembers() );
+ if (aBaseMembers.getLength())
+ {
+ _nBaseOffset = aBaseMembers[aBaseMembers.getLength()-1]->getPosition() +1;
+ break;
+ }
+ xBase = xBaseInterface->getBaseType();
+ }
+
+ // all methods
+ while (nMethods--)
+ {
+ OUString aMemberName( aReader.getMethodName( nMethods ) );
+ OUStringBuffer aTypeName( aInterfaceName );
+ aTypeName.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") );
+ aTypeName.append( aMemberName );
+
+ RTMethodMode eMode = aReader.getMethodMode( nMethods );
+
+ MethodInit & rInit = pMethods->operator[]( nMethods );
+
+ rInit.aTypeName = aTypeName.makeStringAndClear();
+ rInit.aMemberName = aMemberName;
+ rInit.aReturnTypeName = aReader.getMethodReturnType( nMethods ).replace( '/', '.' );
+ rInit.nMethodIndex = nMethods;
+ rInit.bOneWay = (eMode == RT_MODE_ONEWAY || eMode == RT_MODE_ONEWAY_CONST);
+ }
+
+ // all fields
+ while (nFields--)
+ {
+ OUString aMemberName( aReader.getFieldName( nFields ) );
+ OUString aMemberType( aReader.getFieldType( nFields ).replace( '/', '.' ) );
+ OUStringBuffer aTypeName( aInterfaceName );
+ aTypeName.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") );
+ aTypeName.append( aMemberName );
+
+ AttributeInit & rInit = pAttributes->operator[]( nFields );
+
+ rInit.aTypeName = aTypeName.makeStringAndClear();
+ rInit.aMemberName = aMemberName;
+ rInit.aMemberTypeName = aMemberType;
+ rInit.bReadOnly = (aReader.getFieldAccess( nFields ) == RT_ACCESS_READONLY);
+ }
+
+ _pAttributes = pAttributes;
+ _pMethods = pMethods;
+ }
+ }
+
+ // collect members
+ sal_Int32 nAttributes = _pAttributes->size();
+ sal_Int32 nMethods = _pMethods->size();
+
+ Sequence< Reference< XInterfaceMemberTypeDescription > > aMembers( nAttributes + nMethods );
+ Reference< XInterfaceMemberTypeDescription > * pMembers = aMembers.getArray();
+
+ while (nMethods--)
+ {
+ MethodInit & rInit = _pMethods->operator[]( nMethods );
+/* if (! (pMembers[nAttributes+nMethods] = rInit.wxMember).is())
+ {
+ rInit.wxMember = */pMembers[nAttributes+nMethods] = new InterfaceMethodImpl(
+ _xTDMgr, rInit.aTypeName, rInit.aMemberName,
+ rInit.aReturnTypeName, _aBytes, rInit.nMethodIndex,
+ rInit.bOneWay, _nBaseOffset+nAttributes+nMethods );
+// }
+ }
+ while (nAttributes--)
+ {
+ AttributeInit & rInit = _pAttributes->operator[]( nAttributes );
+/* if (! (pMembers[nAttributes] = rInit.wxMember).is())
+ {
+ rInit.wxMember = */pMembers[nAttributes] = new InterfaceAttributeImpl(
+ _xTDMgr, rInit.aTypeName, rInit.aMemberName, rInit.aMemberTypeName,
+ rInit.bReadOnly, _nBaseOffset+nAttributes );
+// }
+ }
+
+ return aMembers;
+}
+
+}
+
+
diff --git a/stoc/source/registry_tdprovider/tdprovider.cxx b/stoc/source/registry_tdprovider/tdprovider.cxx
new file mode 100644
index 000000000000..81021fb338a6
--- /dev/null
+++ b/stoc/source/registry_tdprovider/tdprovider.cxx
@@ -0,0 +1,528 @@
+/*************************************************************************
+ *
+ * $RCSfile: tdprovider.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <stl/list>
+
+#include "base.hxx"
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::registry;
+
+
+namespace stoc_rdbtdp
+{
+
+#define SERVICENAME "com.sun.star.reflection.TypeDescriptionProvider"
+#define IMPLNAME "com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"
+
+// typedef list< Reference< XSimpleRegistry > > RegistryList;
+typedef list< Reference< XRegistryKey > > RegistryKeyList;
+
+//--------------------------------------------------------------------------------------------------
+inline static Sequence< OUString > getSupportedServiceNames()
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//==================================================================================================
+class ProviderImpl
+ : public OComponentHelper
+ , public XServiceInfo
+ , public XHierarchicalNameAccess
+{
+ Mutex _aComponentMutex;
+ Reference< XMultiServiceFactory > _xSMgr;
+ Reference< XHierarchicalNameAccess > _xTDMgr;
+
+ Mutex _aListsMutex;
+// RegistryList _aOpenRegistries;
+ RegistryKeyList _aBaseKeys;
+ RegistryTypeReaderLoader _aLoader;
+
+public:
+ ProviderImpl( const Reference< XMultiServiceFactory > & xMgr );
+ virtual ~ProviderImpl();
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // some XComponent part from OComponentHelper
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // XHierarchicalNameAccess
+ virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+};
+//__________________________________________________________________________________________________
+ProviderImpl::ProviderImpl( const Reference< XMultiServiceFactory > & xSMgr )
+ : OComponentHelper( _aComponentMutex )
+ , _xSMgr( xSMgr )
+ , _xTDMgr( _xSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.TypeDescriptionManager") ) ), UNO_QUERY )
+{
+ OSL_ENSHURE( _xTDMgr.is(), "### cannot get service instance \"com.sun.star.reflection.TypeDescriptionManager\"!" );
+}
+//__________________________________________________________________________________________________
+ProviderImpl::~ProviderImpl()
+{
+}
+
+// XInterface
+//__________________________________________________________________________________________________
+Any ProviderImpl::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( cppu::queryInterface(
+ rType,
+ static_cast< XHierarchicalNameAccess * >( this ),
+ static_cast< XServiceInfo * >( this ) ) );
+
+ return (aRet.hasValue() ? aRet : OComponentHelper::queryInterface( rType ));
+}
+//__________________________________________________________________________________________________
+void ProviderImpl::acquire() throw()
+{
+ OComponentHelper::acquire();
+}
+//__________________________________________________________________________________________________
+void ProviderImpl::release() throw()
+{
+ OComponentHelper::release();
+}
+
+// XTypeProvider
+//__________________________________________________________________________________________________
+Sequence< Type > ProviderImpl::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< XServiceInfo > *)0 ),
+ ::getCppuType( (const Reference< XHierarchicalNameAccess > *)0 ),
+ OComponentHelper::getTypes() );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int8 > ProviderImpl::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * s_pId = 0;
+ if (! s_pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pId)
+ {
+ static OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+}
+
+// XComponent
+//__________________________________________________________________________________________________
+void ProviderImpl::dispose()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ OComponentHelper::dispose();
+
+ MutexGuard aGuard( _aListsMutex );
+ for ( RegistryKeyList::const_iterator iPos( _aBaseKeys.begin() );
+ iPos != _aBaseKeys.end(); ++iPos )
+ {
+ (*iPos)->closeKey();
+ }
+ _aBaseKeys.clear();
+// for ( RegistryList::const_iterator iRPos( _aOpenRegistries.begin() );
+// iRPos != _aOpenRegistries.end(); ++iRPos )
+// {
+// (*iRPos)->close();
+// }
+// _aOpenRegistries.clear();
+
+ MutexGuard aGuard2( _aComponentMutex );
+ _xTDMgr.clear();
+ _xSMgr.clear();
+}
+
+// XServiceInfo
+//__________________________________________________________________________________________________
+OUString ProviderImpl::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
+}
+//__________________________________________________________________________________________________
+sal_Bool ProviderImpl::supportsService( const OUString & rServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ {
+ if (pArray[nPos] == rServiceName)
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > ProviderImpl::getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return stoc_rdbtdp::getSupportedServiceNames();
+}
+
+// XHierarchicalNameAccess
+//__________________________________________________________________________________________________
+Any SAL_CALL ProviderImpl::getByHierarchicalName( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException, com::sun::star::container::NoSuchElementException)
+{
+ Any aRet;
+
+ if (_aLoader.isLoaded()) // dll is loaded?
+ {
+ MutexGuard aGuard( _aListsMutex );
+ if (! _aBaseKeys.size())
+ {
+ // DBO TODO:
+ // listen for registry changes
+
+ // reading from service manager registry for all typelib data
+ Reference< XPropertySet > xProps( _xSMgr, UNO_QUERY );
+ if (xProps.is())
+ {
+ Any aReg( xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Registry") ) ) );
+ if (aReg.hasValue() && aReg.getValueTypeClass() == TypeClass_INTERFACE)
+ {
+ Reference< XSimpleRegistry > xSource(
+ *(const Reference< XInterface > *)aReg.getValue(), UNO_QUERY );
+ if (xSource->isValid())
+ {
+ Reference< XRegistryKey > xKey( xSource->getRootKey()->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/UCR") ) ) );
+ if (xKey.is())
+ _aBaseKeys.push_back( xKey );
+ }
+ }
+ }
+ }
+
+ // read from registry
+ OUString aKey( rName.replace( '.', '/' ) );
+ for ( RegistryKeyList::const_iterator iPos( _aBaseKeys.begin() );
+ !aRet.hasValue() && iPos != _aBaseKeys.end(); ++iPos )
+ {
+ Reference< XRegistryKey > xBaseKey( *iPos );
+ Reference< XRegistryKey > xKey( xBaseKey->openKey( aKey ) );
+ if (xKey.is())
+ {
+ if (xKey->getValueType() == RegistryValueType_BINARY)
+ {
+ Sequence< sal_Int8 > aBytes( xKey->getBinaryValue() );
+ RegistryTypeReader aReader( _aLoader,
+ (const sal_uInt8 *)aBytes.getConstArray(),
+ aBytes.getLength(),
+ sal_False );
+
+ OUString aName( aReader.getTypeName().replace( '/', '.' ) );
+
+ switch (aReader.getTypeClass())
+ {
+ case RT_TYPE_INTERFACE:
+ {
+ RTUik aUik;
+ aReader.getUik( aUik );
+ aRet <<= Reference< XTypeDescription >( new InterfaceTypeDescriptionImpl(
+ _xTDMgr, aName,
+ aReader.getSuperTypeName().replace( '/', '.' ),
+ aUik, aBytes ) );
+ break;
+ }
+ case RT_TYPE_EXCEPTION:
+ aRet <<= Reference< XTypeDescription >( new CompoundTypeDescriptionImpl(
+ _xTDMgr, TypeClass_EXCEPTION, aName,
+ aReader.getSuperTypeName().replace( '/', '.' ),
+ aBytes ) );
+ break;
+ case RT_TYPE_STRUCT:
+ aRet <<= Reference< XTypeDescription >( new CompoundTypeDescriptionImpl(
+ _xTDMgr, TypeClass_STRUCT, aName,
+ aReader.getSuperTypeName().replace( '/', '.' ),
+ aBytes ) );
+ break;
+ case RT_TYPE_ENUM:
+ aRet <<= Reference< XTypeDescription >( new EnumTypeDescriptionImpl(
+ _xTDMgr, aName,
+ getRTValueAsInt32( aReader.getFieldConstValue( 0 ) ),
+ aBytes ) );
+ break;
+ case RT_TYPE_TYPEDEF:
+ aRet <<= Reference< XTypeDescription >( new TypedefTypeDescriptionImpl(
+ _xTDMgr, aName,
+ aReader.getSuperTypeName().replace( '/', '.' ) ) );
+ break;
+
+/* // these following are in question
+ case RT_TYPE_MODULE:
+ aRet <<= Reference< XTypeDescription >( new TypeDescriptionImpl(
+ TypeClass_MODULE, aName ) );
+ break;
+ case RT_TYPE_SERVICE:
+ aRet <<= Reference< XTypeDescription >( new TypeDescriptionImpl(
+ TypeClass_SERVICE, aName ) );
+ break;
+// case RT_TYPE_INVALID:
+// case RT_TYPE_CONSTANTS:
+// case RT_TYPE_OBJECT:
+ default: // existing registry node
+ aRet <<= Reference< XTypeDescription >( new TypeDescriptionImpl(
+ TypeClass_UNKNOWN, aName ) );
+ break;
+*/
+ }
+ }
+ xKey->closeKey();
+ }
+ else // might be a constant
+ {
+ sal_Int32 nIndex = aKey.lastIndexOf( '/' );
+ if (nIndex > 0)
+ {
+ // open module
+ Reference< XRegistryKey > xKey( xBaseKey->openKey( aKey.copy( 0, nIndex ) ) );
+ if (xKey.is())
+ {
+ if (xKey->getValueType() == RegistryValueType_BINARY)
+ {
+ Sequence< sal_Int8 > aBytes( xKey->getBinaryValue() );
+ RegistryTypeReader aReader(
+ _aLoader, (const sal_uInt8 *)aBytes.getConstArray(),
+ aBytes.getLength(), sal_False );
+
+ if (aReader.getTypeClass() == RT_TYPE_MODULE ||
+ aReader.getTypeClass() == RT_TYPE_CONSTANTS ||
+ aReader.getTypeClass() == RT_TYPE_ENUM)
+ {
+ OUString aFieldName( aKey.copy( nIndex+1, aKey.getLength() - nIndex -1 ) );
+ sal_Int32 nPos = aReader.getFieldCount();
+ while (nPos--)
+ {
+ if ( aFieldName.equals( aReader.getFieldName( (sal_uInt16)nPos )) )
+ break;
+ }
+ if (nPos >= 0)
+ aRet = getRTValue( aReader.getFieldConstValue( nPos ) );
+ }
+ }
+ xKey->closeKey();
+ }
+ }
+ }
+ }
+ }
+
+ if (! aRet.hasValue())
+ {
+ NoSuchElementException aExc;
+ aExc.Message = rName;
+ throw aExc;
+ }
+ return aRet;
+}
+//__________________________________________________________________________________________________
+sal_Bool ProviderImpl::hasByHierarchicalName( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ try
+ {
+ return getByHierarchicalName( rName ).hasValue();
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ return sal_False;
+}
+
+//==================================================================================================
+static Reference< XInterface > SAL_CALL ProviderImpl_create( const Reference< XMultiServiceFactory > & xMgr )
+ throw(::com::sun::star::uno::Exception)
+{
+ return Reference< XInterface >( *new ProviderImpl( xMgr ) );
+}
+
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL = stoc_rdbtdp::getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
+ stoc_rdbtdp::ProviderImpl_create,
+ stoc_rdbtdp::getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
diff --git a/stoc/source/servicemanager/makefile.mk b/stoc/source/servicemanager/makefile.mk
new file mode 100644
index 000000000000..fe8980004a31
--- /dev/null
+++ b/stoc/source/servicemanager/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= smgr
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+BOOTSTRAP_SERVICE=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/servicemanager.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx
new file mode 100644
index 000000000000..4613d3669d1f
--- /dev/null
+++ b/stoc/source/servicemanager/servicemanager.cxx
@@ -0,0 +1,1422 @@
+/*************************************************************************
+ *
+ * $RCSfile: servicemanager.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#include <stl/hash_map>
+#include <stl/hash_set>
+
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+#ifndef _UNO_DISPATCHER_H_
+#include <uno/dispatcher.h>
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAKREF_HXX_
+#include <cppuhelper/weakref.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/container/XElementAccess.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+using namespace std;
+
+namespace stoc_smgr
+{
+
+/*****************************************************************************
+ helper functions
+*****************************************************************************/
+OUString Point2Slash(const OUString& s)
+{
+ static OUString slash( RTL_CONSTASCII_USTRINGPARAM("/") );
+
+ OUString ret;
+
+ sal_Int32 tokenCount = s.getTokenCount(L'.');
+
+ for (sal_Int32 i = 0; i < tokenCount; i++)
+ {
+ OUString token = s.getToken(i, L'.');
+
+ if (token.len())
+ ret = ret + slash + token;
+ }
+
+ return ret;
+}
+
+/*****************************************************************************
+ Enumeration by ServiceName
+*****************************************************************************/
+struct hashRef_Impl
+{
+ size_t operator()(const Reference<XInterface > & rName) const
+ {
+ // query to XInterface. The cast to XInterface* must be the same for the same object
+ Reference<XInterface > x( Reference<XInterface >::query( rName ) );
+ return (size_t)x.get();
+ }
+};
+
+struct equaltoRef_Impl
+{
+ size_t operator()(const Reference<XInterface > & rName1, const Reference<XInterface > & rName2 ) const
+ { return rName1 == rName2; }
+};
+
+typedef hash_set
+<
+ Reference<XInterface >,
+ hashRef_Impl,
+ equaltoRef_Impl
+> HashSet_Ref;
+
+
+class ServiceEnumeration_Impl : public WeakImplHelper1< XEnumeration >
+{
+public:
+ ServiceEnumeration_Impl( const Sequence< Reference<XInterface > > & rFactories )
+ : aFactories( rFactories )
+ , nIt( 0 )
+ {}
+ virtual ~ServiceEnumeration_Impl() {};
+
+ // XEnumeration
+ sal_Bool SAL_CALL hasMoreElements()
+ throw(::com::sun::star::uno::RuntimeException);
+ Any SAL_CALL nextElement()
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+private:
+ Mutex aMutex;
+ Sequence< Reference<XInterface > > aFactories;
+ sal_Int32 nIt;
+};
+
+// XEnumeration
+sal_Bool ServiceEnumeration_Impl::hasMoreElements() throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( aMutex );
+ return nIt != aFactories.getLength();
+}
+
+// XEnumeration
+Any ServiceEnumeration_Impl::nextElement()
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( aMutex );
+ if( nIt == aFactories.getLength() )
+ throw NoSuchElementException();
+
+ return Any( &aFactories.getConstArray()[nIt++], ::getCppuType( (const Reference<XInterface > *)0 ) );
+}
+
+/*****************************************************************************
+ Enumeration by implementation
+*****************************************************************************/
+class ImplementationEnumeration_Impl : public WeakImplHelper1< XEnumeration >
+{
+public:
+ ImplementationEnumeration_Impl( const HashSet_Ref & rImplementationMap )
+ : aImplementationMap( rImplementationMap )
+ , aIt( aImplementationMap.begin() )
+ {}
+ virtual ~ImplementationEnumeration_Impl();
+
+ // XEnumeration
+ virtual sal_Bool SAL_CALL hasMoreElements()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual Any SAL_CALL nextElement()
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+private:
+ Mutex aMutex;
+ HashSet_Ref aImplementationMap;
+ HashSet_Ref::iterator aIt;
+ sal_Int32 nNext;
+ Reference<XInterface > xNext;
+};
+
+ImplementationEnumeration_Impl::~ImplementationEnumeration_Impl()
+{
+}
+
+// XEnumeration
+sal_Bool ImplementationEnumeration_Impl::hasMoreElements()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( aMutex );
+ return aIt != aImplementationMap.end();
+}
+
+// XEnumeration
+Any ImplementationEnumeration_Impl::nextElement()
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( aMutex );
+ if( aIt == aImplementationMap.end() )
+ throw NoSuchElementException();
+
+ Any ret( &(*aIt), ::getCppuType( (const Reference<XInterface > *)0 ) );
+ ++aIt;
+ return ret;
+}
+
+/*****************************************************************************
+ Hash tables
+*****************************************************************************/
+struct equalOWString_Impl
+{
+ sal_Bool operator()(const OUString & s1, const OUString & s2) const
+ { return s1 == s2; }
+};
+
+struct hashOWString_Impl
+{
+ size_t operator()(const OUString & rName) const
+ { return rName.hashCode(); }
+};
+
+typedef hash_set
+<
+ OUString,
+ hashOWString_Impl,
+ equalOWString_Impl
+> HashSet_OWString;
+
+typedef hash_multimap
+<
+ OUString,
+ Reference<XInterface >,
+ hashOWString_Impl,
+ equalOWString_Impl
+> HashMultimap_OWString_Interface;
+
+typedef hash_map
+<
+ OUString,
+ Reference<XInterface >,
+ hashOWString_Impl,
+ equalOWString_Impl
+> HashMap_OWString_Interface;
+
+/*****************************************************************************
+ class OServiceManager_Listener
+*****************************************************************************/
+class OServiceManager_Listener : public WeakImplHelper1< XEventListener >
+{
+private:
+ WeakReference<XSet > xSMgr;
+
+public:
+ OServiceManager_Listener( const Reference<XSet > & rSMgr )
+ : xSMgr( rSMgr )
+ {}
+
+ // XEventListener
+ virtual void SAL_CALL disposing(const EventObject & rEvt ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+void OServiceManager_Listener::disposing(const EventObject & rEvt )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference<XSet > x( xSMgr );
+ if( x.is() )
+ {
+ try
+ {
+ x->remove( Any( &rEvt.Source, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
+ }
+ catch( const IllegalArgumentException & )
+ {
+ OSL_ENSHURE( sal_False, "IllegalArgumentException catched" );
+ }
+ catch( const NoSuchElementException & )
+ {
+ OSL_ENSHURE( sal_False, "NoSuchElementException catched" );
+ }
+ }
+}
+
+
+/*****************************************************************************
+ class OServiceManager
+*****************************************************************************/
+struct OServiceManagerMutex
+{
+ Mutex m_mutex;
+};
+
+class OServiceManager
+ : public XMultiServiceFactory
+ , public XSet
+ , public XContentEnumerationAccess
+ , public XServiceInfo
+ , public OServiceManagerMutex
+ , public OComponentHelper
+{
+public:
+ OServiceManager();
+ ~OServiceManager();
+
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw()
+ { OComponentHelper::acquire(); }
+ virtual void SAL_CALL release() throw()
+ { OComponentHelper::release(); }
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ static OUString getImplementationName_Static() throw(::com::sun::star::uno::RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.OServiceManager") ); }
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+ static Sequence< OUString > getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException);
+
+ // XMultiServiceFactory
+ virtual Sequence< OUString > SAL_CALL getAvailableServiceNames() throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference<XInterface > SAL_CALL createInstance(const OUString &) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual Reference<XInterface > SAL_CALL createInstanceWithArguments(const OUString &, const Sequence<Any >& Arguments) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // The same as the interface method, but only uique names
+ Sequence< OUString > getAvailableServiceNames( HashSet_OWString & aNameSet );
+
+ // XElementAccess
+ virtual Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual Reference<XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException);
+
+ // XSet
+ virtual sal_Bool SAL_CALL has( const Any & Element ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL insert( const Any & Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL remove( const Any & Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+ // XContentEnumerationAccess
+ //Sequence< OUString > getAvailableServiceNames() throw( (Exception) );
+ virtual Reference<XEnumeration > SAL_CALL createContentEnumeration(const OUString& aServiceName) throw(::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+ sal_Bool haveFactoryWithThisImplementation(const OUString& aImplName);
+
+ virtual Reference<XSingleServiceFactory > queryServiceFactory(const OUString& aServiceName);
+private:
+
+ Reference<XEventListener > getFactoryListener();
+
+ HashMultimap_OWString_Interface m_ServiceMap;
+ HashSet_Ref m_ImplementationMap;
+ HashMap_OWString_Interface m_ImplementationNameMap;
+ Reference<XEventListener > xFactoryListener;
+};
+
+/**
+ * Create a ServiceManager
+ */
+OServiceManager::OServiceManager()
+ : OComponentHelper( m_mutex )
+{
+}
+
+/**
+ * Destroy the ServiceManager
+ */
+OServiceManager::~OServiceManager()
+{
+}
+
+// OComponentHelper
+void OServiceManager::dispose()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ // notify the disposing listener, the service manager is still full alive
+ EventObject aEvt;
+ aEvt.Source = Reference<XInterface >( *this );
+ rBHelper.aLC.disposeAndClear( aEvt );
+
+ // dispose all factories
+ HashSet_Ref aImpls;
+ {
+ MutexGuard aGuard( m_mutex );
+ aImpls = m_ImplementationMap;
+ }
+ HashSet_Ref::iterator aIt = aImpls.begin();
+ while( aIt != aImpls.end() )
+ {
+ Reference<XComponent > xComp( Reference<XComponent >::query( *aIt++ ) );
+ if( xComp.is() )
+ xComp->dispose();
+ }
+
+ // set the service manager to disposed
+ OComponentHelper::dispose();
+
+ // dispose
+ HashSet_Ref aImplMap;
+ {
+ MutexGuard aGuard( m_mutex );
+ // erase all members
+ m_ServiceMap = HashMultimap_OWString_Interface();
+ aImplMap = m_ImplementationMap;
+ m_ImplementationMap = HashSet_Ref();
+ m_ImplementationNameMap = HashMap_OWString_Interface();
+ }
+
+ // not only the Event should hold the object
+ OSL_ASSERT( m_refCount != 1 );
+}
+
+// XTypeProvider
+Sequence< Type > OServiceManager::getTypes()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ),
+ ::getCppuType( (const Reference< XSet > *)0 ),
+ ::getCppuType( (const Reference< XContentEnumerationAccess > *)0 ),
+ ::getCppuType( (const Reference< XServiceInfo > *)0 ),
+ OComponentHelper::getTypes() );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+Sequence< sal_Int8 > OServiceManager::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * s_pId = 0;
+ if (! s_pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pId)
+ {
+ static OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+}
+
+// OServiceManager
+Reference<XEventListener > OServiceManager::getFactoryListener()
+{
+ MutexGuard aGuard( m_mutex );
+ if( !xFactoryListener.is() )
+ xFactoryListener = new OServiceManager_Listener( this );
+ return xFactoryListener;
+}
+
+// XInterface
+Any OServiceManager::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( ::cppu::queryInterface(
+ rType,
+ static_cast< XMultiServiceFactory * >( this ),
+ static_cast< XServiceInfo * >( this ),
+ static_cast< XContentEnumerationAccess *>( this ),
+ static_cast< XSet *>( this ),
+ static_cast< XEnumerationAccess *>( this ),
+ static_cast< XElementAccess *>( this ) ) );
+
+ return (aRet.hasValue() ? aRet : OComponentHelper::queryInterface( rType ));
+}
+
+// XMultiServiceFactory, XContentEnumeration
+Sequence< OUString > OServiceManager::getAvailableServiceNames( HashSet_OWString & aNameSet )
+{
+ MutexGuard aGuard( m_mutex );
+
+ HashMultimap_OWString_Interface::iterator aSIt = m_ServiceMap.begin();
+ while( aSIt != m_ServiceMap.end() )
+ aNameSet.insert( (*aSIt++).first );
+
+ /* do not return the implementation names
+ HashMap_OWString_Interface m_ImplementationNameMap;
+ HashMap_OWString_Interface::iterator aIt = m_ImplementationNameMap.begin();
+ while( aIt != m_ImplementationNameMap.end() )
+ aNameSet.insert( (*aIt++).first );
+ */
+
+ Sequence< OUString > aNames( aNameSet.size() );
+ OUString * pArray = aNames.getArray();
+ sal_Int32 i = 0;
+ HashSet_OWString::iterator next = aNameSet.begin();
+ while( next != aNameSet.end() )
+ pArray[i++] = (*next++);
+
+ return aNames;
+}
+
+// XMultiServiceFactory, XContentEnumeration
+Sequence< OUString > OServiceManager::getAvailableServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ // all names
+ HashSet_OWString aNameSet;
+ return getAvailableServiceNames( aNameSet );
+}
+
+// XMultibleServiceFactory
+Reference<XInterface > OServiceManager::createInstance(const OUString& ServiceSpecifier )
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ ClearableMutexGuard aGuard( m_mutex );
+
+ Reference<XSingleServiceFactory > xFactory( queryServiceFactory( ServiceSpecifier ) );
+
+ Reference<XInterface > xRet;
+ if( xFactory.is() )
+ {
+ aGuard.clear();
+ xRet = xFactory->createInstance();
+ }
+ return xRet;
+}
+
+// XMultibleServiceFactory
+Reference<XInterface > OServiceManager::createInstanceWithArguments
+(
+ const OUString& ServiceSpecifier,
+ const Sequence<Any >& Arguments
+)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ ClearableMutexGuard aGuard( m_mutex );
+ Reference<XInterface > xRet;
+ Reference<XSingleServiceFactory > xFactory( queryServiceFactory( ServiceSpecifier ) );
+ aGuard.clear();
+
+ if( xFactory.is() )
+ {
+ // single service factory found
+ if( Arguments.getLength() )
+ xRet = xFactory->createInstanceWithArguments( Arguments );
+ else
+ xRet = xFactory->createInstance();
+ }
+// else if( Arguments.getLength()
+// && !Arguments.getConstArray()[0].hasValue() )
+// {
+ // JSC: muss noch mal ueberdacht werden !!!!
+ /*
+ // multible service factory found
+ XMultiServiceFactoryRef xFactory( xProv, USR_QUERY );
+ if( xFactory.is() )
+ {
+ OUString aNextServiceSpecifier = Arguments.getConstArray()[0].getString();
+ // Remove the first element from the argument list
+ Sequence<UsrAny> aNewArgs = Arguments;
+ SequenceRemoveElementAt( aNewArgs, 0 );
+ // create instance
+ if( aNewArgs.getLen() )
+ xRet = xFactory->createInstanceWithArguments( aNextServiceSpecifier, aNewArgs );
+ else
+ xRet = xFactory->createInstance( aNextServiceSpecifier );
+ }
+ */
+// }
+
+ return xRet;
+}
+
+// XServiceInfo
+OUString OServiceManager::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+// XServiceInfo
+sal_Bool OServiceManager::supportsService(const OUString& ServiceName)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+// XServiceInfo
+Sequence< OUString > OServiceManager::getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+// OServiceManager_Static
+Sequence< OUString > OServiceManager::getSupportedServiceNames_Static()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Sequence< OUString > aSNS( 2 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory") );
+ aSNS.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.ServiceManager") );
+ return aSNS;
+}
+
+Reference<XSingleServiceFactory > OServiceManager::queryServiceFactory(const OUString& aServiceName)
+{
+ MutexGuard aGuard( m_mutex );
+ Reference<XSingleServiceFactory > xRet;
+
+ HashMultimap_OWString_Interface::iterator aMultiIt =
+ ((OServiceManager*)this)->m_ServiceMap.find( aServiceName );
+ if( aMultiIt == ((OServiceManager*)this)->m_ServiceMap.end() )
+ {
+ // no service found, look for an implementation
+ HashMap_OWString_Interface::iterator aIt =
+ ((OServiceManager*)this)->m_ImplementationNameMap.find( aServiceName );
+ if( aIt != ((OServiceManager*)this)->m_ImplementationNameMap.end() )
+ // an implementation found
+ xRet = Reference<XSingleServiceFactory >::query( (*aIt).second );
+ }
+ else
+ {
+ xRet = Reference<XSingleServiceFactory >::query( (*aMultiIt).second );
+ }
+
+ return xRet;
+}
+
+// XContentEnumerationAccess
+Reference<XEnumeration > OServiceManager::createContentEnumeration(const OUString& aServiceName)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( ((OServiceManager *)this)->m_mutex );
+
+ // get all factories
+ pair<HashMultimap_OWString_Interface::iterator, HashMultimap_OWString_Interface::iterator>
+ p = ((OServiceManager *)this)->m_ServiceMap.equal_range( aServiceName );
+
+ if( p.first == p.second )
+ // nothing
+ return Reference<XEnumeration >();
+
+ // get the length of the sequence
+ sal_Int32 nLen = 0;
+ HashMultimap_OWString_Interface::iterator next = p.first;
+ while( next != p.second )
+ {
+ nLen++;
+ next++;
+ }
+
+ Sequence< Reference<XInterface > > aFactories( nLen );
+ Reference<XInterface > * pArray = aFactories.getArray();
+ sal_Int32 i = 0;
+ while( p.first != p.second )
+ {
+ pArray[i++] = (*p.first).second;
+ p.first++;
+ }
+ return new ServiceEnumeration_Impl( aFactories );
+}
+
+// XEnumeration
+Reference<XEnumeration > OServiceManager::createEnumeration() throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( m_mutex );
+ return new ImplementationEnumeration_Impl( m_ImplementationMap );
+}
+
+// XElementAccess
+Type OServiceManager::getElementType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::getCppuType( (const Reference< XInterface > *)0 );
+}
+
+// XElementAccess
+sal_Bool OServiceManager::hasElements()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( m_mutex );
+ return !m_ImplementationMap.empty();
+}
+
+// XSet
+sal_Bool OServiceManager::has( const Any & Element )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if( Element.getValueTypeClass() == TypeClass_INTERFACE )
+ {
+ MutexGuard aGuard( m_mutex );
+ HashSet_Ref::iterator aIt =
+ ((OServiceManager*)this)->m_ImplementationMap.find( *(Reference<XInterface >*)Element.getValue() );
+ return aIt != m_ImplementationMap.end();
+ }
+ return sal_False;
+}
+
+// XSet
+void OServiceManager::insert( const Any & Element )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException)
+{
+ if( Element.getValueTypeClass() != TypeClass_INTERFACE )
+ throw IllegalArgumentException();
+ Reference<XInterface > xEle( *(Reference<XInterface >*)Element.getValue(), UNO_QUERY );
+ if( !xEle.is() )
+ throw IllegalArgumentException();
+
+ {
+ MutexGuard aGuard( m_mutex );
+ HashSet_Ref::iterator aIt = m_ImplementationMap.find( xEle );
+ if( aIt != m_ImplementationMap.end() )
+ throw ElementExistException();
+
+ // put into the implementation hashmap
+ m_ImplementationMap.insert( xEle );
+
+ // put into the implementation name hashmap
+ Reference<XServiceInfo > xInfo( Reference<XServiceInfo >::query( xEle ) );
+ if( xInfo.is() )
+ {
+ OUString aImplName = xInfo->getImplementationName();
+ if( aImplName.len() )
+ m_ImplementationNameMap[ aImplName ] = xEle;
+ }
+
+ //put into the service map
+ Reference<XServiceInfo > xSF( Reference<XServiceInfo >::query( xEle ) );
+ if( xSF.is() )
+ {
+ Sequence< OUString > aServiceNames = xSF->getSupportedServiceNames();
+ const OUString * pArray = aServiceNames.getConstArray();
+ for( sal_Int32 i = 0; i < aServiceNames.getLength(); i++ )
+ m_ServiceMap.insert( HashMultimap_OWString_Interface::value_type( pArray[i],
+ *(Reference<XInterface > *)Element.getValue() ) );
+ }
+ }
+ // add the disposing listener to the factory
+ Reference<XComponent > xComp( Reference<XComponent >::query( xEle ) );
+ if( xComp.is() )
+ xComp->addEventListener( getFactoryListener() );
+}
+
+// helper function
+sal_Bool OServiceManager::haveFactoryWithThisImplementation(const OUString& aImplName)
+{
+ if( m_ImplementationNameMap.find(aImplName) != m_ImplementationNameMap.end())
+ return sal_True;
+ else
+ return sal_False;
+}
+
+// XSet
+void OServiceManager::remove( const Any & Element )
+ throw(::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ if( Element.getValueTypeClass() != TypeClass_INTERFACE )
+ throw IllegalArgumentException();
+ Reference<XInterface > xEle = *(Reference<XInterface > *)Element.getValue();
+ if( !xEle.is() )
+ throw IllegalArgumentException();
+
+ // remove the disposing listener from the factory
+ Reference<XComponent > xComp( Reference<XComponent >::query( xEle ) );
+ if( xComp.is() )
+ xComp->removeEventListener( getFactoryListener() );
+
+ MutexGuard aGuard( m_mutex );
+ HashSet_Ref::iterator aIt = m_ImplementationMap.find( xEle );
+ if( aIt == m_ImplementationMap.end() )
+ throw NoSuchElementException();
+
+ // remove from the implementation map
+ m_ImplementationMap.erase( aIt );
+ // remove from the implementation name hashmap
+ Reference<XServiceInfo > xInfo( Reference<XServiceInfo >::query( xEle ) );
+ if( xInfo.is() )
+ {
+ OUString aImplName = xInfo->getImplementationName();
+ if( aImplName.len() )
+ m_ImplementationNameMap.erase( aImplName );
+ }
+
+ //remove from the service map
+ Reference<XServiceInfo > xSF( Reference<XServiceInfo >::query( xEle ) );
+ if( xSF.is() )
+ {
+ Sequence< OUString > aServiceNames = xSF->getSupportedServiceNames();
+ const OUString * pArray = aServiceNames.getConstArray();
+ for( sal_Int32 i = 0; i < aServiceNames.getLength(); i++ )
+ {
+ pair<HashMultimap_OWString_Interface::iterator, HashMultimap_OWString_Interface::iterator> p =
+ m_ServiceMap.equal_range( pArray[i] );
+
+ while( p.first != p.second )
+ {
+ if( xEle == (*p.first).second )
+ {
+ m_ServiceMap.erase( p.first );
+ break;
+ }
+ p.first++;
+ }
+ }
+ }
+}
+
+/*****************************************************************************
+ class ORegistryServiceManager
+*****************************************************************************/
+class ORegistryServiceManager
+ : public XInitialization
+ , public XPropertySet
+ , public OServiceManager
+{
+public:
+ ORegistryServiceManager();
+ ~ORegistryServiceManager();
+
+ Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL acquire() throw()
+ { OServiceManager::acquire(); }
+ void SAL_CALL release() throw()
+ { OServiceManager::release(); }
+
+ // XInitialization
+ void SAL_CALL initialize(const Sequence< Any >& Arguments)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ static OUString getImplementationName_Static() throw(::com::sun::star::uno::RuntimeException)
+ { return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.ORegistryServiceManager") ); }
+
+ //sal_Bool supportsService(const OUString& ServiceName) throw( () );
+ Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+ static Sequence< OUString > getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException);
+
+ // XMultiServiceFactory
+ Sequence< OUString > SAL_CALL getAvailableServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ Sequence< Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
+ Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+ // XContentEnumerationAccess
+ //Sequence< OUString > getAvailableServiceNames() throw( (Exception) );
+ Reference<XEnumeration > SAL_CALL createContentEnumeration(const OUString& aServiceName) throw(::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ Reference<XPropertySetInfo > SAL_CALL getPropertySetInfo()
+ throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL setPropertyValue(const OUString& PropertyName, const Any& aValue)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ Any SAL_CALL getPropertyValue(const OUString& PropertyName)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ void SAL_CALL addPropertyChangeListener(const OUString& PropertyName, const Reference<XPropertyChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ void SAL_CALL removePropertyChangeListener(const OUString& PropertyName, const Reference<XPropertyChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const Reference<XVetoableChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName, const Reference<XVetoableChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+protected:
+ //OServiceManager
+ Reference<XSingleServiceFactory > queryServiceFactory(const OUString& aServiceName);
+private:
+
+ Reference<XRegistryKey > getRootKey();
+ Reference<XSingleServiceFactory > loadWithImplementationName( const OUString & rImplName );
+ Sequence<OUString> getFromServiceName(const OUString& serviceName);
+ Reference<XSingleServiceFactory > loadWithServiceName( const OUString & rImplName );
+ void fillAllNamesFromRegistry( HashSet_OWString & );
+
+ sal_Bool m_searchedRegistry;
+ Reference<XSimpleRegistry > m_xRegistry; // readonly property Registry
+ Reference<XRegistryKey > m_xRootKey;
+};
+
+/**
+ * Create a ServiceManager
+ */
+ORegistryServiceManager::ORegistryServiceManager()
+ : m_searchedRegistry(sal_False)
+{
+}
+
+/**
+ * Destroy the ServiceManager
+ */
+ORegistryServiceManager::~ORegistryServiceManager()
+{
+}
+
+// OComponentHelper
+void ORegistryServiceManager::dispose()throw(::com::sun::star::uno::RuntimeException)
+{
+ OServiceManager::dispose();
+ // dispose
+ MutexGuard aGuard( m_mutex );
+ // erase all members
+ m_xRegistry = Reference<XSimpleRegistry >();
+ m_xRootKey = Reference<XRegistryKey >();
+}
+
+// XTypeProvider
+Sequence< Type > ORegistryServiceManager::getTypes()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * pTypes = 0;
+ if (! pTypes)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pTypes)
+ {
+ static OTypeCollection aTypes(
+ ::getCppuType( (const Reference< XPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XInitialization > *)0 ),
+ OServiceManager::getTypes() );
+ pTypes = &aTypes;
+ }
+ }
+ return pTypes->getTypes();
+}
+Sequence< sal_Int8 > ORegistryServiceManager::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+/**
+ * Return the root key of the registry. The Default registry service is ordered
+ * if no registry is set.
+ */
+//Reference<XServiceProvider > create_DefaultRegistry_ServiceProvider();
+
+Reference<XRegistryKey > ORegistryServiceManager::getRootKey()
+{
+ MutexGuard aGuard( m_mutex );
+ {
+ // DefaultRegistry suchen !!!!
+ if( !m_xRegistry.is() && !m_searchedRegistry )
+ {
+ // merken, es wird nur einmal gesucht
+ m_searchedRegistry = sal_True;
+
+ Reference<XSingleServiceFactory > xFact = queryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.DefaultRegistry") ) );
+ if ( xFact.is() )
+ {
+ m_xRegistry = Reference<XSimpleRegistry >::query( xFact->createInstance() );
+ }
+ }
+
+ if( m_xRegistry.is() && !m_xRootKey.is() )
+ m_xRootKey = m_xRegistry->getRootKey();
+ return m_xRootKey;
+ }
+}
+
+/**
+ * Create a service provider from the registry with an implementation name
+ */
+Reference<XSingleServiceFactory > ORegistryServiceManager::loadWithImplementationName(const OUString& name)
+{
+ Reference<XSingleServiceFactory > ret;
+
+ Reference<XRegistryKey > xRootKey = getRootKey();
+ if( !xRootKey.is() )
+ return ret;
+
+ try
+ {
+ OUString implementationName = OUString( RTL_CONSTASCII_USTRINGPARAM("/IMPLEMENTATIONS/") ) + name;
+ Reference<XRegistryKey > xImpKey = m_xRootKey->openKey(implementationName);
+
+ if( xImpKey.is() )
+ {
+ ret = createSingleRegistryFactory( this, name, xImpKey );
+ Any a( &ret, ::getCppuType( (const Reference<XInterface > *)0 ) );
+ insert( a );
+ }
+ }
+ catch (InvalidRegistryException &)
+ {
+ }
+ return ret;
+}
+
+/**
+ * Return all implementation out of the registry.
+ */
+Sequence<OUString> ORegistryServiceManager::getFromServiceName(const OUString& serviceName)
+{
+ Reference<XRegistryKey > xRootKey = getRootKey();
+ if( !xRootKey.is() )
+ return Sequence<OUString>();
+
+ try
+ {
+ OUString regName = OUString( RTL_CONSTASCII_USTRINGPARAM("/SERVICES/") ) + serviceName;
+ Reference<XRegistryKey > xServKey = m_xRootKey->openKey(regName);
+
+ if( xServKey.is() && xServKey->getValueType() == RegistryValueType_ASCIILIST )
+ {
+ return xServKey->getAsciiListValue();
+ }
+ }
+ catch (InvalidRegistryException &)
+ {
+ }
+
+ return Sequence<OUString>();
+}
+
+/**
+ * Create a service provider from the registry
+ */
+Reference<XSingleServiceFactory > ORegistryServiceManager::loadWithServiceName(const OUString& serviceName)
+{
+ Sequence<OUString> implEntries = getFromServiceName( serviceName );
+ for (sal_Int32 i = 0; i < implEntries.getLength(); i++)
+ return loadWithImplementationName( implEntries.getConstArray()[i] );
+
+ return Reference<XSingleServiceFactory >();
+}
+
+/**
+ * Return a sequence of all service names from the registry.
+ */
+void ORegistryServiceManager::fillAllNamesFromRegistry( HashSet_OWString & rSet )
+{
+ Reference<XRegistryKey > xRootKey = getRootKey();
+ if( !xRootKey.is() )
+ return;
+
+ try
+ {
+ Reference<XRegistryKey > xServicesKey = xRootKey->openKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("SERVICES") ) );
+ // root + /Services + /
+ if( xServicesKey.is() )
+ {
+ sal_Int32 nPrefix = xServicesKey->getKeyName().len() +1;
+ Sequence<Reference<XRegistryKey > > aKeys = xServicesKey->openKeys();
+ for( sal_Int32 i = 0; i < aKeys.getLength(); i++ )
+ rSet.insert( aKeys.getConstArray()[i]->getKeyName().copy( nPrefix ) );
+ }
+ }
+ catch (InvalidRegistryException &)
+ {
+ }
+}
+
+// XInterface
+Any ORegistryServiceManager::queryInterface( const Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet( cppu::queryInterface(
+ rType,
+ static_cast< XInitialization * >( this ),
+ static_cast< XPropertySet * >( this ) ) );
+
+ return (aRet.hasValue() ? aRet : OServiceManager::queryInterface( rType ));
+}
+
+// XInitialization
+void ORegistryServiceManager::initialize(const Sequence< Any >& Arguments)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ if( Arguments.getLength() == 0 )
+ return;
+ if( Arguments.getLength() != 1
+ || Arguments.getConstArray()[0].getValueTypeClass() != TypeClass_INTERFACE )
+ throw IllegalArgumentException();
+
+ Reference<XSimpleRegistry > xRef( Reference<XSimpleRegistry >::query(
+ *(Reference<XInterface > *)Arguments.getConstArray()[0].getValue() ) );
+ if( !xRef.is() )
+ throw IllegalArgumentException();
+
+ MutexGuard aGuard( m_mutex );
+ m_xRegistry = xRef;
+ m_xRootKey = Reference<XRegistryKey >();
+}
+
+// XMultiServiceFactory, XContentEnumeration
+Sequence< OUString > ORegistryServiceManager::getAvailableServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( m_mutex );
+ // all names
+ HashSet_OWString aNameSet;
+
+ // all names from the registry
+ fillAllNamesFromRegistry( aNameSet );
+
+ return OServiceManager::getAvailableServiceNames( aNameSet );
+}
+
+// XServiceInfo
+OUString ORegistryServiceManager::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+// XServiceInfo
+Sequence< OUString > ORegistryServiceManager::getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+// ORegistryServiceManager_Static
+Sequence< OUString > ORegistryServiceManager::getSupportedServiceNames_Static()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Sequence< OUString > aSNS( 2 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory") );
+ aSNS.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.RegistryServiceManager") );
+ return aSNS;
+}
+
+// OServiceManager
+Reference<XSingleServiceFactory > ORegistryServiceManager::queryServiceFactory(const OUString& aServiceName)
+{
+ Reference<XSingleServiceFactory > xRet = OServiceManager::queryServiceFactory( aServiceName );
+ if( !xRet.is() )
+ {
+ MutexGuard aGuard( m_mutex );
+ xRet = ((ORegistryServiceManager *)this)->loadWithServiceName( aServiceName );
+ if( !xRet.is() )
+ xRet = ((ORegistryServiceManager *)this)->loadWithImplementationName( aServiceName );
+ }
+
+ return xRet;
+}
+
+// XContentEnumerationAccess
+Reference<XEnumeration > ORegistryServiceManager::createContentEnumeration(const OUString& aServiceName)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( ((ORegistryServiceManager *)this)->m_mutex );
+ // get all implementation names registered under this service name from the registry
+ Sequence<OUString> aImpls = ((ORegistryServiceManager *)this)->getFromServiceName( aServiceName );
+ // load and insert all factories specified by the registry
+ sal_Int32 i;
+ OUString aImplName;
+ for( i = 0; i < aImpls.getLength(); i++ )
+ {
+ aImplName = aImpls.getConstArray()[i];
+ if ( !haveFactoryWithThisImplementation(aImplName) )
+ {
+ loadWithImplementationName( aImplName );
+ }
+ }
+ // call the superclass to enumerate all contents
+ return OServiceManager::createContentEnumeration( aServiceName );
+}
+
+// XPropertySet
+Reference<XPropertySetInfo > ORegistryServiceManager::getPropertySetInfo()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return Reference<XPropertySetInfo >();
+}
+
+void ORegistryServiceManager::setPropertyValue(const OUString& PropertyName,
+ const Any& aValue)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ throw UnknownPropertyException();
+}
+
+Any ORegistryServiceManager::getPropertyValue(const OUString& PropertyName)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ Any ret;
+
+ if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Registry") ))
+ {
+ MutexGuard aGuard( m_mutex );
+ if( m_xRegistry.is() )
+ {
+ ret = Any( &m_xRegistry, ::getCppuType( (const Reference<XSimpleRegistry > *)0 ) );
+ }
+ } else
+ {
+ UnknownPropertyException except;
+ except.Message = OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager : unknown property " ) );
+ except.Message += PropertyName;
+ throw except;
+ }
+
+ return ret;
+}
+
+void ORegistryServiceManager::addPropertyChangeListener(const OUString& PropertyName,
+ const Reference<XPropertyChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ throw UnknownPropertyException();
+}
+
+void ORegistryServiceManager::removePropertyChangeListener(const OUString& PropertyName,
+ const Reference<XPropertyChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ throw UnknownPropertyException();
+}
+
+void ORegistryServiceManager::addVetoableChangeListener(const OUString& PropertyName,
+ const Reference<XVetoableChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ throw UnknownPropertyException();
+}
+
+void ORegistryServiceManager::removeVetoableChangeListener(const OUString& PropertyName,
+ const Reference<XVetoableChangeListener >& aListener)
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ throw UnknownPropertyException();
+}
+
+
+/**
+ * Create the ServiceManager
+ */
+static Reference<XInterface > SAL_CALL OServiceManager_CreateInstance(const Reference<XMultiServiceFactory > & rSMgr)
+{
+ return Reference<XInterface >( SAL_STATIC_CAST( XInterface *, SAL_STATIC_CAST( OWeakObject *, new OServiceManager() ) ) );
+}
+
+/**
+ * Create the ServiceManager
+ */
+static Reference<XInterface > SAL_CALL ORegistryServiceManager_CreateInstance(const Reference<XMultiServiceFactory > & rSMgr)
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ return Reference<XInterface >( SAL_STATIC_CAST( XInterface *, SAL_STATIC_CAST( OWeakObject *, new ORegistryServiceManager() ) ) );
+}
+
+} // namespace
+
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ OUStringBuffer buf( 32 );
+ // OServiceManager
+ buf.append( (sal_Unicode)'/' );
+ buf.append( stoc_smgr::OServiceManager::getImplementationName_Static() );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/UNO/SERVICES") );
+ Reference<XRegistryKey> xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( buf.makeStringAndClear() ) );
+ const Sequence<OUString > & rSMnames =
+ stoc_smgr::OServiceManager::getSupportedServiceNames_Static();
+ const OUString * pNames = rSMnames.getConstArray();
+ sal_Int32 nPos;
+ for ( nPos = rSMnames.getLength(); nPos--; )
+ xNewKey->createKey( pNames[nPos] );
+
+ // ORegistryServiceManager
+ buf.append( (sal_Unicode)'/' );
+ buf.append( stoc_smgr::ORegistryServiceManager::getImplementationName_Static() );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/UNO/SERVICES") );
+ xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ buf.makeStringAndClear() );
+ const Sequence<OUString > & rRSMnames =
+ stoc_smgr::ORegistryServiceManager::getSupportedServiceNames_Static();
+ pNames = rRSMnames.getConstArray();
+ for ( nPos = rRSMnames.getLength(); nPos--; )
+ xNewKey->createKey( pNames[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ Reference< XSingleServiceFactory > xFactory;
+
+ if (stoc_smgr::OServiceManager::getImplementationName_Static().compareToAscii( pImplName ) == 0)
+ {
+ xFactory = createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ stoc_smgr::OServiceManager::getImplementationName_Static(),
+ stoc_smgr::OServiceManager_CreateInstance,
+ stoc_smgr::OServiceManager::getSupportedServiceNames_Static() );
+ }
+ if (stoc_smgr::ORegistryServiceManager::getImplementationName_Static().compareToAscii( pImplName ) == 0)
+ {
+ xFactory = createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ stoc_smgr::ORegistryServiceManager::getImplementationName_Static(),
+ stoc_smgr::ORegistryServiceManager_CreateInstance,
+ stoc_smgr::ORegistryServiceManager::getSupportedServiceNames_Static() );
+ }
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ return xFactory.get();
+ }
+ return 0;
+}
+}
+
+
diff --git a/stoc/source/simpleregistry/makefile.mk b/stoc/source/simpleregistry/makefile.mk
new file mode 100644
index 000000000000..c780de0ecef9
--- /dev/null
+++ b/stoc/source/simpleregistry/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= simreg
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+BOOTSTRAP_SERVICE=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/simpleregistry.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx
new file mode 100644
index 000000000000..9433c2f07dfb
--- /dev/null
+++ b/stoc/source/simpleregistry/simpleregistry.cxx
@@ -0,0 +1,1252 @@
+/*************************************************************************
+ *
+ * $RCSfile: simpleregistry.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#ifndef _REGISTRY_REGISTRY_HXX_
+#include <registry/registry.hxx>
+#endif
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::lang;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+#define SERVICENAME "com.sun.star.registry.SimpleRegistry"
+#define IMPLNAME "com.sun.star.comp.stoc.SimpleRegistry"
+
+namespace stoc_simreg {
+
+//*************************************************************************
+// class RegistryKeyImpl the implenetation of interface XRegistryKey
+//*************************************************************************
+class RegistryKeyImpl;
+
+//*************************************************************************
+// SimpleRegistryImpl
+//*************************************************************************
+class SimpleRegistryImpl : public WeakImplHelper2< XSimpleRegistry, XServiceInfo >
+{
+public:
+ SimpleRegistryImpl( const Reference<XMultiServiceFactory> & rXSMgr,
+ const Registry& rRegistry );
+
+ ~SimpleRegistryImpl();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( );
+
+ // XSimpleRegistry
+ virtual OUString SAL_CALL getURL() throw(RuntimeException);
+ virtual void SAL_CALL open( const OUString& rURL, sal_Bool bReadOnly, sal_Bool bCreate ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Bool SAL_CALL isValid( ) throw(RuntimeException);
+ virtual void SAL_CALL close( ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL destroy( ) throw(InvalidRegistryException, RuntimeException);
+ virtual Reference< XRegistryKey > SAL_CALL getRootKey( ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL mergeKey( const OUString& aKeyName, const OUString& aUrl ) throw(InvalidRegistryException, MergeConflictException, RuntimeException);
+
+ friend RegistryKeyImpl;
+protected:
+ Mutex m_mutex;
+ OUString m_url;
+ Registry m_registry;
+
+ Reference<XMultiServiceFactory> m_xSMgr;
+};
+
+
+class RegistryKeyImpl : public WeakImplHelper1< XRegistryKey >
+{
+public:
+ RegistryKeyImpl( const RegistryKey& rKey, SimpleRegistryImpl* pRegistry );
+
+ RegistryKeyImpl( const OUString& rKeyName, SimpleRegistryImpl* pRegistry );
+
+ ~RegistryKeyImpl();
+
+ // XRegistryKey
+ virtual OUString SAL_CALL getKeyName() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Bool SAL_CALL isValid( ) throw(RuntimeException);
+ virtual RegistryKeyType SAL_CALL getKeyType( const OUString& rKeyName ) throw(InvalidRegistryException, RuntimeException);
+ virtual RegistryValueType SAL_CALL getValueType( ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Int32 SAL_CALL getLongValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setLongValue( sal_Int32 value ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< sal_Int32 > SAL_CALL getLongListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setLongListValue( const ::com::sun::star::uno::Sequence< sal_Int32 >& seqValue ) throw(InvalidRegistryException, RuntimeException);
+ virtual OUString SAL_CALL getAsciiValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setAsciiValue( const OUString& value ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getAsciiListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setAsciiListValue( const ::com::sun::star::uno::Sequence< OUString >& seqValue ) throw(InvalidRegistryException, RuntimeException);
+ virtual OUString SAL_CALL getStringValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setStringValue( const OUString& value ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getStringListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setStringListValue( const ::com::sun::star::uno::Sequence< OUString >& seqValue ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getBinaryValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException);
+ virtual void SAL_CALL setBinaryValue( const ::com::sun::star::uno::Sequence< sal_Int8 >& value ) throw(InvalidRegistryException, RuntimeException);
+ virtual Reference< XRegistryKey > SAL_CALL openKey( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException);
+ virtual Reference< XRegistryKey > SAL_CALL createKey( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL closeKey( ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL deleteKey( const OUString& rKeyName ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< Reference< XRegistryKey > > SAL_CALL openKeys( ) throw(InvalidRegistryException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getKeyNames( ) throw(InvalidRegistryException, RuntimeException);
+ virtual sal_Bool SAL_CALL createLink( const OUString& aLinkName, const OUString& aLinkTarget ) throw(InvalidRegistryException, RuntimeException);
+ virtual void SAL_CALL deleteLink( const OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException);
+ virtual OUString SAL_CALL getLinkTarget( const OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException);
+ virtual OUString SAL_CALL getResolvedName( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException);
+
+protected:
+ OUString m_name;
+ RegistryKey m_key;
+ SimpleRegistryImpl* m_pRegistry;
+};
+
+//*************************************************************************
+RegistryKeyImpl::RegistryKeyImpl( const RegistryKey& key, SimpleRegistryImpl* pRegistry )
+ : m_key(key)
+ , m_pRegistry(pRegistry)
+{
+ m_pRegistry->acquire();
+ m_name = m_key.getName();
+}
+
+//*************************************************************************
+RegistryKeyImpl::RegistryKeyImpl( const OUString& rKeyName,
+ SimpleRegistryImpl* pRegistry )
+ : m_pRegistry(pRegistry)
+{
+ m_pRegistry->acquire();
+
+ RegistryKey rootKey;
+ if (!pRegistry->m_registry.isValid() ||
+ pRegistry->m_registry.openRootKey(rootKey))
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ if ( rootKey.openKey(rKeyName, m_key) )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ m_name = rKeyName;
+ }
+ }
+}
+
+//*************************************************************************
+RegistryKeyImpl::~RegistryKeyImpl()
+{
+ m_pRegistry->release();
+}
+
+//*************************************************************************
+OUString SAL_CALL RegistryKeyImpl::getKeyName() throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ return m_name;
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL RegistryKeyImpl::isReadOnly( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if (m_key.isValid())
+ {
+ return(m_key.isReadOnly());
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return sal_False;
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL RegistryKeyImpl::isValid( ) throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ return m_key.isValid();
+}
+
+//*************************************************************************
+RegistryKeyType SAL_CALL RegistryKeyImpl::getKeyType( const OUString& rKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( m_key.isValid() )
+ {
+ RegKeyType keyType;
+ if ( !m_key.getKeyType(rKeyName, &keyType) )
+ {
+ switch (keyType)
+ {
+ case RG_KEYTYPE:
+ return RegistryKeyType_KEY;
+ break;
+ case RG_LINKTYPE:
+ return RegistryKeyType_LINK;
+ break;
+ }
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+ } else
+ {
+ throw InvalidRegistryException();
+ }
+
+ return RegistryKeyType_KEY;
+}
+
+//*************************************************************************
+RegistryValueType SAL_CALL RegistryKeyImpl::getValueType( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if (!m_key.isValid())
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegValueType type;
+ sal_uInt32 size;
+
+ if (m_key.getValueInfo(OUString(), &type, &size))
+ {
+ return RegistryValueType_NOT_DEFINED;
+ } else
+ {
+ switch (type)
+ {
+ case RG_VALUETYPE_LONG: return RegistryValueType_LONG;
+ case RG_VALUETYPE_STRING: return RegistryValueType_ASCII;
+ case RG_VALUETYPE_UNICODE: return RegistryValueType_STRING;
+ case RG_VALUETYPE_BINARY: return RegistryValueType_BINARY;
+ case RG_VALUETYPE_LONGLIST: return RegistryValueType_LONGLIST;
+ case RG_VALUETYPE_STRINGLIST: return RegistryValueType_ASCIILIST;
+ case RG_VALUETYPE_UNICODELIST: return RegistryValueType_STRINGLIST;
+ default: return RegistryValueType_NOT_DEFINED;
+ }
+ }
+ }
+
+ return RegistryValueType_NOT_DEFINED;
+}
+
+//*************************************************************************
+sal_Int32 SAL_CALL RegistryKeyImpl::getLongValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if (!m_key.isValid())
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegValueType type;
+ sal_uInt32 size;
+
+ if ( !m_key.getValueInfo(OUString(), &type, &size) )
+ {
+ if (type == RG_VALUETYPE_LONG)
+ {
+ sal_Int32 value;
+ if ( !m_key.getValue(OUString(), (RegValue)&value) )
+ {
+ return value;
+ }
+ }
+ }
+
+ throw InvalidValueException();
+ }
+
+ return 0;
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::setLongValue( sal_Int32 value )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ if (m_key.setValue(OUString(), RG_VALUETYPE_LONG, &value, sizeof(sal_Int32)))
+ {
+ throw InvalidValueException();
+ }
+ }
+}
+
+//*************************************************************************
+Sequence< sal_Int32 > SAL_CALL RegistryKeyImpl::getLongListValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegValueType type;
+ sal_uInt32 size;
+
+ if ( !m_key.getValueInfo(OUString(), &type, &size) )
+ {
+ if (type == RG_VALUETYPE_LONGLIST)
+ {
+ RegistryValueList<sal_Int32> tmpValue;
+ if ( !m_key.getLongListValue(OUString(), tmpValue) )
+ {
+ Sequence<sal_Int32> seqValue(size);
+
+ for (sal_uInt32 i=0; i < size; i++)
+ {
+ seqValue.getArray()[i] = tmpValue.getElement(i);
+ }
+
+ return seqValue;
+ }
+ }
+ }
+
+ throw InvalidValueException();
+ }
+
+ return Sequence<sal_Int32>();
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::setLongListValue( const Sequence< sal_Int32 >& seqValue )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ sal_uInt32 length = seqValue.getLength();
+ sal_Int32* tmpValue = new sal_Int32[length];
+
+ for (sal_uInt32 i=0; i < length; i++)
+ {
+ tmpValue[i] = seqValue.getConstArray()[i];
+ }
+
+ if ( m_key.setLongListValue(OUString(), tmpValue, length) )
+ {
+ delete[] tmpValue;
+ throw InvalidValueException();
+ }
+
+ delete[] tmpValue;
+ }
+}
+
+//*************************************************************************
+OUString SAL_CALL RegistryKeyImpl::getAsciiValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if (!m_key.isValid())
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegValueType type;
+ sal_uInt32 size;
+
+ if ( !m_key.getValueInfo(OUString(), &type, &size) )
+ {
+ if ( type == RG_VALUETYPE_STRING )
+ {
+ char* value = new char[size];
+ if ( m_key.getValue(OUString(), (RegValue)value) )
+ {
+ delete(value);
+ throw InvalidValueException();
+ } else
+ {
+ OUString ret(OStringToOUString(value, RTL_TEXTENCODING_ASCII_US));
+ delete(value);
+ return ret;
+ }
+ }
+ }
+
+ throw InvalidValueException();
+ }
+
+ return OUString();
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::setAsciiValue( const OUString& value )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ OString sValue = OUStringToOString(value, RTL_TEXTENCODING_ASCII_US);
+ sal_uInt32 size = sValue.getLength()+1;
+ if ( m_key.setValue(OUString(), RG_VALUETYPE_STRING,
+ (RegValue)(sValue.getStr()), size) )
+ {
+ throw InvalidValueException();
+ }
+ }
+}
+
+//*************************************************************************
+Sequence< OUString > SAL_CALL RegistryKeyImpl::getAsciiListValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegValueType type;
+ sal_uInt32 size;
+
+ if ( !m_key.getValueInfo(OUString(), &type, &size) )
+ {
+ if (type == RG_VALUETYPE_STRINGLIST)
+ {
+ RegistryValueList<char*> tmpValue;
+ if ( !m_key.getStringListValue(OUString(), tmpValue) )
+ {
+ Sequence<OUString> seqValue(size);
+
+ for (sal_uInt32 i=0; i < size; i++)
+ {
+ seqValue.getArray()[i] =
+ OStringToOUString(tmpValue.getElement(i), RTL_TEXTENCODING_ASCII_US);
+ }
+
+ return seqValue;
+ }
+ }
+ }
+
+ throw InvalidValueException();
+ }
+
+ return Sequence<OUString>();
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::setAsciiListValue( const Sequence< OUString >& seqValue )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ sal_uInt32 length = seqValue.getLength();
+ OString* pSValue = new OString[length];
+ char** tmpValue = new char*[length];
+
+ for (sal_uInt32 i=0; i < length; i++)
+ {
+ pSValue[i] = OUStringToOString(seqValue.getConstArray()[i], RTL_TEXTENCODING_ASCII_US);
+ tmpValue[i] = (char*)pSValue[i].getStr();
+ }
+
+ if ( m_key.setStringListValue(OUString(), tmpValue, length) )
+ {
+ delete[] pSValue;
+ delete[] tmpValue;
+ throw InvalidValueException();
+ }
+
+ delete[] pSValue;
+ delete[] tmpValue;
+ }
+}
+
+//*************************************************************************
+OUString SAL_CALL RegistryKeyImpl::getStringValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegValueType type;
+ sal_uInt32 size;
+
+ if ( !m_key.getValueInfo(OUString(), &type, &size) )
+ {
+ if (type == RG_VALUETYPE_UNICODE)
+ {
+ sal_Unicode* value = new sal_Unicode[size];
+ if ( m_key.getValue(OUString(), (RegValue)value) )
+ {
+ delete(value);
+ throw InvalidValueException();
+ } else
+ {
+ OUString ret(value);
+ delete(value);
+ return ret;
+ }
+ }
+ }
+
+ throw InvalidValueException();
+ }
+
+ return OUString();
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::setStringValue( const OUString& value )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ sal_uInt32 size = (value.getLength() + 1) * sizeof(sal_Unicode);
+ if ( m_key.setValue(OUString(), RG_VALUETYPE_UNICODE,
+ (RegValue)(value.getStr()), size) )
+ {
+ throw InvalidValueException();
+ }
+ }
+}
+
+//*************************************************************************
+Sequence< OUString > SAL_CALL RegistryKeyImpl::getStringListValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegValueType type;
+ sal_uInt32 size;
+
+ if ( !m_key.getValueInfo(OUString(), &type, &size) )
+ {
+ if (type == RG_VALUETYPE_UNICODELIST)
+ {
+ RegistryValueList<sal_Unicode*> tmpValue;
+ if ( !m_key.getUnicodeListValue(OUString(), tmpValue) )
+ {
+ Sequence<OUString> seqValue(size);
+
+ for (sal_uInt32 i=0; i < size; i++)
+ {
+ seqValue.getArray()[i] = OUString(tmpValue.getElement(i));
+ }
+
+ return seqValue;
+ }
+ }
+ }
+
+ throw InvalidValueException();
+ }
+
+ return Sequence<OUString>();
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::setStringListValue( const Sequence< OUString >& seqValue )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ sal_uInt32 length = seqValue.getLength();
+ sal_Unicode** tmpValue = new sal_Unicode*[length];
+
+ for (sal_uInt32 i=0; i < length; i++)
+ {
+ tmpValue[i] = (sal_Unicode*)seqValue.getConstArray()[i].getStr();
+ }
+
+ if (m_key.setUnicodeListValue(OUString(), tmpValue, length))
+ {
+ delete[] tmpValue;
+ throw InvalidValueException();
+ }
+
+ delete[] tmpValue;
+ }
+}
+
+//*************************************************************************
+Sequence< sal_Int8 > SAL_CALL RegistryKeyImpl::getBinaryValue( )
+ throw(InvalidRegistryException, InvalidValueException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegValueType type;
+ sal_uInt32 size;
+
+ if ( !m_key.getValueInfo(OUString(), &type, &size) )
+ {
+ if (type == RG_VALUETYPE_BINARY)
+ {
+ sal_Int8* value = new sal_Int8[size];
+ if (m_key.getValue(OUString(), (RegValue)value))
+ {
+ delete(value);
+ throw InvalidValueException();
+ } else
+ {
+ Sequence<sal_Int8> seqBytes(value, size);
+ delete(value);
+ return seqBytes;
+ }
+ }
+ }
+
+ throw InvalidValueException();
+ }
+
+ return Sequence< sal_Int8 >();
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::setBinaryValue( const Sequence< sal_Int8 >& value )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ sal_uInt32 size = value.getLength();
+ if ( m_key.setValue(OUString(), RG_VALUETYPE_BINARY,
+ (RegValue)(value.getConstArray()), size) )
+ {
+ throw InvalidValueException();
+ }
+ }
+}
+
+//*************************************************************************
+Reference< XRegistryKey > SAL_CALL RegistryKeyImpl::openKey( const OUString& aKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ RegistryKey newKey;
+
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegError _ret = REG_NO_ERROR;
+ if ( _ret = m_key.openKey(aKeyName, newKey) )
+ {
+ if ( _ret == REG_INVALID_KEY )
+ throw InvalidRegistryException();
+
+ return Reference<XRegistryKey>();
+ } else
+ {
+ return ((XRegistryKey*)new RegistryKeyImpl(newKey, m_pRegistry));
+ }
+ }
+
+ return Reference<XRegistryKey>();
+}
+
+//*************************************************************************
+Reference< XRegistryKey > SAL_CALL RegistryKeyImpl::createKey( const OUString& aKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ RegistryKey newKey;
+
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegError _ret = REG_NO_ERROR;
+ if ( _ret = m_key.createKey(aKeyName, newKey) )
+ {
+ if (_ret == REG_INVALID_KEY)
+ throw InvalidRegistryException();
+
+ return Reference<XRegistryKey>();
+ } else
+ {
+ return ((XRegistryKey*)new RegistryKeyImpl(newKey, m_pRegistry));
+ }
+ }
+
+ return Reference<XRegistryKey>();
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::closeKey( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( m_key.isValid() )
+ {
+ if ( !m_key.closeKey() )
+ return;
+ }
+
+ throw InvalidRegistryException();
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::deleteKey( const OUString& rKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( m_key.isValid() )
+ {
+ if ( !m_key.deleteKey(rKeyName) )
+ return;
+ }
+
+ throw InvalidRegistryException();
+}
+
+//*************************************************************************
+Sequence< Reference< XRegistryKey > > SAL_CALL RegistryKeyImpl::openKeys( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegistryKeyArray subKeys;
+ RegError _ret = REG_NO_ERROR;
+ if ( _ret = m_key.openSubKeys(OUString(), subKeys) )
+ {
+ if ( _ret == REG_INVALID_KEY )
+ throw InvalidRegistryException();
+
+ return Sequence< Reference<XRegistryKey> >();
+ } else
+ {
+ sal_uInt32 length = subKeys.getLength();
+ Sequence< Reference<XRegistryKey> > seqKeys(length);
+
+ for (sal_uInt32 i=0; i < length; i++)
+ {
+ seqKeys.getArray()[i] =
+ (XRegistryKey*) new RegistryKeyImpl(subKeys.getElement(i), m_pRegistry);
+ }
+ return seqKeys;
+ }
+ }
+
+ return Sequence< Reference<XRegistryKey> >();
+}
+
+//*************************************************************************
+Sequence< OUString > SAL_CALL RegistryKeyImpl::getKeyNames( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegistryKeyNames subKeys;
+ RegError _ret = REG_NO_ERROR;
+ if ( _ret = m_key.getKeyNames(OUString(), subKeys) )
+ {
+ if ( _ret == REG_INVALID_KEY )
+ throw InvalidRegistryException();
+
+ return Sequence<OUString>();
+ } else
+ {
+ sal_uInt32 length = subKeys.getLength();
+ Sequence<OUString> seqKeys(length);
+
+ for (sal_uInt32 i=0; i < length; i++)
+ {
+ seqKeys.getArray()[i] = subKeys.getElement(i);
+ }
+ return seqKeys;
+ }
+ }
+
+ return Sequence<OUString>();
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL RegistryKeyImpl::createLink( const OUString& aLinkName, const OUString& aLinkTarget )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegError ret = REG_NO_ERROR;
+
+ if ( ret = m_key.createLink(aLinkName, aLinkTarget) )
+ {
+ if ( ret == REG_DETECT_RECURSION ||
+ ret == REG_INVALID_KEY )
+ {
+ throw InvalidRegistryException();
+ } else
+ return sal_False;
+ } else
+ {
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+//*************************************************************************
+void SAL_CALL RegistryKeyImpl::deleteLink( const OUString& rLinkName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ if ( m_key.deleteLink(rLinkName) )
+ {
+ throw InvalidRegistryException();
+ }
+ }
+}
+
+//*************************************************************************
+OUString SAL_CALL RegistryKeyImpl::getLinkTarget( const OUString& rLinkName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ OUString linkTarget;
+
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegError ret = REG_NO_ERROR;
+
+ if ( ret = m_key.getLinkTarget(rLinkName, linkTarget) )
+ {
+ throw InvalidRegistryException();
+ }
+ }
+
+ return linkTarget;
+}
+
+//*************************************************************************
+OUString SAL_CALL RegistryKeyImpl::getResolvedName( const OUString& aKeyName )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ OUString resolvedName;
+
+ Guard< Mutex > aGuard( m_pRegistry->m_mutex );
+ if ( !m_key.isValid() )
+ {
+ throw InvalidRegistryException();
+ } else
+ {
+ RegError ret = REG_NO_ERROR;
+
+ if ( ret = m_key.getResolvedKeyName(aKeyName, sal_True, resolvedName) )
+ {
+ throw InvalidRegistryException();
+ }
+ }
+
+ return resolvedName;
+}
+
+//*************************************************************************
+SimpleRegistryImpl::SimpleRegistryImpl( const Reference<XMultiServiceFactory> & rXSMgr,
+ const Registry& rRegistry )
+ : m_xSMgr(rXSMgr)
+ , m_registry(rRegistry)
+{
+}
+
+//*************************************************************************
+SimpleRegistryImpl::~SimpleRegistryImpl()
+{
+}
+
+//*************************************************************************
+OUString SAL_CALL SimpleRegistryImpl::getImplementationName( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL SimpleRegistryImpl::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL SimpleRegistryImpl::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL SimpleRegistryImpl::getSupportedServiceNames_Static( )
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//*************************************************************************
+OUString SAL_CALL SimpleRegistryImpl::getURL() throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return m_url;
+}
+
+//*************************************************************************
+void SAL_CALL SimpleRegistryImpl::open( const OUString& rURL, sal_Bool bReadOnly, sal_Bool bCreate )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ if ( m_registry.isValid() )
+ {
+ m_registry.close();
+ }
+
+ RegAccessMode accessMode = REG_READWRITE;
+
+ if ( bReadOnly )
+ accessMode = REG_READONLY;
+
+ if ( !m_registry.open(rURL, accessMode) )
+ return;
+
+ if ( bCreate )
+ {
+ if ( !m_registry.create(rURL) )
+ return;
+ }
+
+ throw InvalidRegistryException();
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL SimpleRegistryImpl::isValid( ) throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return m_registry.isValid();
+}
+
+//*************************************************************************
+void SAL_CALL SimpleRegistryImpl::close( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ if ( m_registry.isValid() )
+ {
+ if ( !m_registry.close() )
+ return;
+ }
+
+ throw InvalidRegistryException();
+}
+
+//*************************************************************************
+void SAL_CALL SimpleRegistryImpl::destroy( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ if ( m_registry.isValid() )
+ {
+ if ( !m_registry.destroy(OUString()) )
+ return;
+ }
+
+ throw InvalidRegistryException();
+}
+
+//*************************************************************************
+Reference< XRegistryKey > SAL_CALL SimpleRegistryImpl::getRootKey( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ if ( m_registry.isValid() )
+ return ((XRegistryKey*)new RegistryKeyImpl(OUString( RTL_CONSTASCII_USTRINGPARAM("/") ), this));
+ else
+ throw InvalidRegistryException();
+
+ return Reference< XRegistryKey >();
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL SimpleRegistryImpl::isReadOnly( )
+ throw(InvalidRegistryException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ if ( m_registry.isValid() )
+ return m_registry.isReadOnly();
+ else
+ throw InvalidRegistryException();
+
+ return sal_False;
+}
+
+//*************************************************************************
+void SAL_CALL SimpleRegistryImpl::mergeKey( const OUString& aKeyName, const OUString& aUrl )
+ throw(InvalidRegistryException, MergeConflictException, RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ if ( m_registry.isValid() )
+ {
+ RegistryKey rootKey;
+ if ( !m_registry.openRootKey(rootKey) )
+ {
+ RegError ret;
+ if (ret = m_registry.mergeKey(rootKey, aKeyName, aUrl, sal_False, sal_False))
+ {
+ if ( ret == REG_MERGE_ERROR )
+ throw MergeConflictException();
+ else
+ throw InvalidRegistryException();
+ }
+
+ return;
+ }
+ }
+
+ throw InvalidRegistryException();
+}
+
+//*************************************************************************
+Reference<XInterface> SAL_CALL SimpleRegistry_CreateInstance( const Reference<XMultiServiceFactory>& rSMgr )
+{
+ Reference<XInterface> xRet;
+ RegistryLoader aLoader;
+
+ if ( aLoader.isLoaded() )
+ {
+ Registry reg(aLoader);
+
+ XSimpleRegistry *pRegistry = (XSimpleRegistry*) new SimpleRegistryImpl(rSMgr, reg);
+
+ if (pRegistry)
+ {
+ xRet = Reference<XInterface>::query(pRegistry);
+ }
+ }
+
+ return xRet;
+}
+
+}
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL =
+ ::stoc_simreg::SimpleRegistryImpl::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
+ ::stoc_simreg::SimpleRegistry_CreateInstance,
+ ::stoc_simreg::SimpleRegistryImpl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
+
diff --git a/stoc/source/tdmanager/lrucache.hxx b/stoc/source/tdmanager/lrucache.hxx
new file mode 100644
index 000000000000..6616916e0deb
--- /dev/null
+++ b/stoc/source/tdmanager/lrucache.hxx
@@ -0,0 +1,282 @@
+/*************************************************************************
+ *
+ * $RCSfile: lrucache.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _LRU_CACHE_HXX_
+#define _LRU_CACHE_HXX_
+
+// __CACHE_DIAGNOSE forces cache size to 4 and works only for OUString keys
+// #define __CACHE_DIAGNOSE 1
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+#include <stl/hash_map>
+
+
+/** Implementation of a least recently used (lru) cache.
+ <br>
+ @author Daniel Boelzle
+*/
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+class LRU_Cache
+{
+ struct CacheEntry
+ {
+ t_Key aKey;
+ t_Val aVal;
+ CacheEntry * pPred;
+ CacheEntry * pSucc;
+ };
+ typedef ::std::hash_map< t_Key, CacheEntry *, t_KeyHash, t_KeyEqual > t_Key2Element;
+
+ mutable ::osl::Mutex _aCacheMutex;
+ sal_Int32 _nCachedElements;
+ t_Key2Element _aKey2Element;
+
+ CacheEntry * _pBlock;
+ mutable CacheEntry * _pHead;
+ mutable CacheEntry * _pTail;
+ inline void toFront( CacheEntry * pEntry ) const;
+
+public:
+ /** Constructor:
+ <br>
+ @param nCachedElements number of elements to be cached; default param set to 128
+ */
+ inline LRU_Cache( sal_Int32 nCachedElements = 128 );
+ /** Destructor: releases all cached elements and keys.
+ <br>
+ */
+ inline ~LRU_Cache();
+
+ /** Retrieves a value from the cache. Returns default constructed value,
+ if none was found.
+ <br>
+ @param rKey a key
+ @return value
+ */
+ inline t_Val getValue( const t_Key & rKey ) const;
+ /** Sets a value to be cached for given key.
+ <br>
+ @param rKey a key
+ @param rValue a value
+ */
+ inline void setValue( const t_Key & rKey, const t_Val & rValue );
+ /** Tests whether a value is cached for given key.
+ <br>
+ @param rKey a key
+ @return true, if value is cached
+ */
+ inline sal_Bool hasValue( const t_Key & rKey ) const;
+ /** Clears the cache, thus releasing all cached elements and keys.
+ <br>
+ */
+ inline void clear();
+};
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::LRU_Cache( sal_Int32 nCachedElements )
+#ifdef __CACHE_DIAGNOSE
+ : _nCachedElements( 4 )
+#else
+ : _nCachedElements( nCachedElements )
+#endif
+ , _pBlock( 0 )
+{
+ if (_nCachedElements > 0)
+ {
+ _pBlock = new CacheEntry[_nCachedElements];
+ _pHead = _pBlock;
+ _pTail = _pBlock + _nCachedElements -1;
+ for ( sal_Int32 nPos = _nCachedElements; nPos--; )
+ {
+ _pBlock[nPos].pPred = _pBlock + nPos -1;
+ _pBlock[nPos].pSucc = _pBlock + nPos +1;
+ }
+ }
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::~LRU_Cache()
+{
+ delete [] _pBlock;
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::toFront( CacheEntry * pEntry ) const
+{
+ if (pEntry != _pHead)
+ {
+ // cut out element
+ if (pEntry == _pTail)
+ {
+ _pTail = pEntry->pPred;
+ }
+ else
+ {
+ pEntry->pSucc->pPred = pEntry->pPred;
+ pEntry->pPred->pSucc = pEntry->pSucc;
+ }
+ // push to front
+ _pHead->pPred = pEntry;
+ pEntry->pSucc = _pHead;
+ _pHead = pEntry;
+ }
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline sal_Bool LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::hasValue( const t_Key & rKey ) const
+{
+ ::osl::MutexGuard aGuard( _aCacheMutex );
+ const t_Key2Element::const_iterator iFind( _aKey2Element.find( rKey ) );
+ return (iFind != _aKey2Element.end());
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline t_Val LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::getValue( const t_Key & rKey ) const
+{
+ ::osl::MutexGuard aGuard( _aCacheMutex );
+ const t_Key2Element::const_iterator iFind( _aKey2Element.find( rKey ) );
+ if (iFind != _aKey2Element.end())
+ {
+ CacheEntry * pEntry = (*iFind).second;
+ toFront( pEntry );
+#ifdef __CACHE_DIAGNOSE
+ OSL_TRACE( "> retrieved element \"" );
+ OSL_TRACE( ::rtl::OUStringToOString( pEntry->aKey, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ OSL_TRACE( "\" from cache <\n" );
+#endif
+ return pEntry->aVal;
+ }
+ return t_Val();
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::setValue(
+ const t_Key & rKey, const t_Val & rValue )
+{
+ if (_nCachedElements > 0)
+ {
+ ::osl::MutexGuard aGuard( _aCacheMutex );
+ const t_Key2Element::const_iterator iFind( _aKey2Element.find( rKey ) );
+
+ CacheEntry * pEntry;
+ if (iFind == _aKey2Element.end())
+ {
+ pEntry = _pTail; // erase last element
+#ifdef __CACHE_DIAGNOSE
+ if (pEntry->aKey.getLength())
+ {
+ OSL_TRACE( "> kicking element \"" );
+ OSL_TRACE( ::rtl::OUStringToOString( pEntry->aKey, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ OSL_TRACE( "\" from cache <\n" );
+ }
+#endif
+ _aKey2Element.erase( pEntry->aKey );
+ _aKey2Element[ pEntry->aKey = rKey ] = pEntry;
+ }
+ else
+ {
+ pEntry = (*iFind).second;
+#ifdef __CACHE_DIAGNOSE
+ OSL_TRACE( "> replacing element \"" );
+ OSL_TRACE( ::rtl::OUStringToOString( pEntry->aKey, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ OSL_TRACE( "\" in cache <\n" );
+#endif
+ }
+ pEntry->aVal = rValue;
+ toFront( pEntry );
+ }
+}
+//__________________________________________________________________________________________________
+template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual >
+inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::clear()
+{
+ ::osl::MutexGuard aGuard( _aCacheMutex );
+ _aKey2Element.clear();
+ for ( sal_Int32 nPos = _nCachedElements; nPos--; )
+ {
+ _pBlock[nPos].aKey = t_Key();
+ _pBlock[nPos].aVal = t_Val();
+ }
+#ifdef __CACHE_DIAGNOSE
+ OSL_TRACE( "> cleared cache <\n" );
+#endif
+}
+
+//==================================================================================================
+struct FctHashOUString : public ::std::unary_function< const ::rtl::OUString &, size_t >
+{
+ size_t operator()( const ::rtl::OUString & rKey ) const
+ { return rKey.hashCode(); }
+};
+
+/** Template instance for OUString keys, Any values.<br>
+*/
+typedef LRU_Cache< ::rtl::OUString, ::com::sun::star::uno::Any,
+ FctHashOUString, ::std::equal_to< ::rtl::OUString > >
+ LRU_CacheAnyByOUString;
+
+
+#endif
diff --git a/stoc/source/tdmanager/makefile.mk b/stoc/source/tdmanager/makefile.mk
new file mode 100644
index 000000000000..c56b297b9190
--- /dev/null
+++ b/stoc/source/tdmanager/makefile.mk
@@ -0,0 +1,108 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= tdmgr
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+BOOTSTRAP_SERVICE=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+
+SLOFILES= \
+ $(SLO)$/tdmgr.obj \
+ $(SLO)$/transfer.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/source/tdmanager/tdmgr.cxx b/stoc/source/tdmanager/tdmgr.cxx
new file mode 100644
index 000000000000..482a1b5ca513
--- /dev/null
+++ b/stoc/source/tdmanager/tdmgr.cxx
@@ -0,0 +1,834 @@
+/*************************************************************************
+ *
+ * $RCSfile: tdmgr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+// #define TRACE(x) OSL_TRACE(x)
+#define TRACE(x)
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _CPPUHELPER_COMPONENT_HXX_
+#include <cppuhelper/component.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+
+#include "lrucache.hxx"
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/reflection/XTypeDescription.hpp>
+#include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
+#include <com/sun/star/reflection/XInterfaceTypeDescription.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+#include <stl/algorithm>
+#include <stl/vector>
+
+
+
+using namespace std;
+using namespace cppu;
+using namespace rtl;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::container;
+using namespace com::sun::star::registry;
+
+
+namespace stoc_tdmgr
+{
+
+static const sal_Int32 CACHE_SIZE = 512;
+
+#define SERVICENAME "com.sun.star.reflection.TypeDescriptionManager"
+#define IMPLNAME "com.sun.star.comp.stoc.TypeDescriptionManager"
+
+//--------------------------------------------------------------------------------------------------
+template < class T >
+inline sal_Bool extract( const Any & rAny, Reference< T > & rDest )
+{
+ rDest.clear();
+ if (! (rAny >>= rDest))
+ {
+ if (rAny.getValueTypeClass() == TypeClass_INTERFACE)
+ rDest = Reference< T >::query( *(const Reference< XInterface > *)rAny.getValue() );
+ }
+ return rDest.is();
+}
+//--------------------------------------------------------------------------------------------------
+inline static Sequence< OUString > getSupportedServiceNames()
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+typedef vector< Reference< XHierarchicalNameAccess > > ProviderVector;
+
+class EnumerationImpl;
+class ManagerImpl;
+
+//==================================================================================================
+class EventListenerImpl : public ImplHelper1< XEventListener >
+{
+ ManagerImpl * _pMgr;
+
+public:
+ EventListenerImpl( ManagerImpl * pMgr )
+ : _pMgr( pMgr )
+ {}
+
+ // lifetime delegated to manager
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject & rEvt ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class ManagerImpl : public WeakImplHelper3< XServiceInfo, XSet, XHierarchicalNameAccess >
+{
+ friend EnumerationImpl;
+ friend EventListenerImpl;
+
+ Mutex _aComponentMutex;
+ Reference< XMultiServiceFactory > _xSMgr;
+ EventListenerImpl _aEventListener;
+
+ // elements
+ sal_Bool _bCaching;
+ LRU_CacheAnyByOUString _aElements;
+ // provider chain
+ ProviderVector _aProviders;
+ sal_Bool _bProviderInit;
+
+ inline void initProviders();
+ inline Any getSimpleType( const OUString & rName );
+
+public:
+ ManagerImpl( const Reference< XMultiServiceFactory > & xSMgr );
+ virtual ~ManagerImpl();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess
+ virtual Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual Reference< XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException);
+
+ // XSet
+ virtual sal_Bool SAL_CALL has( const Any & rElement ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL insert( const Any & rElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL remove( const Any & rElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+
+ // XHierarchicalNameAccess
+ virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================================================
+class EnumerationImpl
+ : public WeakImplHelper1< XEnumeration >
+{
+ ManagerImpl * _pMgr;
+ sal_Int32 _nPos;
+
+public:
+ EnumerationImpl( ManagerImpl * pManager );
+ virtual ~EnumerationImpl();
+
+ // XEnumeration
+ virtual sal_Bool SAL_CALL hasMoreElements() throw(::com::sun::star::uno::RuntimeException);
+ virtual Any SAL_CALL nextElement() throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+};
+
+//##################################################################################################
+
+// lifetime delegated to manager
+//__________________________________________________________________________________________________
+void EventListenerImpl::acquire() throw()
+{
+ _pMgr->acquire();
+}
+//__________________________________________________________________________________________________
+void EventListenerImpl::release() throw()
+{
+ _pMgr->release();
+}
+
+// XEventListener
+//__________________________________________________________________________________________________
+void EventListenerImpl::disposing( const EventObject & rEvt )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( _pMgr->_aComponentMutex );
+ if (rEvt.Source == _pMgr->_xSMgr)
+ {
+ Reference< XComponent > xComp( _pMgr->_xSMgr, UNO_QUERY );
+ OSL_ENSHURE( xComp.is(), "### service manager must implement XComponent!" );
+ xComp->removeEventListener( this );
+ _pMgr->_bCaching = sal_False;
+ _pMgr->_aElements.clear();
+ _pMgr->_xSMgr.clear();
+ }
+ else
+ {
+ _pMgr->remove( makeAny( rEvt.Source ) );
+ }
+}
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+EnumerationImpl::EnumerationImpl( ManagerImpl * pManager )
+ : _pMgr( pManager )
+ , _nPos( 0 )
+{
+ _pMgr->acquire();
+}
+//__________________________________________________________________________________________________
+EnumerationImpl::~EnumerationImpl()
+{
+ _pMgr->release();
+}
+
+// XEnumeration
+//__________________________________________________________________________________________________
+sal_Bool EnumerationImpl::hasMoreElements()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( _pMgr->_aComponentMutex );
+ return (_nPos < _pMgr->_aProviders.size());
+}
+//__________________________________________________________________________________________________
+Any EnumerationImpl::nextElement()
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( _pMgr->_aComponentMutex );
+ if (_nPos >= _pMgr->_aProviders.size())
+ {
+ throw NoSuchElementException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("there is no further element!") ),
+ (XWeak *)(OWeakObject *)this );
+ }
+ return makeAny( _pMgr->_aProviders[_nPos] );
+}
+
+//##################################################################################################
+
+
+//==================================================================================================
+typelib_TypeDescription * createCTD( const Reference<XTypeDescription > & xType );
+
+//==================================================================================================
+extern "C"
+{
+static void SAL_CALL tdmgr_typelib_callback( void * pContext, typelib_TypeDescription ** ppRet,
+ rtl_uString * pTypeName )
+{
+ OSL_ENSHURE( pContext && ppRet && pTypeName, "### null ptr!" );
+ if (ppRet)
+ {
+ if (*ppRet)
+ {
+ typelib_typedescription_release( *ppRet );
+ *ppRet = 0;
+ }
+ if (pContext && pTypeName)
+ {
+ try
+ {
+ Reference< XTypeDescription > xTD;
+ if (extractInterface(
+ xTD, reinterpret_cast< ManagerImpl * >( pContext )->getByHierarchicalName( pTypeName ) ))
+ {
+ *ppRet = createCTD( xTD );
+ }
+ }
+ catch (...)
+ {
+ }
+ }
+#ifdef DEBUG
+ if (! *ppRet)
+ {
+ OSL_TRACE( "### typelib type not accessable: " );
+ OString aTypeName( OUStringToOString( pTypeName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( aTypeName.getStr() );
+ OSL_TRACE( "\n" );
+ }
+#endif
+ }
+}
+}
+
+//__________________________________________________________________________________________________
+ManagerImpl::ManagerImpl( const Reference< XMultiServiceFactory > & xSMgr )
+ : _xSMgr( xSMgr )
+ , _aEventListener( this )
+ , _bCaching( sal_True )
+ , _aElements( CACHE_SIZE )
+ , _bProviderInit( sal_False )
+{
+ // register c typelib callback
+ typelib_typedescription_registerCallback( this, tdmgr_typelib_callback );
+
+ // listen to service manager vanishing...
+ Reference< XComponent > xComp( _xSMgr, UNO_QUERY );
+ OSL_ENSHURE( xComp.is(), "### service manager must implement XComponent!" );
+ xComp->addEventListener( &_aEventListener );
+}
+//__________________________________________________________________________________________________
+ManagerImpl::~ManagerImpl()
+{
+ OSL_ENSHURE( _aProviders.size() == 0, "### still providers left!" );
+ TRACE( "> TypeDescriptionManager shut down. <\n" );
+ MutexGuard aGuard( _aComponentMutex );
+
+ // deregister of c typelib callback
+ typelib_typedescription_revokeCallback( this, tdmgr_typelib_callback );
+}
+//__________________________________________________________________________________________________
+inline void ManagerImpl::initProviders()
+{
+ // looking up service manager for all known provider implementations
+ Reference< XContentEnumerationAccess > xEnumAccess( _xSMgr, UNO_QUERY );
+ OSL_ENSHURE( xEnumAccess.is(), "### service manager must export XContentEnumerationAccess!" );
+
+ Reference< XEnumeration > xEnum( xEnumAccess->createContentEnumeration(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.TypeDescriptionProvider") ) ) );
+ OSL_ENSHURE( xEnum.is(), "### no TypeDescriptionProviders available!" );
+ if (xEnum.is())
+ {
+ while (xEnum->hasMoreElements())
+ {
+ Any aAny( xEnum->nextElement() );
+ if (aAny.getValueTypeClass() == TypeClass_INTERFACE)
+ {
+ Reference< XServiceInfo > xInfo(
+ *(const Reference< XInterface > *)aAny.getValue(), UNO_QUERY );
+ if (xInfo.is() &&
+ !xInfo->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(IMPLNAME) )) // no self insertion
+ {
+ Reference< XSingleServiceFactory > xFactory(
+ *(const Reference< XInterface > *)aAny.getValue(), UNO_QUERY );
+ OSL_ENSHURE( xFactory.is(), "### the thing that should not be!" );
+
+ Reference< XHierarchicalNameAccess > xHA( xFactory->createInstance(), UNO_QUERY );
+ if (xHA.is())
+ {
+ try
+ {
+ insert( makeAny( xHA ) );
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+ catch (ElementExistException &)
+ {
+ }
+ }
+ }
+ }
+ }
+ }
+ OSL_ENSHURE( !_aProviders.empty(), "### no typedescription providers found!" );
+}
+
+// XServiceInfo
+//__________________________________________________________________________________________________
+OUString ManagerImpl::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
+}
+//__________________________________________________________________________________________________
+sal_Bool ManagerImpl::supportsService( const OUString & rServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ {
+ if (pArray[nPos] == rServiceName)
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > ManagerImpl::getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return stoc_tdmgr::getSupportedServiceNames();
+}
+
+// XElementAccess
+//__________________________________________________________________________________________________
+Type ManagerImpl::getElementType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::getCppuType( (const Reference< XHierarchicalNameAccess > *)0 );
+}
+//__________________________________________________________________________________________________
+sal_Bool ManagerImpl::hasElements()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard( _aComponentMutex );
+ return (_aProviders.size() > 0);
+}
+
+// XEnumerationAccess
+//__________________________________________________________________________________________________
+Reference< XEnumeration > ManagerImpl::createEnumeration()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return new EnumerationImpl( this );
+}
+
+// XSet
+//__________________________________________________________________________________________________
+sal_Bool SAL_CALL ManagerImpl::has( const Any & rElement )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Reference< XHierarchicalNameAccess > xElem;
+ if (extract( rElement, xElem ))
+ {
+ MutexGuard aGuard( _aComponentMutex );
+ return (find( _aProviders.begin(), _aProviders.end(), xElem ) != _aProviders.end());
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+void SAL_CALL ManagerImpl::insert( const Any & rElement )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException)
+{
+ Reference< XHierarchicalNameAccess > xElem;
+ if (! extract( rElement, xElem ))
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no type description provider given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ }
+
+ MutexGuard aGuard( _aComponentMutex );
+ if (find( _aProviders.begin(), _aProviders.end(), xElem ) != _aProviders.end())
+ {
+ throw ElementExistException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("provider already inserted!") ),
+ (XWeak *)(OWeakObject *)this );
+ }
+ _aProviders.push_back( xElem );
+ Reference< XComponent > xComp( xElem, UNO_QUERY );
+ if (xComp.is())
+ xComp->addEventListener( &_aEventListener );
+}
+//__________________________________________________________________________________________________
+void SAL_CALL ManagerImpl::remove( const Any & rElement )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException)
+{
+ Reference< XHierarchicalNameAccess > xElem;
+ if (! extract( rElement, xElem ))
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no type description provider given!") ),
+ (XWeak *)(OWeakObject *)this, 0 );
+ }
+
+ MutexGuard aGuard( _aComponentMutex );
+ ProviderVector::iterator iFind( find( _aProviders.begin(), _aProviders.end(), xElem ) );
+ if (iFind == _aProviders.end())
+ {
+ throw NoSuchElementException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("provider not found!") ),
+ (XWeak *)(OWeakObject *)this );
+ }
+ _aProviders.erase( iFind );
+ Reference< XComponent > xComp( xElem, UNO_QUERY );
+ if (xComp.is())
+ xComp->removeEventListener( &_aEventListener );
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//==================================================================================================
+class SimpleTypeDescriptionImpl : public WeakImplHelper1< XTypeDescription >
+{
+ TypeClass _eTC;
+ OUString _aName;
+
+public:
+ SimpleTypeDescriptionImpl( TypeClass eTC, const OUString & rName )
+ : _eTC( eTC )
+ , _aName( rName )
+ {}
+
+ // XTypeDescription
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+};
+
+// XTypeDescription
+//__________________________________________________________________________________________________
+TypeClass SimpleTypeDescriptionImpl::getTypeClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _eTC;
+}
+//__________________________________________________________________________________________________
+OUString SimpleTypeDescriptionImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _aName;
+}
+
+//==================================================================================================
+class SequenceTypeDescriptionImpl : public WeakImplHelper1< XIndirectTypeDescription >
+{
+ Reference< XTypeDescription > _xElementTD;
+
+public:
+ SequenceTypeDescriptionImpl( const Reference< XTypeDescription > & xElementTD )
+ : _xElementTD( xElementTD )
+ {}
+
+ // XTypeDescription
+ virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
+ virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+
+ // XIndirectTypeDescription
+ virtual Reference< XTypeDescription > SAL_CALL getReferencedType() throw(::com::sun::star::uno::RuntimeException);
+};
+
+// XTypeDescription
+//__________________________________________________________________________________________________
+TypeClass SequenceTypeDescriptionImpl::getTypeClass()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return TypeClass_SEQUENCE;
+}
+//__________________________________________________________________________________________________
+OUString SequenceTypeDescriptionImpl::getName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (OUString( RTL_CONSTASCII_USTRINGPARAM("[]") ) + _xElementTD->getName());
+}
+
+// XIndirectTypeDescription
+//__________________________________________________________________________________________________
+Reference< XTypeDescription > SequenceTypeDescriptionImpl::getReferencedType()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return _xElementTD;
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+//__________________________________________________________________________________________________
+inline Any ManagerImpl::getSimpleType( const OUString & rName )
+{
+ Any aRet;
+
+ if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("string") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_STRING, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("long") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_LONG, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("unsigned long") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_UNSIGNED_LONG, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boolean") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_BOOLEAN, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("char") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_CHAR, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("byte") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_BYTE, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_SHORT, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("unsigned short") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_UNSIGNED_SHORT, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("hyper") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_HYPER, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("unsigned hyper") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_UNSIGNED_HYPER, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("float") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_FLOAT, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_DOUBLE, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("any") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_ANY, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("void") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_VOID, rName ) );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("type") ))
+ aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_TYPE, rName ) );
+
+ return aRet;
+}
+
+// XHierarchicalNameAccess
+//__________________________________________________________________________________________________
+Any ManagerImpl::getByHierarchicalName( const OUString & rName )
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException)
+{
+ Any aRet;
+ if (_bCaching)
+ _aElements.getValue( rName );
+ if (rName.getLength() && !aRet.hasValue())
+ {
+ sal_Int32 nIndex;
+ if (rName[0] == '[') // test for sequence
+ {
+ Reference< XTypeDescription > xElemType;
+ if (extract( getByHierarchicalName( rName.copy( 2 ) ), xElemType ))
+ aRet <<= Reference< XTypeDescription >( new SequenceTypeDescriptionImpl( xElemType ) );
+ else
+ return Any(); // further lookup makes no sense
+ }
+ else if ((nIndex = rName.indexOf( ':' )) >= 0) // test for interface member names
+ {
+ Reference< XInterfaceTypeDescription > xIfaceTD;
+ if (extract( getByHierarchicalName( rName.copy( 0, nIndex ) ), xIfaceTD ))
+ {
+ const Sequence< Reference< XInterfaceMemberTypeDescription > > & rMembers =
+ xIfaceTD->getMembers();
+ const Reference< XInterfaceMemberTypeDescription > * pMembers =
+ rMembers.getConstArray();
+
+ for ( sal_Int32 nPos = rMembers.getLength(); nPos--; )
+ {
+ if (rName == pMembers[nPos]->getName())
+ {
+ aRet <<= Reference< XTypeDescription >::query( pMembers[nPos] );
+ break;
+ }
+ }
+ if (! aRet.hasValue())
+ return Any(); // further lookup makes no sense
+ }
+ }
+ else if (rName.indexOf( '.' ) < 0) // test for simple/ build in types
+ {
+ aRet = getSimpleType( rName );
+ }
+
+ if (! aRet.hasValue())
+ {
+ // last, try callback chain
+ MutexGuard aGuard( _aComponentMutex );
+ if (! _bProviderInit)
+ {
+ initProviders();
+ _bProviderInit = sal_True;
+ }
+ for ( ProviderVector::const_iterator iPos( _aProviders.begin() );
+ iPos != _aProviders.end(); ++iPos )
+ {
+ try
+ {
+ if ((aRet = (*iPos)->getByHierarchicalName( rName )).hasValue())
+ break;
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ }
+ }
+
+ // update cache
+ if (_bCaching && aRet.hasValue())
+ _aElements.setValue( rName, aRet );
+ }
+
+ if (! aRet.hasValue())
+ {
+ NoSuchElementException aExc;
+ aExc.Message = rName;
+ throw aExc;
+ }
+ return aRet;
+}
+//__________________________________________________________________________________________________
+sal_Bool ManagerImpl::hasByHierarchicalName( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ try
+ {
+ return getByHierarchicalName( rName ).hasValue();
+ }
+ catch (NoSuchElementException &)
+ {
+ }
+ return sal_False;
+}
+
+//==================================================================================================
+static Reference< XInterface > SAL_CALL ManagerImpl_create( const Reference< XMultiServiceFactory > & xSMgr )
+ throw(::com::sun::star::uno::Exception)
+{
+ return Reference< XInterface >( *new ManagerImpl( xSMgr ) );
+}
+
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL = stoc_tdmgr::getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
+ stoc_tdmgr::ManagerImpl_create,
+ stoc_tdmgr::getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
diff --git a/stoc/source/typeconv/convert.cxx b/stoc/source/typeconv/convert.cxx
new file mode 100644
index 000000000000..b8add2091be1
--- /dev/null
+++ b/stoc/source/typeconv/convert.cxx
@@ -0,0 +1,907 @@
+/*************************************************************************
+ *
+ * $RCSfile: convert.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <osl/diagnose.h>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+#include <typelib/typedescription.hxx>
+#include <uno/data.h>
+
+#ifdef WNT
+#include <cmath>
+#else
+#include <math.h>
+#endif
+#include <float.h>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/script/FailReason.hpp>
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::script;
+using namespace com::sun::star::registry;
+using namespace cppu;
+using namespace rtl;
+
+#define SERVICENAME "com.sun.star.script.Converter"
+#define IMPLNAME "com.sun.star.comp.stoc.TypeConverter"
+
+namespace stoc_tcv
+{
+
+const double MIN_DOUBLE = -DBL_MAX;
+const double MAX_DOUBLE = DBL_MAX;
+const double MIN_FLOAT = -FLT_MAX;
+const double MAX_FLOAT = FLT_MAX;
+
+//--------------------------------------------------------------------------------------------------
+static inline double round( double aVal )
+{
+ sal_Bool bPos = (aVal >= 0.0); //
+ aVal = ::fabs( aVal );
+ double aUpper = ::ceil( aVal );
+
+ aVal = ((aUpper-aVal) <= 0.5) ? aUpper : (aUpper - 1.0);
+ return (bPos ? aVal : -aVal);
+}
+
+//--------------------------------------------------------------------------------------------------
+static sal_Bool getNumericValue( double & rfVal, const OUString & rStr )
+{
+ double fRet = rStr.toDouble();
+ if (fRet == 0.0)
+ {
+ sal_Int32 nLen = rStr.getLength();
+ if (!nLen || (nLen == 1 && rStr[0] == '0')) // common case
+ {
+ rfVal = 0.0;
+ return sal_True;
+ }
+
+ OUString trim( rStr.trim() );
+
+ // try hex
+ sal_Int32 nX = trim.indexOf( 'x' );
+ if (nX < 0)
+ nX = trim.indexOf( 'X' );
+
+ if (nX > 0 && trim[nX-1] == '0') // 0x
+ {
+ sal_Bool bNeg = sal_False;
+ switch (nX)
+ {
+ case 2: // (+|-)0x...
+ if (trim[0] == '-')
+ bNeg = sal_True;
+ else if (trim[0] != '+')
+ return sal_False;
+ case 1: // 0x...
+ break;
+ default:
+ return sal_False;
+ }
+
+ OUString aHexRest( trim.copy( nX+1 ) );
+ sal_Int64 nRet = aHexRest.toInt64( 16 );
+
+ if (nRet == 0)
+ {
+ for ( sal_Int32 nPos = aHexRest.getLength(); nPos--; )
+ {
+ if (aHexRest[nPos] != '0')
+ return sal_False;
+ }
+ }
+
+ rfVal = (bNeg ? -nRet : nRet);
+ return sal_True;
+ }
+
+ nLen = trim.getLength();
+ sal_Int32 nPos = 0;
+
+ // skip +/-
+ if (nLen && (trim[0] == '-' || trim[0] == '+'))
+ ++nPos;
+
+ while (nPos < nLen) // skip leading zeros
+ {
+ if (trim[nPos] != '0')
+ {
+ if (trim[nPos] != '.')
+ return sal_False;
+ ++nPos;
+ while (nPos < nLen) // skip trailing zeros
+ {
+ if (trim[nPos] != '0')
+ return sal_False;
+ ++nPos;
+ }
+ break;
+ }
+ ++nPos;
+ }
+ }
+ rfVal = fRet;
+ return sal_True;
+}
+
+//==================================================================================================
+class TypeConverter_Impl : public WeakImplHelper2< XTypeConverter, XServiceInfo >
+{
+ // ...misc helpers...
+ sal_Int64 toHyper( const Any& rAny, sal_Int64 min = 0x8000000000000000, sal_uInt64 max = 0xffffffffffffffff )
+ throw( CannotConvertException );
+ double toDouble( const Any& rAny, double min = MIN_DOUBLE, double max = MAX_DOUBLE ) const
+ throw( CannotConvertException );
+
+public:
+ static OUString getImplementationName_Static(void);
+ static Sequence< OUString > getSupportedServiceNames_Static(void) throw( RuntimeException );
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw( RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException );
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( RuntimeException );
+
+ // XTypeConverter
+ virtual Any SAL_CALL convertTo( const Any& aFrom, const Type& DestinationType ) throw( IllegalArgumentException, CannotConvertException, RuntimeException);
+ virtual Any SAL_CALL convertToSimpleType( const Any& aFrom, TypeClass aDestinationType ) throw( IllegalArgumentException, CannotConvertException, RuntimeException);
+};
+
+// XServiceInfo
+OUString TypeConverter_Impl::getImplementationName() throw( RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+// XServiceInfo Helper
+OUString TypeConverter_Impl::getImplementationName_Static(void)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
+}
+
+// XServiceInfo
+sal_Bool TypeConverter_Impl::supportsService(const OUString& ServiceName) throw( RuntimeException )
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+// XServiceInfo
+Sequence< OUString > TypeConverter_Impl::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+// ORegistryServiceManager_Static
+Sequence< OUString > TypeConverter_Impl::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME ) );
+ return aSNS;
+}
+
+//--------------------------------------------------------------------------------------------------
+sal_Int64 TypeConverter_Impl::toHyper( const Any& rAny, sal_Int64 min, sal_uInt64 max )
+ throw( CannotConvertException )
+{
+ sal_Int64 nRet;
+ TypeClass aDestinationClass = rAny.getValueTypeClass();
+
+ switch (aDestinationClass)
+ {
+ // ANY
+// case TypeClass_ANY: // any sollte schon vorher entschachtelt sein...
+// break;
+ // ENUM
+ case TypeClass_ENUM:
+ nRet = *(int *)rAny.getValue();
+ break;
+ // BOOL
+ case TypeClass_BOOLEAN:
+ nRet = (*(sal_Bool*)rAny.getValue() ? 1 : 0);
+ break;
+ // CHAR, BYTE
+ case TypeClass_CHAR:
+ nRet = *(sal_Unicode *)rAny.getValue();
+ break;
+ case TypeClass_BYTE:
+ nRet = *(sal_Int8 *)rAny.getValue();
+ break;
+ // SHORT
+ case TypeClass_SHORT:
+ nRet = *(sal_Int16 *)rAny.getValue();
+ break;
+ // UNSIGNED SHORT
+ case TypeClass_UNSIGNED_SHORT:
+ nRet = *(sal_uInt16 *)rAny.getValue();
+ break;
+ // LONG
+ case TypeClass_LONG:
+ nRet = *(sal_Int32 *)rAny.getValue();
+ break;
+ // UNSIGNED LONG
+ case TypeClass_UNSIGNED_LONG:
+ nRet = *(sal_uInt32 *)rAny.getValue();
+ break;
+ // HYPER
+ case TypeClass_HYPER:
+ nRet = *(sal_Int64 *)rAny.getValue();
+ break;
+ // UNSIGNED HYPER
+ case TypeClass_UNSIGNED_HYPER:
+ {
+ nRet = *(sal_Int64 *)rAny.getValue();
+ if ((min < 0 || (sal_uInt64)nRet >= (sal_uInt64)min) && // lower bound
+ (sal_uInt64)nRet <= max) // upper bound
+ {
+ return nRet;
+ }
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("UNSIGNED HYPER out of range!") ),
+ Reference<XInterface>(), aDestinationClass, FailReason::OUT_OF_RANGE, 0 );
+ }
+
+ // FLOAT, DOUBLE
+ case TypeClass_FLOAT:
+ {
+ double fVal = round( *(float *)rAny.getValue() );
+ // implementationsabh. cast von unsigned nach signed!
+#ifdef SAL_W32 // conversion from unsigned __int64 to double not impl
+ nRet = (fVal > 0x7fffffffffffffff ? (__int64)fVal : (sal_Int64)fVal);
+ if (fVal >= min && fVal <= (__int64)(max & 0x7fffffffffffffff))
+#else
+ nRet = (fVal > 0x7fffffffffffffff ? (sal_uInt64)fVal : (sal_Int64)fVal);
+ if (fVal >= min && fVal <= max)
+#endif
+ {
+ return nRet;
+ }
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("FLOAT out of range!") ),
+ Reference<XInterface>(), aDestinationClass, FailReason::OUT_OF_RANGE, 0 );
+ }
+ case TypeClass_DOUBLE:
+ {
+ double fVal = round( *(double *)rAny.getValue() );
+ // implementationsabh. cast von unsigned nach signed!
+#ifdef SAL_W32 // conversion from unsigned __int64 to double not impl
+ nRet = (fVal > 0x7fffffffffffffff ? (__int64)fVal : (sal_Int64)fVal);
+ if (fVal >= min && fVal <= (__int64)(max & 0x7fffffffffffffff))
+#else
+ nRet = (fVal > 0x7fffffffffffffff ? (sal_uInt64)fVal : (sal_Int64)fVal);
+ if (fVal >= min && fVal <= max)
+#endif
+ {
+ return nRet;
+ }
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("DOUBLE out of range!") ),
+ Reference<XInterface>(), aDestinationClass, FailReason::OUT_OF_RANGE, 0 );
+ }
+
+ // STRING
+ case TypeClass_STRING:
+ {
+ double fVal;
+ if (! getNumericValue( fVal, *(OUString *)rAny.getValue() ))
+ {
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid STRING value!") ),
+ Reference<XInterface>(), aDestinationClass, FailReason::IS_NOT_NUMBER, 0 );
+ }
+ else
+ {
+ // implementationsabh. cast von unsigned nach signed!
+ nRet = (fVal > 0x7fffffffffffffff ? (sal_uInt64)fVal : (sal_Int64)fVal);
+#ifdef SAL_W32 // conversion from unsigned __int64 to double not impl
+ if (fVal >= min && fVal <= (__int64)(max & 0x7fffffffffffffff))
+#else
+ if (fVal >= min && fVal <= max)
+#endif
+ return nRet;
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("STRING value out of range!") ),
+ Reference<XInterface>(), aDestinationClass, FailReason::OUT_OF_RANGE, 0 );
+ }
+ }
+
+ default:
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("TYPE is not supported!") ),
+ Reference<XInterface>(), aDestinationClass, FailReason::TYPE_NOT_SUPPORTED, 0 );
+ }
+
+ if (nRet >= min && (nRet < 0 || (sal_uInt64)nRet <= max))
+ return nRet;
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("VALUE is out of range!") ),
+ Reference<XInterface>(), aDestinationClass, FailReason::OUT_OF_RANGE, 0 );
+ return 0; // dummy
+}
+
+//--------------------------------------------------------------------------------------------------
+double TypeConverter_Impl::toDouble( const Any& rAny, double min, double max ) const
+ throw( CannotConvertException )
+{
+ double fRet;
+ TypeClass aDestinationClass = rAny.getValueTypeClass();
+
+ switch (aDestinationClass)
+ {
+ // ANY
+// case TypeClass_ANY: // any sollte schon vorher entschachtelt sein...
+// break;
+ // ENUM
+ case TypeClass_ENUM:
+ fRet = *(int *)rAny.getValue();
+ break;
+ // BOOL
+ case TypeClass_BOOLEAN:
+ fRet = (*(sal_Bool*)rAny.getValue() ? 1.0 : 0.0);
+ break;
+ // CHAR, BYTE
+ case TypeClass_CHAR:
+ fRet = *(sal_Unicode *)rAny.getValue();
+ break;
+ case TypeClass_BYTE:
+ fRet = *(sal_Int8 *)rAny.getValue();
+ break;
+ // SHORT
+ case TypeClass_SHORT:
+ fRet = *(sal_Int16 *)rAny.getValue();
+ break;
+ // UNSIGNED SHORT
+ case TypeClass_UNSIGNED_SHORT:
+ fRet = *(sal_uInt16 *)rAny.getValue();
+ break;
+ // LONG
+ case TypeClass_LONG:
+ fRet = *(sal_Int32 *)rAny.getValue();
+ break;
+ // UNSIGNED LONG
+ case TypeClass_UNSIGNED_LONG:
+ fRet = *(sal_uInt32 *)rAny.getValue();
+ break;
+ // HYPER
+ case TypeClass_HYPER:
+ fRet = *(sal_Int64 *)rAny.getValue();
+ break;
+ // UNSIGNED HYPER
+ case TypeClass_UNSIGNED_HYPER:
+#ifdef SAL_W32
+ fRet = *(__int64 *)rAny.getValue();
+#else
+ fRet = *(sal_uInt64 *)rAny.getValue();
+#endif
+ break;
+ // FLOAT, DOUBLE
+ case TypeClass_FLOAT:
+ fRet = *(float *)rAny.getValue();
+ break;
+ case TypeClass_DOUBLE:
+ fRet = *(double *)rAny.getValue();
+ break;
+
+ // STRING
+ case TypeClass_STRING:
+ {
+ if (! getNumericValue( fRet, *(OUString *)rAny.getValue() ))
+ {
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid STRING value!") ),
+ Reference<XInterface>(), aDestinationClass, FailReason::IS_NOT_NUMBER, 0 );
+ }
+ break;
+ }
+
+ default:
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("TYPE is not supported!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::TYPE_NOT_SUPPORTED, 0 );
+ }
+
+ if (fRet >= min && fRet <= max)
+ return fRet;
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("VALUE is out of range!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::OUT_OF_RANGE, 0 );
+ return 0.0; // dummy
+}
+
+//--------------------------------------------------------------------------------------------------
+Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestType )
+ throw( IllegalArgumentException, CannotConvertException, RuntimeException)
+{
+ Type aSourceType = rVal.getValueType();
+ if (aSourceType == aDestType)
+ return rVal;
+
+ TypeClass aSourceClass = aSourceType.getTypeClass();
+ TypeClass aDestinationClass = aDestType.getTypeClass();
+
+ Any aRet;
+
+ // convert to...
+ switch (aDestinationClass)
+ {
+ // --- to VOID ------------------------------------------------------------------------------
+ case TypeClass_VOID:
+ return Any();
+ // --- to ANY -------------------------------------------------------------------------------
+ case TypeClass_ANY:
+ return rVal;
+
+ // --- to STRUCT, UNION, EXCEPTION ----------------------------------------------------------
+ case TypeClass_STRUCT:
+// case TypeClass_UNION: // todo
+ case TypeClass_EXCEPTION:
+ {
+ // same types or destination type is derived source type?
+ TypeDescription aSourceTD( aSourceType );
+ TypeDescription aDestTD( aDestType );
+ if (typelib_typedescription_isAssignableFrom( aDestTD.get(), aSourceTD.get() ))
+ {
+ aRet.setValue( rVal.getValue(), aDestTD.get() ); // evtl. .uP.cAsT.
+ }
+ else
+ {
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value is not of same or derived type!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::SOURCE_IS_NO_DERIVED_TYPE, 0 );
+ }
+ break;
+ }
+ // --- to INTERFACE -------------------------------------------------------------------------
+ case TypeClass_INTERFACE:
+ {
+ if (rVal.getValueTypeClass() != TypeClass_INTERFACE ||
+ !*(XInterface * const *)rVal.getValue())
+ {
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value is no interface!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::NO_SUCH_INTERFACE, 0 );
+ }
+ if (! (aRet = (*(XInterface * const *)rVal.getValue())->queryInterface( aDestType )).hasValue())
+ {
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value has no such interface!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::NO_SUCH_INTERFACE, 0 );
+ }
+ break;
+ }
+ // --- to SEQUENCE --------------------------------------------------------------------------
+ case TypeClass_SEQUENCE:
+ {
+ if (aSourceClass==TypeClass_SEQUENCE)
+ {
+ // wenn beide Sequences vom gleichen Typ sind
+ if( aSourceType == aDestType )
+ return rVal;
+
+ TypeDescription aSourceTD( aSourceType );
+ TypeDescription aDestTD( aDestType );
+ typelib_TypeDescription * pSourceElementTD = 0;
+ TYPELIB_DANGER_GET( &pSourceElementTD, ((typelib_IndirectTypeDescription *)aSourceTD.get())->pType );
+ typelib_TypeDescription * pDestElementTD = 0;
+ TYPELIB_DANGER_GET( &pDestElementTD, ((typelib_IndirectTypeDescription *)aDestTD.get())->pType );
+
+ sal_uInt32 nPos = (*(const uno_Sequence * const *)rVal.getValue())->nElements;
+ uno_Sequence * pRet = 0;
+ uno_sequence_construct( &pRet, aDestTD.get(), 0, nPos, cpp_acquire );
+ aRet.setValue( &pRet, aDestTD.get() );
+ uno_destructData( &pRet, aDestTD.get(), cpp_release ); // decr ref count
+
+ char * pDestElements = (*(uno_Sequence * const *)aRet.getValue())->elements;
+ const char * pSourceElements = (*(const uno_Sequence * const *)rVal.getValue())->elements;
+
+ while (nPos--)
+ {
+ char * pDestPos = pDestElements + (nPos * pDestElementTD->nSize);
+ const char * pSourcePos = pSourceElements + (nPos * pSourceElementTD->nSize);
+
+ Any aElement( convertTo( Any( pSourcePos, pSourceElementTD ), pDestElementTD->pWeakRef ) );
+
+ sal_Bool bSucc = uno_assignData(
+ pDestPos, pDestElementTD,
+ (pDestElementTD->eTypeClass == typelib_TypeClass_ANY
+ ? &aElement : const_cast< void * >( aElement.getValue() )),
+ pDestElementTD, cpp_queryInterface, cpp_acquire, cpp_release );
+ OSL_ASSERT( bSucc );
+ }
+ TYPELIB_DANGER_RELEASE( pDestElementTD );
+ TYPELIB_DANGER_RELEASE( pSourceElementTD );
+ }
+ }
+ break;
+ // --- to ENUM ------------------------------------------------------------------------------
+ case TypeClass_ENUM:
+ {
+ TypeDescription aEnumTD( aDestType );
+ sal_Int32 nPos = -1;
+
+ if (aSourceClass==TypeClass_STRING)
+ {
+ for ( nPos = ((typelib_EnumTypeDescription *)aEnumTD.get())->nEnumValues; nPos--; )
+ {
+ if (((const OUString *)rVal.getValue())->equalsIgnoreCase( ((typelib_EnumTypeDescription *)aEnumTD.get())->ppEnumNames[nPos] ))
+ break;
+ }
+ }
+ else if (aSourceClass!=TypeClass_ENUM && // exclude some unwanted types for toHyper()
+ aSourceClass!=TypeClass_BOOLEAN &&
+ aSourceClass!=TypeClass_CHAR)
+ {
+ sal_Int32 nEnumValue = toHyper( rVal, 0, 0xffffffff );
+ for ( nPos = ((typelib_EnumTypeDescription *)aEnumTD.get())->nEnumValues; nPos--; )
+ {
+ if (nEnumValue == ((typelib_EnumTypeDescription *)aEnumTD.get())->pEnumValues[nPos])
+ break;
+ }
+ }
+
+ if (nPos >= 0)
+ {
+ aRet.setValue( &((typelib_EnumTypeDescription *)aEnumTD.get())->pEnumValues[nPos], aEnumTD.get() );
+ }
+ else
+ {
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value cannot be converted to demanded ENUM!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::IS_NOT_ENUM, 0 );
+ }
+ break;
+ }
+
+ default:
+ // else simple type conversion possible?
+ try
+ {
+ aRet = convertToSimpleType( rVal, aDestinationClass ); // CannotConvertException darf durchfliegen
+ }
+ catch (IllegalArgumentException &)
+ {
+ // ...FailReason::INVALID fliegt
+ }
+ }
+
+ if (aRet.getValueTypeClass() != TypeClass_VOID)
+ return aRet;
+
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("conversion not possible!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::INVALID, 0 );
+ return Any(); // dummy
+}
+
+//--------------------------------------------------------------------------------------------------
+Any TypeConverter_Impl::convertToSimpleType( const Any& rVal, TypeClass aDestinationClass )
+ throw( IllegalArgumentException, CannotConvertException, RuntimeException )
+{
+ switch (aDestinationClass)
+ {
+ // only simple Conversion of _simple_ types
+ case TypeClass_INTERFACE:
+ case TypeClass_SERVICE:
+ case TypeClass_STRUCT:
+ case TypeClass_TYPEDEF:
+ case TypeClass_UNION:
+ case TypeClass_EXCEPTION:
+ case TypeClass_ARRAY:
+ case TypeClass_SEQUENCE:
+ case TypeClass_ENUM:
+ case TypeClass_UNKNOWN:
+ case TypeClass_MODULE:
+ throw IllegalArgumentException();
+ }
+
+ Type aSourceType = rVal.getValueType();
+ TypeClass aSourceClass = aSourceType.getTypeClass();
+ if (aDestinationClass == aSourceClass)
+ return rVal;
+
+ Any aRet;
+
+ // Convert to...
+ switch (aDestinationClass)
+ {
+ // --- to VOID ------------------------------------------------------------------------------
+ case TypeClass_VOID:
+ return Any();
+
+ // --- to ANY -------------------------------------------------------------------------------
+ case TypeClass_ANY:
+ return rVal;
+
+ // --- to BOOL ------------------------------------------------------------------------------
+ case TypeClass_BOOLEAN:
+ switch (aSourceClass)
+ {
+ default:
+ {
+ sal_Bool bTmp = (toDouble( rVal ) != 0.0);
+ aRet.setValue( &bTmp, getBooleanCppuType() );
+ }
+ case TypeClass_ENUM: // exclude enums
+ break;
+
+ case TypeClass_STRING:
+ {
+ const OUString & aStr = *(const OUString *)rVal.getValue();
+ if (aStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("0") ) ||
+ aStr.equalsIgnoreCase( OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) ))
+ {
+ sal_Bool bFalse = sal_False;
+ aRet.setValue( &bFalse, getCppuBooleanType() );
+ }
+ else if (aStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("1") ) ||
+ aStr.equalsIgnoreCase( OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) ))
+ {
+ sal_Bool bTrue = sal_True;
+ aRet.setValue( &bTrue, getCppuBooleanType() );
+ }
+ else
+ {
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("STRING has no boolean value!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::IS_NOT_BOOL, 0 );
+ }
+ }
+ }
+ break;
+
+ // --- to CHAR, BYTE ------------------------------------------------------------------------
+ case TypeClass_CHAR:
+ {
+ if (aSourceClass==TypeClass_STRING)
+ {
+ if ((*(const OUString *)rVal.getValue()).getLength() == 1) // single char
+ aRet.setValue( (*(const OUString *)rVal.getValue()).getStr(), ::getCharCppuType() );
+ }
+ else if (aSourceClass!=TypeClass_ENUM && // exclude enums, chars
+ aSourceClass!=TypeClass_CHAR)
+ {
+ sal_Unicode cRet = (sal_Unicode)toHyper( rVal, 0, 0xffff ); // range
+ aRet.setValue( &cRet, ::getCharCppuType() );
+ }
+ break;
+ }
+ case TypeClass_BYTE:
+ aRet <<= (sal_Int8)( toHyper( rVal, -(sal_Int64)0x80, 0x7f ) );
+ break;
+
+ // --- to SHORT, UNSIGNED SHORT -------------------------------------------------------------
+ case TypeClass_SHORT:
+ aRet <<= (sal_Int16)( toHyper( rVal, -(sal_Int64)0x8000, 0x7fff ) );
+ break;
+ case TypeClass_UNSIGNED_SHORT:
+ aRet <<= (sal_uInt16)( toHyper( rVal, 0, 0xffff ) );
+ break;
+
+ // --- to LONG, UNSIGNED LONG ---------------------------------------------------------------
+ case TypeClass_LONG:
+ aRet <<= (sal_Int32)( toHyper( rVal, -(sal_Int64)0x80000000, 0x7fffffff ) );
+ break;
+ case TypeClass_UNSIGNED_LONG:
+ aRet <<= (sal_uInt32)( toHyper( rVal, 0, 0xffffffff ) );
+ break;
+
+ // --- to HYPER, UNSIGNED HYPER--------------------------------------------
+ case TypeClass_HYPER:
+ aRet <<= toHyper( rVal, -(sal_Int64)0x8000000000000000, 0x7fffffffffffffff );
+ break;
+ case TypeClass_UNSIGNED_HYPER:
+ aRet <<= (sal_uInt64)( toHyper( rVal, 0, 0xffffffffffffffff ) );
+ break;
+
+ // --- to FLOAT, DOUBLE ---------------------------------------------------------------------
+ case TypeClass_FLOAT:
+ aRet <<= (float)( toDouble( rVal, MIN_FLOAT, MAX_FLOAT ) );
+ break;
+ case TypeClass_DOUBLE:
+ aRet <<= (double)( toDouble( rVal, MIN_DOUBLE, MAX_DOUBLE ) );
+ break;
+
+ // --- to STRING ----------------------------------------------------------------------------
+ case TypeClass_STRING:
+ switch (aSourceClass)
+ {
+ case TypeClass_ENUM:
+ {
+ TypeDescription aEnumTD( aSourceType );
+ sal_Int32 nPos;
+ sal_Int32 nEnumValue = *(int *)rVal.getValue();
+ for ( nPos = ((typelib_EnumTypeDescription *)aEnumTD.get())->nEnumValues; nPos--; )
+ {
+ if (nEnumValue == ((typelib_EnumTypeDescription *)aEnumTD.get())->pEnumValues[nPos])
+ break;
+ }
+ if (nPos >= 0)
+ {
+ aRet.setValue( &((typelib_EnumTypeDescription *)aEnumTD.get())->ppEnumNames[nPos], ::getCppuType( (const OUString *)0 ) );
+ }
+ else
+ {
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value is not ENUM!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::IS_NOT_ENUM, 0 );
+ }
+ break;
+ }
+
+ case TypeClass_BOOLEAN:
+ aRet <<= OUString::createFromAscii( (*(sal_Bool *)rVal.getValue() ? "true" : "false") );
+ break;
+ case TypeClass_CHAR:
+ aRet <<= OUString( (sal_Unicode *)rVal.getValue(), 1 );
+ break;
+
+ case TypeClass_LONG:
+ {
+ sal_Int32 nInt(0);
+ rVal >>= nInt;
+ aRet <<= OUString::valueOf( nInt );
+ }
+ break;
+
+ default:
+ aRet <<= OUString::valueOf( toDouble( rVal ) );
+ }
+ }
+
+ if (aRet.getValueTypeClass() != TypeClass_VOID)
+ return aRet;
+
+ throw CannotConvertException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("conversion not possible!") ),
+ Reference< XInterface >(), aDestinationClass, FailReason::INVALID, 0 );
+ return Any(); // dummy
+}
+
+//*************************************************************************
+Reference< XInterface > SAL_CALL TypeConverter_Impl_CreateInstance(
+ const Reference< XMultiServiceFactory > & rSMgr )
+ throw( RuntimeException )
+{
+ return (XWeak *)(OWeakObject *)new TypeConverter_Impl();
+}
+
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL =
+ stoc_tcv::TypeConverter_Impl::getSupportedServiceNames_Static();
+
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ stoc_tcv::TypeConverter_Impl_CreateInstance,
+ stoc_tcv::TypeConverter_Impl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
diff --git a/stoc/source/typeconv/makefile.mk b/stoc/source/typeconv/makefile.mk
new file mode 100644
index 000000000000..3165dcdf4fce
--- /dev/null
+++ b/stoc/source/typeconv/makefile.mk
@@ -0,0 +1,105 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=stoc
+TARGET=tcv
+USE_DEFFILE=TRUE
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+UNOTYPES=$($(TARGET)_XML2CMPTYPES)
+
+SLOFILES= \
+ $(SLO)$/convert.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/test/excomp/example/ExampleComponent1.idl b/stoc/test/excomp/example/ExampleComponent1.idl
new file mode 100644
index 000000000000..3cfe772fa548
--- /dev/null
+++ b/stoc/test/excomp/example/ExampleComponent1.idl
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: ExampleComponent1.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _EXCOMP_EXAMPLECOMPONENT1_IDL_
+#define _EXCOMP_EXAMPLECOMPONENT1_IDL_
+
+#include <example/XTest.idl>
+
+module example
+{
+
+service ExampleComponent1
+{
+ interface XTest;
+};
+
+}; // test
+
+
+#endif
diff --git a/stoc/test/excomp/example/ExampleComponent2.idl b/stoc/test/excomp/example/ExampleComponent2.idl
new file mode 100644
index 000000000000..ad0e2237511f
--- /dev/null
+++ b/stoc/test/excomp/example/ExampleComponent2.idl
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * $RCSfile: ExampleComponent2.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _EXCOMP_EXAMPLECOMPONENT2_IDL_
+#define _EXCOMP_EXAMPLECOMPONENT2_IDL_
+
+#include <example/XTest.idl>
+
+module example
+{
+
+service ExampleComponent2
+{
+ interface XTest;
+};
+
+}; // test
+
+
+#endif
diff --git a/stoc/test/excomp/example/XTest.idl b/stoc/test/excomp/example/XTest.idl
new file mode 100644
index 000000000000..01d1e4bb44ef
--- /dev/null
+++ b/stoc/test/excomp/example/XTest.idl
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * $RCSfile: XTest.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _EXCOMP_XTEST_IDL_
+#define _EXCOMP_XTEST_IDL_
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module example
+{
+/**
+ * Simple test interface.
+ *
+ * @author Juergen Schmidt
+ */
+[ uik(46833373-3462-11d3-87A50070-24594732), ident("XTest", 1.0) ]
+interface XTest : com::sun::star::uno::XInterface
+{
+ /**
+ * in parameter test, tests by calls reference also (complex types)
+ */
+ string getMessage( );
+};
+
+}; // test
+
+#endif
diff --git a/stoc/test/excomp/excomp.cxx b/stoc/test/excomp/excomp.cxx
new file mode 100644
index 000000000000..27d9954aff2b
--- /dev/null
+++ b/stoc/test/excomp/excomp.cxx
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * $RCSfile: excomp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef _VOS_DIAGNOSE_HXX_
+#include <vos/diagnose.hxx>
+#endif
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+
+#include <example/XTest.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::lang;
+using namespace example;
+using namespace cppu;
+using namespace vos;
+using namespace rtl;
+
+#ifdef _DEBUG
+#define TEST_ENSHURE(c, m) VOS_ENSHURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) VOS_VERIFY(c)
+#endif
+
+OUString getExePath()
+{
+ OStartupInfo startupInfo;
+ OUString exe;
+
+ VOS_VERIFY(startupInfo.getExecutableFile(exe) == OStartupInfo::E_None);
+
+#if defined(WIN32) || defined(__OS2__) || defined(WNT)
+ exe = exe.copy(0, exe.getLength() - 10);
+#else
+ exe = exe.copy(0, exe.getLength() - 6);
+#endif
+ return exe;
+}
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+#ifdef UNX
+ OUString compName1(RTL_CONSTASCII_USTRINGPARAM("libexcomp1.so"));
+ OUString compName2(RTL_CONSTASCII_USTRINGPARAM("libexcomp2.so"));
+#else
+ OUString compName1(RTL_CONSTASCII_USTRINGPARAM("excomp1"));
+ OUString compName2(RTL_CONSTASCII_USTRINGPARAM("excomp2"));
+#endif
+
+ OUString exePath( getExePath() );
+ OUString excompRdb(exePath);
+
+ excompRdb += OUString::createFromAscii("excomp.rdb");
+
+ Reference< XMultiServiceFactory > xSMgr = ::cppu::createRegistryServiceFactory( excompRdb );
+ TEST_ENSHURE( xSMgr.is(), "excomp error 0" );
+
+ typelib_TypeDescription* pTypeDesc = NULL;
+ OUString sType = OUString::createFromAscii("com.sun.star.text.XTextDocument");
+ typelib_typedescription_getByName( &pTypeDesc, sType.pData);
+ typelib_InterfaceTypeDescription* pInterDesc = (typelib_InterfaceTypeDescription*)pTypeDesc;
+
+ Reference< XInterface > xIFace = xSMgr->createInstance(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration"));
+ Reference< XImplementationRegistration > xImpReg( xIFace, UNO_QUERY);
+ TEST_ENSHURE( xImpReg.is(), "excomp error 1" );
+ try
+ {
+ xImpReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ compName1,
+ Reference< XSimpleRegistry >() );
+ xImpReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ compName2,
+ Reference< XSimpleRegistry >() );
+ }
+ catch( CannotRegisterImplementationException& e)
+ {
+ TEST_ENSHURE( e.Message.getLength(), OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr() );
+ }
+
+ Reference< XTest > xTest1( xSMgr->createInstance(OUString::createFromAscii("example.ExampleComponent1")),
+ UNO_QUERY);
+ TEST_ENSHURE( xTest1.is(), "excomp error 2" );
+ Reference< XTest > xTest2( xSMgr->createInstance(OUString::createFromAscii("example.ExampleComponent2")),
+ UNO_QUERY);
+ TEST_ENSHURE( xTest2.is(), "excomp error 3" );
+
+ OUString m1 = xTest1->getMessage();
+ OUString m2 = xTest2->getMessage();
+
+ fprintf(stdout, "ExampleComponent1, Message = \"%s\"\n", OUStringToOString(m1, RTL_TEXTENCODING_ASCII_US).getStr());
+ fprintf(stdout, "ExampleComponent2, Message = \"%s\"\n", OUStringToOString(m2, RTL_TEXTENCODING_ASCII_US).getStr());
+
+ xImpReg->revokeImplementation(compName1, Reference< XSimpleRegistry >() );
+ xImpReg->revokeImplementation(compName2, Reference< XSimpleRegistry >() );
+
+ Reference< XComponent >( xSMgr, UNO_QUERY )->dispose();
+
+ return(0);
+}
+
+
diff --git a/stoc/test/excomp/excomp1.cxx b/stoc/test/excomp/excomp1.cxx
new file mode 100644
index 000000000000..fc5f3577df80
--- /dev/null
+++ b/stoc/test/excomp/excomp1.cxx
@@ -0,0 +1,259 @@
+/*************************************************************************
+ *
+ * $RCSfile: excomp1.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+
+#include <example/XTest.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+using namespace example;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+#define SERVICENAME1 "example.ExampleComponent1"
+#define IMPLNAME1 "example.ExampleComponent1.Impl"
+
+namespace excomp_impl {
+
+//*************************************************************************
+// ExampleComponent1Impl
+//*************************************************************************
+class ExampleComponent1Impl : public WeakImplHelper2< XTest, XServiceInfo >
+{
+public:
+ ExampleComponent1Impl( const Reference<XMultiServiceFactory> & rXSMgr );
+
+ ~ExampleComponent1Impl();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( );
+
+ // XSimpleRegistry
+ virtual OUString SAL_CALL getMessage() throw(RuntimeException);
+
+protected:
+ Mutex m_mutex;
+
+ Reference<XMultiServiceFactory> m_xSMgr;
+};
+
+//*************************************************************************
+ExampleComponent1Impl::ExampleComponent1Impl( const Reference<XMultiServiceFactory> & rXSMgr )
+ : m_xSMgr(rXSMgr)
+{
+}
+
+//*************************************************************************
+ExampleComponent1Impl::~ExampleComponent1Impl()
+{
+}
+
+//*************************************************************************
+OUString SAL_CALL ExampleComponent1Impl::getImplementationName( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME1) );
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL ExampleComponent1Impl::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ExampleComponent1Impl::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ExampleComponent1Impl::getSupportedServiceNames_Static( )
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME1) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//*************************************************************************
+OUString SAL_CALL ExampleComponent1Impl::getMessage() throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return OUString::createFromAscii("Lalelu nur der Mann im Mond schaut zu ...");
+}
+
+
+//*************************************************************************
+Reference<XInterface> SAL_CALL ExampleComponent1_CreateInstance( const Reference<XMultiServiceFactory>& rSMgr )
+{
+ Reference<XInterface> xRet;
+
+ XTest *pXTest = (XTest*) new ExampleComponent1Impl(rSMgr);
+
+ if (pXTest)
+ {
+ xRet = Reference< XInterface >::query(pXTest);
+ }
+
+ return xRet;
+}
+
+} // excomp_impl
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ // ExampleComponent1
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME1 "/UNO/SERVICES") ) ) );
+
+ Sequence< OUString > & rSNL =
+ ::excomp_impl::ExampleComponent1Impl::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLNAME1 ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME1) ),
+ ::excomp_impl::ExampleComponent1_CreateInstance,
+ ::excomp_impl::ExampleComponent1Impl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
+
diff --git a/stoc/test/excomp/excomp1.xml b/stoc/test/excomp/excomp1.xml
new file mode 100644
index 000000000000..0246dd4f88ca
--- /dev/null
+++ b/stoc/test/excomp/excomp1.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Juergen Schmidt </Author>
+
+<Name> example.ExampleComponent1.Impl </Name>
+
+<Description>
+ This component provides a simple demo component.
+</Description>
+
+<ModuleName> excomp1 </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> example.ExampleComponent1 </SupportedService>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> vos </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu </RuntimeModuleDependency>
+<RuntimeModuleDependency> vos </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal </RuntimeModuleDependency>
+
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> example.XTest </Type>
+
+</COMPONENTDESCRIPTION>
diff --git a/stoc/test/excomp/excomp2.cxx b/stoc/test/excomp/excomp2.cxx
new file mode 100644
index 000000000000..ccedc6dbf907
--- /dev/null
+++ b/stoc/test/excomp/excomp2.cxx
@@ -0,0 +1,334 @@
+/*************************************************************************
+ *
+ * $RCSfile: excomp2.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
+#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+
+#include <example/XTest.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+using namespace example;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+#define SERVICENAME2 "example.ExampleComponent2"
+#define IMPLNAME2 "example.ExampleComponent2.Impl"
+
+namespace excomp2_impl {
+
+//*************************************************************************
+// ExampleComponent2Impl
+//*************************************************************************
+class ExampleComponent2Impl : public OWeakObject
+ , public XTypeProvider
+ , public XServiceInfo
+ , public XTest
+{
+public:
+ ExampleComponent2Impl( const Reference<XMultiServiceFactory> & rXSMgr );
+
+ ~ExampleComponent2Impl();
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw()
+ { OWeakObject::release(); }
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( );
+
+ // XTest
+ virtual OUString SAL_CALL getMessage() throw(RuntimeException);
+
+protected:
+ Mutex m_mutex;
+
+ Reference<XMultiServiceFactory> m_xSMgr;
+};
+
+//*************************************************************************
+ExampleComponent2Impl::ExampleComponent2Impl( const Reference<XMultiServiceFactory> & rXSMgr )
+ : m_xSMgr(rXSMgr)
+{
+}
+
+//*************************************************************************
+ExampleComponent2Impl::~ExampleComponent2Impl()
+{
+}
+
+//*************************************************************************
+Any SAL_CALL ExampleComponent2Impl::queryInterface( const ::com::sun::star::uno::Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface(rType,
+ static_cast< XTypeProvider * >( this ),
+ static_cast< XServiceInfo * >( this ),
+ static_cast< XTest * >( this ) );
+ if ( aRet.hasValue() )
+ return aRet;
+
+ return OWeakObject::queryInterface( rType );
+}
+
+//*************************************************************************
+Sequence< Type > SAL_CALL ExampleComponent2Impl::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * pTypes = 0;
+ if (! pTypes)
+ {
+ MutexGuard aGuard( m_mutex );
+ if (! pTypes)
+ {
+ static OTypeCollection aTypes(
+ ::getCppuType( (const Reference< XInterface > *)0 ),
+ ::getCppuType( (const Reference< XWeak > *)0 ),
+ ::getCppuType( (const Reference< XTypeProvider > *)0 ),
+ ::getCppuType( (const Reference< XServiceInfo > *)0 ),
+ ::getCppuType( (const Reference< XTest > *)0 ) );
+ pTypes = &aTypes;
+ }
+ }
+ return pTypes->getTypes();
+}
+
+//*************************************************************************
+Sequence< sal_Int8 > SAL_CALL ExampleComponent2Impl::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( m_mutex );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//*************************************************************************
+OUString SAL_CALL ExampleComponent2Impl::getImplementationName( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME2) );
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL ExampleComponent2Impl::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ExampleComponent2Impl::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ExampleComponent2Impl::getSupportedServiceNames_Static( )
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME2) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//*************************************************************************
+OUString SAL_CALL ExampleComponent2Impl::getMessage() throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return OUString::createFromAscii("Alle meine Entchen schwimmen auf dem See, schwimmen auf dem See ...");
+}
+
+
+//*************************************************************************
+Reference<XInterface> SAL_CALL ExampleComponent2_CreateInstance( const Reference<XMultiServiceFactory>& rSMgr )
+{
+ Reference<XInterface> xRet;
+
+ XTest *pXTest = (XTest*) new ExampleComponent2Impl(rSMgr);
+
+ if (pXTest)
+ {
+ xRet = Reference< XInterface >::query(pXTest);
+ }
+
+ return xRet;
+}
+
+
+} // excomp_impl
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ // ExampleComponent2
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME2 "/UNO/SERVICES") ) ) );
+
+ Sequence< OUString > & rSNL =
+ ::excomp2_impl::ExampleComponent2Impl::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSHURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLNAME2 ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME2) ),
+ ::excomp2_impl::ExampleComponent2_CreateInstance,
+ ::excomp2_impl::ExampleComponent2Impl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
+
diff --git a/stoc/test/excomp/excomp2.xml b/stoc/test/excomp/excomp2.xml
new file mode 100644
index 000000000000..4fa4db28eb2d
--- /dev/null
+++ b/stoc/test/excomp/excomp2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "componentdescription.dtd">
+
+<COMPONENTDESCRIPTION
+ xmlns:xlink="http://www.w3.org/1999/xlink/Namespace" >
+
+<Author> Juergen Schmidt </Author>
+
+<Name> example.ExampleComponent2.Impl </Name>
+
+<Description>
+ This component provides a simple demo component.
+</Description>
+
+<ModuleName> excomp2 </ModuleName>
+
+<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName>
+
+<Language> c++ </Language>
+
+<Status StatusValue="final"/>
+
+<SupportedService> example.ExampleComponent2 </SupportedService>
+
+<ProjectBuildDependency> cppuhelper </ProjectBuildDependency>
+<ProjectBuildDependency> cppu </ProjectBuildDependency>
+<ProjectBuildDependency> vos </ProjectBuildDependency>
+<ProjectBuildDependency> sal </ProjectBuildDependency>
+
+<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency>
+<RuntimeModuleDependency> cppu </RuntimeModuleDependency>
+<RuntimeModuleDependency> vos </RuntimeModuleDependency>
+<RuntimeModuleDependency> sal </RuntimeModuleDependency>
+
+<Type> com.sun.star.lang.XTypeProvider </Type>
+<Type> com.sun.star.lang.XServiceInfo </Type>
+<Type> com.sun.star.lang.XSingleServiceFactory </Type>
+<Type> com.sun.star.lang.XMultiServiceFactory </Type>
+<Type> com.sun.star.registry.XRegistryKey </Type>
+<Type> com.sun.star.uno.XAggregation </Type>
+<Type> com.sun.star.uno.XWeak </Type>
+<Type> com.sun.star.uno.TypeClass </Type>
+<Type> example.XTest </Type>
+
+</COMPONENTDESCRIPTION>
diff --git a/stoc/test/excomp/exports.dxp b/stoc/test/excomp/exports.dxp
new file mode 100644
index 000000000000..2513a15ad5d5
--- /dev/null
+++ b/stoc/test/excomp/exports.dxp
@@ -0,0 +1,4 @@
+component_getDescriptionFunc
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/stoc/test/excomp/makefile.mk b/stoc/test/excomp/makefile.mk
new file mode 100644
index 000000000000..578a1880cff3
--- /dev/null
+++ b/stoc/test/excomp/makefile.mk
@@ -0,0 +1,167 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= excomp
+TARGET1= excomp1
+TARGET2= excomp2
+TARGETTYPE=CUI
+#LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+COMP1TYPELIST=$(TARGET1)
+COMP2TYPELIST=$(TARGET2)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+UNOUCRDEP= $(BIN)$/excomp.rdb
+UNOUCRRDB= $(BIN)$/excomp.rdb
+UNOUCROUT= $(OUT)$/inc
+INCPRE+= $(OUT)$/inc
+
+UNOTYPES=$($(TARGET1)_XML2CMPTYPES)
+UNOTYPES+=$($(TARGET2)_XML2CMPTYPES)
+UNOTYPES+= com.sun.star.registry.XImplementationRegistration \
+ com.sun.star.lang.XComponent
+
+# --- Application excomp ------------------------------------------------
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/excomp.obj
+
+APP1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+# ---- objects ----
+SLOFILES= \
+ $(SLO)$/excomp1.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj \
+ $(SLO)$/excomp2.obj \
+ $(SLO)$/$(COMP2TYPELIST)_description.obj
+
+# ---- excomp1 ------
+SHL1TARGET= $(TARGET1)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1LIBS=
+SHL1OBJS= $(SLO)$/excomp1.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+SHL1IMPLIB= i$(TARGET1)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# ---- excomp2 ------
+SHL2TARGET= $(TARGET2)
+
+SHL2STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+SHL2DEPN=
+SHL2LIBS=
+SHL2OBJS= $(SLO)$/excomp2.obj \
+ $(SLO)$/$(COMP2TYPELIST)_description.obj
+SHL2IMPLIB= i$(TARGET2)
+SHL2DEF= $(MISC)$/$(SHL2TARGET).def
+
+DEF2NAME= $(SHL2TARGET)
+DEF2EXPORTFILE= exports.dxp
+
+ALLIDLFILES:= example$/XTest.idl example$/ExampleComponent1.idl example$/ExampleComponent2.idl
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : $(BIN)$/excomp.rdb \
+ ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+$(BIN)$/excomp.rdb: $(ALLIDLFILES)
+ +unoidl -I$(PRJ) -I$(SOLARIDLDIR) -Burd -OH$(MISC)$/excomp $?
+ +regmerge $@ /UCR $(MISC)$/excomp$/{$(?:f:s/.idl/.urd/)}
+ +regmerge $@ / $(SOLARBINDIR)$/applicat.rdb
+ touch $@
+
diff --git a/stoc/test/javavm/makefile.mk b/stoc/test/javavm/makefile.mk
new file mode 100644
index 000000000000..4784d96882c6
--- /dev/null
+++ b/stoc/test/javavm/makefile.mk
@@ -0,0 +1,124 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET6= testjavavm
+TARGETTYPE= CUI
+LIBTARGET= NO
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC= TRUE
+
+UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb
+#UNOUCROUT= $(OUT)$/inc$/test
+UNOUCROUT= $(OUT)$/inc$
+#INCPRE+= $(OUT)$/inc$/test
+INCPRE+= $(OUT)$/inc$
+
+#asdf:
+# echo $(OUT)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Application 6 - testjavavm ------------------------------------
+APP6TARGET= $(TARGET6)
+APP6OBJS = $(OBJ)$/testjavavm.obj
+APP6STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(UNOLIB)
+
+.IF "$(GUI)"=="WNT"
+APP6STDLIBS+= $(LIBCIMT)
+.ENDIF
+
+#ALLIDLFILES:=
+
+# --- Target ------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : unoheader \
+ ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+TESTJAVAVM:=com.sun.star.uno.XWeak;com.sun.star.java.XJavaVM;com.sun.star.java.XJavaThreadRegister.XJavaThreadRegister_11;com.sun.star.registry.XSimpleRegistry;com.sun.star.lang.XComponent;com.sun.star.registry.XImplementationRegistration;com.sun.star.lang.XSingleServiceFactory;com.sun.star.uno.TypeClass;com.sun.star.lang.XMultiServiceFactory
+
+#$(BIN)$/stoctest.rdb: $(ALLIDLFILES)
+# +unoidl -I$(PRJ) -I$(SOLARIDLDIR) -Burd -OH$(BIN) $?
+# +regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)}
+# +regmerge $@ / $(UNOUCRRDB)
+# touch $@
+
+unoheader: $(UNOUCRRDB)
+ +cppumaker -BUCR -O$(UNOUCROUT) -T"$(TESTJAVAVM)" $(UNOUCRRDB)
+
diff --git a/stoc/test/javavm/testjavavm.cxx b/stoc/test/javavm/testjavavm.cxx
new file mode 100644
index 000000000000..34c883f2168e
--- /dev/null
+++ b/stoc/test/javavm/testjavavm.cxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * $RCSfile: testjavavm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include <jni.h>
+
+//#include <iostream>
+#include <stdio.h>
+#include <uno/api.h>
+
+#include <vos/diagnose.hxx>
+#include <vos/dynload.hxx>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/weak.hxx>
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/java/XJavaVM.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/java/XJavaThreadRegister/XJavaThreadRegister_11.hpp>
+
+//#include <cppuhelper/implbase1.hxx>
+
+using namespace std;
+using namespace rtl;
+using namespace cppu;
+using namespace vos;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+//using namespace com::sun::star::reflection;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::java;
+using namespace com::sun::star::java::XJavaThreadRegister;
+
+
+sal_Bool testJavaVM(const Reference< XMultiServiceFactory > & xMgr )
+{
+
+ Reference<XInterface> xXInt= xMgr->createInstance(L"com.sun.star.java.JavaVirtualMachine");
+ if( ! xXInt.is())
+ return sal_False;
+ Reference<XJavaVM> xVM( xXInt, UNO_QUERY);
+ if( ! xVM.is())
+ return sal_False;
+ Reference<XJavaThreadRegister_11> xreg11(xVM, UNO_QUERY);
+ if( ! xreg11.is())
+ return sal_False;
+
+ sal_Bool b= xreg11->isThreadAttached();
+ xreg11->registerThread();
+ b= xreg11->isThreadAttached();
+ xreg11->revokeThread();
+ b= xreg11->isThreadAttached();
+
+ Uik aMachineId;
+ aMachineId.m_Data1= 0;
+ aMachineId.m_Data2= 0;
+ aMachineId.m_Data3= 0;
+ aMachineId.m_Data4= 0;
+ aMachineId.m_Data5= 0;
+
+ b= xVM->isVMEnabled();
+ b= xVM->isVMStarted();
+
+ Any anyVM = xVM->getJavaVM( aMachineId, UNO_getProcessIdentifier());
+
+ b= xVM->isVMEnabled();
+ b= xVM->isVMStarted();
+
+
+ JavaVM* _jvm= *(JavaVM**) anyVM.getValue();
+ JNIEnv *p_env;
+ if( _jvm->AttachCurrentThread( &p_env, 0))
+ return sal_False;
+
+// jclass aJProg = p_env->FindClass("TestJavaVM");
+// if( p_env->ExceptionOccurred()){
+// p_env->ExceptionDescribe();
+// p_env->ExceptionClear();
+// }
+//
+// jmethodID mid= p_env->GetStaticMethodID( aJProg,"main", "([Ljava/lang/String;)V");
+
+ jclass cls = p_env->FindClass( "TestJavaVM");
+ if (cls == 0) {
+ VOS_TRACE( "Can't find Prog class\n");
+ exit(1);
+ }
+
+// jmethodID methid = p_env->GetStaticMethodID( cls, "main", "([Ljava/lang/String;)V");
+// if (methid == 0) {
+// VOS_TRACE("Can't find Prog.main\n");
+// exit(1);
+// }
+
+// jstring jstr = p_env->NewStringUTF(" from C!");
+// if (jstr == 0) {
+// VOS_TRACE("Out of memory\n");
+// exit(1);
+// }
+// jobjectArray args = p_env->NewObjectArray( 1,
+// p_env->FindClass("java/lang/String"), jstr);
+// if (args == 0) {
+// VOS_TRACE( "Out of memory\n");
+// exit(1);
+// }
+// p_env->CallStaticVoidMethod( cls, methid, args);
+
+
+ jmethodID id = p_env->GetStaticMethodID( cls, "getInt", "()I");
+ if( id)
+ {
+ jint _i= p_env->CallStaticIntMethod(cls, id);
+ }
+
+ if( p_env->ExceptionOccurred()){
+ p_env->ExceptionDescribe();
+ p_env->ExceptionClear();
+ }
+
+
+ _jvm->DetachCurrentThread();
+ return sal_True;
+}
+
+extern
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int __cdecl main( int argc, char * argv[] )
+#endif
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory( "applicat.rdb" ) );
+
+ sal_Bool bSucc = sal_False;
+ try
+ {
+ Reference<com::sun::star::registry::XImplementationRegistration> xImplReg(
+ xMgr->createInstance( L"com.sun.star.registry.ImplementationRegistration" ), UNO_QUERY );
+ VOS_ENSHURE( xImplReg.is(), "### no impl reg!" );
+
+ sal_Char pLibName[256];
+ ORealDynamicLoader::computeLibraryName("je558mi", pLibName, 255);
+ xImplReg->registerImplementation(
+ L"com.sun.star.loader.SharedLibrary", OWString::createFromAscii(pLibName), Reference< XSimpleRegistry >() );
+
+ bSucc = testJavaVM( xMgr );
+ }
+ catch (Exception & rExc)
+ {
+ VOS_ENSHURE( sal_False, "### exception occured!" );
+ OString aMsg( OWStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ VOS_TRACE( "### exception occured: " );
+ VOS_TRACE( aMsg.getStr() );
+ VOS_TRACE( "\n" );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+ printf("javavm %s", bSucc ? "succeeded" : "failed");
+// cout << "javavm " << (bSucc ? "succeeded" : "failed") << " !" << endl;
+ return (bSucc ? 0 : -1);
+}
+
+
diff --git a/stoc/test/javavm/testjavavm.java b/stoc/test/javavm/testjavavm.java
new file mode 100644
index 000000000000..3acef1ae7801
--- /dev/null
+++ b/stoc/test/javavm/testjavavm.java
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: testjavavm.java,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+class TestJavaVM
+{
+ public static int getInt()
+ {
+ return 100;
+ }
+
+ public static void main( String args[])
+ {
+ System.out.println("Hello World");
+ }
+}
diff --git a/stoc/test/language_binding.idl b/stoc/test/language_binding.idl
new file mode 100644
index 000000000000..cc93e8a32197
--- /dev/null
+++ b/stoc/test/language_binding.idl
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * $RCSfile: language_binding.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _TEST_LANGUAGE_BINDING_IDL_
+#define _TEST_LANGUAGE_BINDING_IDL_
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/lang/IllegalArgumentException.idl>
+
+module test
+{
+
+enum TestEnum
+{
+ TEST,
+ ONE,
+ TWO,
+ CHECK,
+ LOLA,
+ PALOO,
+ ZA
+};
+
+/**
+ * simple c++ types
+ */
+struct TestSimple
+{
+ boolean Bool;
+ char Char;
+ byte Byte;
+ short Short;
+ unsigned short UShort;
+ long Long;
+ unsigned long ULong;
+ hyper Hyper;
+ unsigned hyper UHyper;
+ float Float;
+ double Double;
+ test::TestEnum Enum;
+};
+/**
+ * complex c++ types
+ */
+struct TestElement : test::TestSimple
+{
+ string String;
+ com::sun::star::uno::XInterface Interface;
+ any Any;
+};
+struct TestDataElements : test::TestElement
+{
+ sequence<test::TestElement > Sequence;
+};
+
+typedef TestDataElements TestData;
+
+/**
+ * Monster test interface to test language binding calls.
+ *
+ * @author Daniel Boelzle
+ */
+[ uik(46833373-3462-11d3-87A400A0-24494732), ident("XLBTest", 1.0) ]
+interface XLBTestBase : com::sun::star::uno::XInterface
+{
+ /**
+ * in parameter test, tests by calls reference also (complex types)
+ */
+ [oneway] void setValues( [in] boolean bBool, [in] char cChar, [in] byte nByte,
+ [in] short nShort, [in] unsigned short nUShort,
+ [in] long nLong, [in] unsigned long nULong,
+ [in] hyper nHyper, [in] unsigned hyper nUHyper,
+ [in] float fFloat, [in] double fDouble,
+ [in] test::TestEnum eEnum, [in] string aString,
+ [in] com::sun::star::uno::XInterface xInterface, [in] any aAny,
+ [in] sequence<test::TestElement > aSequence,
+ [in] test::TestData aStruct );
+ /**
+ * inout parameter test
+ */
+ test::TestData setValues2( [inout] boolean bBool, [inout] char cChar, [inout] byte nByte,
+ [inout] short nShort, [inout] unsigned short nUShort,
+ [inout] long nLong, [inout] unsigned long nULong,
+ [inout] hyper nHyper, [inout] unsigned hyper nUHyper,
+ [inout] float fFloat, [inout] double fDouble,
+ [inout] test::TestEnum eEnum, [inout] string aString,
+ [inout] com::sun::star::uno::XInterface xInterface, [inout] any aAny,
+ [inout] sequence<test::TestElement > aSequence,
+ [inout] test::TestData aStruct );
+
+ /**
+ * out parameter test
+ */
+ test::TestData getValues( [out] boolean bBool, [out] char cChar, [out] byte nByte,
+ [out] short nShort, [out] unsigned short nUShort,
+ [out] long nLong, [out] unsigned long nULong,
+ [out] hyper nHyper, [out] unsigned hyper nUHyper,
+ [out] float fFloat, [out] double fDouble,
+ [out] test::TestEnum eEnum, [out] string aString,
+ [out] com::sun::star::uno::XInterface xInterface, [out] any aAny,
+ [out] sequence<test::TestElement > aSequence,
+ [out] test::TestData aStruct );
+
+ [attribute] boolean Bool;
+ [attribute] byte Byte;
+ [attribute] char Char;
+ [attribute] short Short;
+ [attribute] unsigned short UShort;
+ [attribute] long Long;
+ [attribute] unsigned long ULong;
+ [attribute] hyper Hyper;
+ [attribute] unsigned hyper UHyper;
+ [attribute] float Float;
+ [attribute] double Double;
+ [attribute] test::TestEnum Enum;
+ [attribute] string String;
+ [attribute] com::sun::star::uno::XInterface Interface;
+ [attribute] any Any;
+ [attribute] sequence<test::TestElement > Sequence;
+ [attribute] test::TestData Struct;
+};
+
+
+/**
+ * Inherting from monster; adds raiseException().
+ *
+ * @author Daniel Boelzle
+ */
+[ uik(44C34C20-3478-11d3-87A400A0-24494732), ident("XLanguageBindingTest", 1.0) ]
+interface XLanguageBindingTest : test::XLBTestBase
+{
+ /**
+ * params are there only for dummy, to test if all temp out params will be released.
+ */
+ test::TestData raiseException( [out] boolean bBool, [out] char cChar, [out] byte nByte,
+ [out] short nShort, [out] unsigned short nUShort,
+ [out] long nLong, [out] unsigned long nULong,
+ [out] hyper nHyper, [out] unsigned hyper nUHyper,
+ [out] float fFloat, [out] double fDouble,
+ [out] test::TestEnum eEnum, [out] string aString,
+ [out] com::sun::star::uno::XInterface xInterface, [out] any aAny,
+ [out] sequence<test::TestElement > aSequence,
+ [out] test::TestData aStruct )
+ raises( com::sun::star::lang::IllegalArgumentException );
+
+ /**
+ * raises runtime exception
+ */
+ [attribute] long RuntimeException;
+};
+
+}; // test
+
+
+#endif
diff --git a/stoc/test/makefile.mk b/stoc/test/makefile.mk
new file mode 100644
index 000000000000..0c3c3b12b0d6
--- /dev/null
+++ b/stoc/test/makefile.mk
@@ -0,0 +1,239 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=stoc
+TARGET=stoc
+TARGET1=testloader
+TARGET2=testregistry
+TARGET3=testsmgr
+TARGET4=testcorefl
+TARGET5=testiadapter
+TARGET6=testintrosp
+TARGET7=testconv
+TARGET8=testproxyfac
+TARGETTYPE=CUI
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= testloader.cxx \
+ testregistry.cxx \
+ testsmgr.cxx
+
+# --- Application 1 ------------------------------------------------
+APP1TARGET= $(TARGET1)
+APP1OBJS= $(OBJ)$/testloader.obj
+
+APP1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+=
+# $(LIBCIMT) $(LIBCMT)
+.ENDIF
+
+# --- Application 2 ------------------------------------------------
+APP2TARGET= $(TARGET2)
+APP2OBJS= $(OBJ)$/testregistry.obj
+
+APP2STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(UNOTOOLSLIB)
+
+.IF "$(GUI)"=="WNT"
+APP2STDLIBS+=
+# $(LIBCIMT) $(LIBCMT)
+.ENDIF
+
+
+# --- Application 3 - testsmgr main ------------------------------------
+APP3TARGET= $(TARGET3)
+APP3OBJS = $(OBJ)$/testsmgr.obj
+APP3STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="UNX"
+APP3STDLIBS+= -lat
+.ENDIF
+.IF "$(GUI)"=="WNT"
+APP3STDLIBS+= $(LIBCIMT) \
+ iat.lib
+.ENDIF
+
+# --- Application 4 - testcorefl main ------------------------------------
+APP4TARGET= $(TARGET4)
+APP4OBJS = $(OBJ)$/testcorefl.obj
+APP4STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="WNT"
+APP4STDLIBS+= $(LIBCIMT)
+.ENDIF
+
+# --- Application 5 - testiadapter main ------------------------------------
+APP5TARGET= $(TARGET5)
+APP5OBJS = $(OBJ)$/testiadapter.obj
+APP5STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="WNT"
+APP5STDLIBS+= $(LIBCIMT)
+.ENDIF
+
+# --- Application 6 - testiadapter main ------------------------------------
+APP6TARGET= $(TARGET6)
+APP6OBJS = $(OBJ)$/testintrosp.obj
+APP6STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="WNT"
+APP6STDLIBS+= $(LIBCIMT)
+.ENDIF
+
+# --- Application 7 - testiadapter main ------------------------------------
+APP7TARGET= $(TARGET7)
+APP7OBJS = $(OBJ)$/testconv.obj
+APP7STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="WNT"
+APP7STDLIBS+= $(LIBCIMT)
+.ENDIF
+
+# --- Application 8 - testproxyfac main ------------------------------------
+APP8TARGET= $(TARGET8)
+APP8OBJS = $(OBJ)$/testproxyfac.obj
+APP8STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="WNT"
+APP8STDLIBS+= $(LIBCIMT)
+.ENDIF
+
+ALLIDLFILES:= testcorefl.idl language_binding.idl testintrosp.idl
+
+
+# --- Target ------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : unoheader \
+ ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+CPPUMAKERFLAGS =
+.IF "$(COM)" == "MSC"
+CPPUMAKERFLAGS = -L
+.ENDIF
+
+FACTORYTYPES:=com.sun.star.container.XEnumeration;com.sun.star.lang.XComponent;com.sun.star.registry.XSimpleRegistry;com.sun.star.lang.XInitialization;com.sun.star.lang.XMultiServiceFactory;com.sun.star.loader.XImplementationLoader;com.sun.star.registry.XImplementationRegistration;com.sun.star.container.XSet;com.sun.star.lang.XSingleServiceFactory
+TESTCOREFL:=ModuleC;ModuleC.XInterfaceA;ModuleC.XInterfaceB;ModuleA.XInterface1;com.sun.star.reflection.XIdlReflection;com.sun.star.reflection.XIdlField;com.sun.star.reflection.XIdlArray;com.sun.star.reflection.XIdlMethod;com.sun.star.reflection.XIdlClass;com.sun.star.beans.XPropertySet;com.sun.star.lang.XComponent;com.sun.star.container.XHierarchicalNameAccess
+TESTIADAPTER:=com.sun.star.beans.XIntrospection;com.sun.star.beans.MethodConcept;com.sun.star.beans.XExactName;com.sun.star.lang.XTypeProvider;com.sun.star.uno.XAggregation;com.sun.star.script.XInvocationAdapterFactory;com.sun.star.script.XInvocation;com.sun.star.lang.XMultiServiceFactory;com.sun.star.registry.XSimpleRegistry;com.sun.star.lang.XInitialization;test.XLanguageBindingTest
+TESTINTROSP:=ModuleA;ModuleA.XIntroTest;com.sun.star.beans.XPropertySet;com.sun.star.container.XIndexAccess;com.sun.star.container.XNameAccess;com.sun.star.beans.PropertyAttribute;com.sun.star.beans.PropertyConcept
+TESTCONV:=com.sun.star.script.XTypeConverter
+TESTPROXYFAC:=com.sun.star.util.XProxyFactory
+
+$(BIN)$/stoctest.rdb: $(ALLIDLFILES)
+ +unoidl -I$(PRJ) -I$(SOLARIDLDIR) -Burd -OH$(BIN) $?
+ +regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)}
+ +regmerge $@ / $(SOLARBINDIR)$/applicat.rdb
+ touch $@
+
+unoheader: $(BIN)$/stoctest.rdb
+ +cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTIADAPTER);$(FACTORYTYPES)" $(BIN)$/stoctest.rdb
+ +cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTCOREFL)" $(BIN)$/stoctest.rdb
+ +cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTINTROSP)" $(BIN)$/stoctest.rdb
+ +cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTCONV)" $(BIN)$/stoctest.rdb
+ +cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTPROXYFAC)" $(BIN)$/stoctest.rdb
+
diff --git a/stoc/test/testconv.cxx b/stoc/test/testconv.cxx
new file mode 100644
index 000000000000..5bacf288d1fe
--- /dev/null
+++ b/stoc/test/testconv.cxx
@@ -0,0 +1,736 @@
+/*************************************************************************
+ *
+ * $RCSfile: testconv.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <osl/diagnose.h>
+#include <rtl/ustrbuf.hxx>
+#include <cppuhelper/servicefactory.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/reflection/FieldAccessMode.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+
+#include <float.h>
+#include <stdio.h>
+
+
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::script;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::registry;
+
+const double MIN_DOUBLE = -DBL_MAX;
+const double MAX_DOUBLE = DBL_MAX;
+const double MIN_FLOAT = -FLT_MAX;
+const double MAX_FLOAT = FLT_MAX;
+
+//==================================================================================================
+static void printValue( const Any & rVal )
+{
+ // print value
+ OString aStr( OUStringToOString( rVal.getValueType().getTypeName(), RTL_TEXTENCODING_ISO_8859_1 ) );
+ printf( "(%s)", aStr.getStr() );
+
+ switch (rVal.getValueTypeClass())
+ {
+ case TypeClass_VOID:
+ printf( "void" );
+ break;
+ case TypeClass_ANY:
+ if (rVal.hasValue())
+ printValue( *(Any *)rVal.getValue() );
+ break;
+ case TypeClass_BOOLEAN:
+ printf( "%s", (*(sal_Bool *)rVal.getValue() ? "true" : "false") );
+ break;
+ case TypeClass_CHAR:
+ {
+ char ar[2];
+ ar[0] = (char)(sal_Unicode)rVal.getValue();
+ ar[1] = 0;
+ printf( ar );
+ break;
+ }
+ case TypeClass_BYTE:
+ printf( "%x", (int)*(sal_Int8 *)rVal.getValue() );
+ break;
+ case TypeClass_SHORT:
+ printf( "%x", *(sal_Int16 *)rVal.getValue() );
+ break;
+ case TypeClass_UNSIGNED_SHORT:
+ printf( "%x", *(sal_uInt16 *)rVal.getValue() );
+ break;
+ case TypeClass_LONG:
+ printf( "%x", *(sal_Int32 *)rVal.getValue() );
+ break;
+ case TypeClass_UNSIGNED_LONG:
+ printf( "%x", *(sal_uInt32 *)rVal.getValue() );
+ break;
+ case TypeClass_HYPER:
+ printf( "%x", (long)*(sal_Int64 *)rVal.getValue() );
+ break;
+ case TypeClass_UNSIGNED_HYPER:
+ printf( "%x", (unsigned long)*(sal_uInt64 *)rVal.getValue() );
+ break;
+ case TypeClass_FLOAT:
+ printf( "%f", *(float *)rVal.getValue() );
+ break;
+ case TypeClass_DOUBLE:
+ printf( "%g", *(double *)rVal.getValue() );
+ break;
+ case TypeClass_STRING:
+ {
+ OString aStr( OUStringToOString( *(OUString *)rVal.getValue(), RTL_TEXTENCODING_ISO_8859_1 ) );
+ printf( aStr.getStr() );
+ break;
+ }
+ case TypeClass_ENUM:
+ {
+ typelib_EnumTypeDescription * pEnumTD = 0;
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pEnumTD, rVal.getValueTypeRef() );
+
+ for ( sal_Int32 nPos = pEnumTD->nEnumValues; nPos--; )
+ {
+ if (pEnumTD->pEnumValues[nPos] == *(int *)rVal.getValue())
+ {
+ printf( OUStringToOString(pEnumTD->ppEnumNames[nPos]->buffer, RTL_TEXTENCODING_ASCII_US).getStr() );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pEnumTD );
+ return;
+ }
+ }
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pEnumTD );
+ printf( ">ENUM not found!<" );
+ break;
+ }
+ case TypeClass_SEQUENCE:
+ {
+ uno_Sequence * pSeq = *(uno_Sequence **)rVal.getValue();
+ typelib_TypeDescription * pSeqTD = 0;
+ TYPELIB_DANGER_GET( &pSeqTD, rVal.getValueTypeRef() );
+ typelib_TypeDescription * pElemTD = 0;
+ TYPELIB_DANGER_GET( &pElemTD, ((typelib_IndirectTypeDescription *)pSeqTD)->pType );
+
+ sal_Int32 nLen = pSeq->nElements;
+ if (nLen)
+ {
+ printf( "{ " );
+ for ( sal_Int32 nPos = 0; nPos < nLen; ++nPos )
+ {
+ printValue( Any( ((char *)pSeq->elements) + (nPos * pElemTD->nSize), pElemTD ) );
+ if (nPos < (nLen-1))
+ printf( ", " );
+ }
+ printf( " }" );
+ }
+
+ TYPELIB_DANGER_RELEASE( pElemTD );
+ TYPELIB_DANGER_RELEASE( pSeqTD );
+ break;
+ }
+
+ default:
+ printf( ">not printable<" );
+ break;
+ }
+}
+
+static Reference< XTypeConverter > s_xConverter;
+
+//==================================================================================================
+static sal_Bool convertTo( const Type & rDestType, const Any & rVal, sal_Bool bExpectSuccess )
+{
+ sal_Bool bCanConvert = sal_False;
+ Any aRet;
+
+ OString aExcMsg;
+
+ try
+ {
+ aRet = s_xConverter->convertTo( rVal, rDestType );
+ bCanConvert = sal_True;
+ }
+ catch (Exception & rExc)
+ {
+ aExcMsg = OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US );
+ }
+
+ if (bExpectSuccess && !bCanConvert)
+ {
+ printf( "# conversion of " );
+ printValue( rVal );
+ printf( " to " );
+ printf( OUStringToOString(rDestType.getTypeName(), RTL_TEXTENCODING_ASCII_US).getStr() );
+ printf( " failed, but success was expected! [" );
+ printf( aExcMsg.getStr() );
+ printf( "]\n" );
+ return sal_False;
+ }
+ if (!bExpectSuccess && bCanConvert)
+ {
+ printf( "# conversion of " );
+ printValue( rVal );
+ printf( " to " );
+ printValue( aRet );
+ printf( " was successful, but was not expected to be!\n" );
+ return sal_False;
+ }
+
+#ifdef __MAG_MARKUS_NICHT___EXTRA_AUSGABEN__
+//= re-conversion output =
+ if (bCanConvert)
+ {
+ // re convert to original type
+ sal_Bool bReConvert = sal_False;
+ Any aRet2;
+
+ try
+ {
+ aRet2 = s_xConverter->convertTo( aRet, rVal.getValueType() );
+ bReConvert = sal_True;
+ }
+ catch (Exception & rExc)
+ {
+ aExcMsg = OUStringToOString( rExc.Message, RTL_TEXTENCODING_ISO_8859_1 );
+ }
+
+ if (bReConvert)
+ {
+ if (rVal != aRet2)
+ {
+ printf( "# re-conversion of " );
+ printValue( rVal );
+ printf( " to " );
+ printValue( aRet );
+ printf( " to " );
+ printValue( aRet2 );
+ printf( ": first and last do not match!\n" );
+ }
+ }
+ else
+ {
+ printf( "# re-conversion of " );
+ printValue( aRet );
+ printf( " to " );
+ printf( rVal.getValueType().getTypeName().getStr() );
+ printf( " failed! [" );
+ printf( aExcMsg.getStr() );
+ printf( "]\n" );
+ }
+ }
+#endif
+
+ return sal_True;
+}
+
+
+//==================================================================================================
+typedef struct _ConvBlock
+{
+ Any _value;
+ sal_Bool _toString, _toDouble, _toFloat;
+ sal_Bool _toUINT32, _toINT32, _toUINT16, _toINT16, _toBYTE, _toBOOL, _toChar;
+ sal_Bool _toTypeClass, _toSeqINT16, _toSeqAny;
+
+ _ConvBlock()
+ {
+ }
+ _ConvBlock( const Any & rValue_,
+ sal_Bool toString_, sal_Bool toDouble_, sal_Bool toFloat_,
+ sal_Bool toUINT32_, sal_Bool toINT32_, sal_Bool toUINT16_, sal_Bool toINT16_,
+ sal_Bool toBYTE_, sal_Bool toBOOL_, sal_Bool toChar_,
+ sal_Bool toTypeClass_, sal_Bool toSeqINT16_, sal_Bool toSeqAny_ )
+ : _value( rValue_ )
+ , _toString( toString_ ), _toDouble( toDouble_ ), _toFloat( toFloat_ )
+ , _toUINT32( toUINT32_ ), _toINT32( toINT32_ ), _toUINT16( toUINT16_ ), _toINT16( toINT16_ )
+ , _toBYTE( toBYTE_ ), _toBOOL( toBOOL_ ), _toChar( toChar_ )
+ , _toTypeClass( toTypeClass_ ), _toSeqINT16( toSeqINT16_ ), _toSeqAny( toSeqAny_ )
+ {
+ }
+} ConvBlock;
+
+
+//==================================================================================================
+static sal_Int32 initBlocks( ConvBlock * pTestBlocks )
+{
+ Any aVal;
+
+ sal_uInt32 nElems = 0;
+
+ // ==BYTE==
+ aVal <<= OUString::createFromAscii( "0xff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "255" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_Int8)0xff;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "0x80" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "128" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_Int8)( 0x80 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "0x7f" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "127" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_Int8)( 0x7f );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "5" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "+5" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_Int8)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "-5" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int8)( -5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "256" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==UINT16==
+ aVal <<= OUString::createFromAscii( "65535" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0xffff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt16)( 0xffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "32768" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt16)( 0x8000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "32767" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0x7fff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt16)( 0x7fff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "256" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0x100" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt16)( 0x100 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt16)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt16)( -5 ); // is 0xfffb
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==INT16==
+ aVal <<= (sal_Int16)( -1 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( -0x8000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( 0x7fff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( 0x100 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( -5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==UINT32==
+ aVal <<= OUString::createFromAscii( "+4294967295" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "4294967295" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0xffffffff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt32)( 0xffffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "-2147483648" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "-0x80000000" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt32)( 0x80000000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "2147483647" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0x7fffffff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt32)( 0x7fffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "65536" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0x10000" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt32)( 0x10000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt32)( 0x8000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt32)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "0xfffffffb" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt32)( -5 ); // is 0xfffffffb
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==INT32==
+ aVal <<= (sal_Int32)( 0xffffffff ); // is -1
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( -0x80000000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( 0x7fffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( 0x10000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( -0x8001 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( -5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==FLOAT==
+ aVal <<= OUString::createFromAscii( "-3.4e+38" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( MIN_FLOAT );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "+3.4e+38" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( MAX_FLOAT );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "9e-20" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( 9e-20 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "+.7071067811865" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( .7071067811865 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "3.14159265359" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( 3.14159265359 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (float)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==DOUBLE==
+ aVal <<= OUString::createFromAscii( "-1.7976931348623158e+308" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (double)( MIN_DOUBLE );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "1.7976931348623158e+308" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (double)( MAX_DOUBLE );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( MIN_FLOAT );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( MAX_FLOAT );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( -((double)0x80000000) );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( -((double)0x80000001) );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( 0x7fffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( 0x80000000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( 0xffffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "0x100000000" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+#ifndef OS2
+ aVal <<= (double)( 0x100000000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+#endif
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==CHAR==
+ sal_Unicode c = 'A';
+ aVal.setValue( &c, ::getCharCppuType() );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "A" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==BOOL==
+ aVal <<= OUString::createFromAscii( "0" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "1" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "False" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "true" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+
+ sal_Bool bTmp = sal_True;
+ aVal.setValue( &bTmp, getBooleanCppuType() );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==ZERO STRINGS==
+ aVal <<= OUString();
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "-" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "-0" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==TYPECLASS ENUM==
+ aVal <<= OUString::createFromAscii( "eNuM" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "DOUBLE" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ int e = 1;
+ aVal.setValue( &e, ::getCppuType( (const TypeClass *)0 ) );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal.setValue( &e, ::getCppuType( (const FieldAccessMode *)0 ) );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==SEQ of INT==
+ Sequence< sal_Int32 > aINT32Seq( 3 ), aINT32Seq2( 3 );
+ sal_Int32 * pINT32Seq = aINT32Seq.getArray();
+ pINT32Seq[0] = -32768;
+ pINT32Seq[1] = 0;
+ pINT32Seq[2] = 32767;
+ aVal <<= aINT32Seq;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ pINT32Seq = aINT32Seq2.getArray();
+ pINT32Seq[0] = -32768;
+ pINT32Seq[1] = -32769;
+ pINT32Seq[2] = 32767;
+ aVal <<= aINT32Seq2;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==SEQ of ANY==
+ Sequence< Any > aAnySeq( 2 ), aAnySeq2( 2 ), aAnySeq3( 2 );
+ Any * pAnySeq = aAnySeq.getArray();
+ pAnySeq[0] = makeAny( aINT32Seq );
+ pAnySeq[1] = makeAny( OUString::createFromAscii("lala") );
+ aVal <<= aAnySeq;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ pAnySeq = aAnySeq2.getArray();
+ pAnySeq[0] <<= (sal_Int32)4711;
+ pAnySeq[1] <<= OUString::createFromAscii("0815");
+ aVal <<= aAnySeq2;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ pAnySeq = aAnySeq3.getArray();
+ pAnySeq[0] <<= OUString::createFromAscii("TypeClass_UNION");
+ pAnySeq[1] <<= OUString::createFromAscii("TypeClass_ENUM");
+ aVal <<= aAnySeq3;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ return nElems;
+}
+
+//==================================================================================================
+static void test_Conversion( const Reference< XMultiServiceFactory > & xMgr )
+{
+ printf( "test_Conversion(): start...\n" );
+
+ Reference< XTypeConverter > xConverter( xMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.script.Converter" ) ), UNO_QUERY );
+
+ ConvBlock * pTestBlocks = new ConvBlock[256];
+ sal_Int32 nPos = initBlocks( pTestBlocks );
+
+ s_xConverter = xConverter;
+ while (nPos--)
+ {
+ const ConvBlock& rBlock = pTestBlocks[nPos];
+ const Any & rVal = rBlock._value;
+
+ convertTo( ::getCppuType( (const OUString *)0 ), rVal, rBlock._toString );
+ convertTo( ::getCppuType( (const float *)0 ), rVal, rBlock._toFloat );
+ convertTo( ::getCppuType( (const double *)0 ), rVal, rBlock._toDouble );
+ convertTo( ::getCppuType( (const sal_uInt32 *)0 ), rVal, rBlock._toUINT32 );
+ convertTo( ::getCppuType( (const sal_Int32 *)0 ), rVal, rBlock._toINT32 );
+ convertTo( ::getCppuType( (const sal_uInt16 *)0 ), rVal, rBlock._toUINT16 );
+ convertTo( ::getCppuType( (const sal_Int16 *)0 ), rVal, rBlock._toINT16 );
+ convertTo( ::getCppuType( (const sal_Int8 *)0 ), rVal, rBlock._toBYTE );
+ convertTo( ::getBooleanCppuType(), rVal, rBlock._toBOOL );
+ convertTo( ::getCharCppuType(), rVal, rBlock._toChar );
+ convertTo( ::getCppuType( (const TypeClass *)0 ), rVal, rBlock._toTypeClass );
+ convertTo( ::getCppuType( (const Sequence< sal_Int16 > *)0 ), rVal, rBlock._toSeqINT16 );
+ convertTo( ::getCppuType( (const Sequence< Any > *)0 ), rVal, rBlock._toSeqAny );
+
+ convertTo( ::getVoidCppuType(), rVal, sal_True ); // anything converts to void
+ }
+ s_xConverter.clear();
+
+ delete [] pTestBlocks;
+
+ Any aRet;
+ aRet = xConverter->convertTo( Any( &xMgr, ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ) ),
+ ::getCppuType( (const Reference< XServiceInfo > *)0 ) );
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ) );
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const Reference< XServiceInfo > *)0 ) );
+ aRet <<= (sal_Int64)0x7fffffffffffffff;
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const sal_uInt64 *)0 ) );
+ OSL_ASSERT( *(const sal_uInt64 *)aRet.getValue() == (sal_uInt64)0x7fffffffffffffff );
+ aRet <<= (sal_uInt64)0xffffffffffffffff;
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const sal_uInt64 *)0 ) );
+ OSL_ASSERT( *(const sal_uInt64 *)aRet.getValue() == (sal_uInt64)0xffffffffffffffff );
+ aRet <<= (sal_Int64)0xffffffffffffffff;
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const sal_Int8 *)0 ) );
+ OSL_ASSERT( *(const sal_Int8 *)aRet.getValue() == (-1) );
+ printf( "test_Conversion(): end.\n" );
+}
+
+
+#ifdef UNX
+#define REG_PREFIX "lib"
+#define DLL_POSTFIX ".so"
+#else
+#define REG_PREFIX ""
+#define DLL_POSTFIX ".dll"
+#endif
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int __cdecl main( int argc, char * argv[] )
+#endif
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory( OUString::createFromAscii("stoctest.rdb") ) );
+
+ try
+ {
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstance( OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration") ), UNO_QUERY );
+ OSL_ENSHURE( xImplReg.is(), "### no impl reg!" );
+
+ OUString aLibName( OUString::createFromAscii( REG_PREFIX ) );
+ aLibName += OUString::createFromAscii("tcv");
+#ifndef OS2
+ aLibName += OUString::createFromAscii( DLL_POSTFIX );
+#endif
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ aLibName, Reference< XSimpleRegistry >() );
+
+ test_Conversion( xMgr );
+ }
+ catch (Exception & rExc)
+ {
+ OSL_ENSHURE( sal_False, "### exception occured!" );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### exception occured: " );
+ OSL_TRACE( aMsg.getStr() );
+ OSL_TRACE( "\n" );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+ return 0;
+}
diff --git a/stoc/test/testcorefl.cxx b/stoc/test/testcorefl.cxx
new file mode 100644
index 000000000000..d5d4287a2270
--- /dev/null
+++ b/stoc/test/testcorefl.cxx
@@ -0,0 +1,439 @@
+/*************************************************************************
+ *
+ * $RCSfile: testcorefl.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <osl/diagnose.h>
+
+#ifdef _DEBUG
+#define TEST_ENSHURE(c, m) OSL_ENSHURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) OSL_VERIFY(c)
+#endif
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <ModuleA/XInterface1.hpp>
+#include <ModuleC/XInterfaceA.hpp>
+#include <ModuleC/XInterfaceB.hpp>
+#include <ModuleC/ModuleC.hpp>
+
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <stdio.h>
+
+
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+using namespace ModuleA;
+using namespace ModuleB;
+using namespace ModuleC;
+using namespace ModuleA::ModuleB;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::container;
+
+
+//==================================================================================================
+class OInterfaceA : public WeakImplHelper1< XInterfaceA >
+{
+public:
+
+ virtual void SAL_CALL methodA(void)
+ {}
+
+ virtual void SAL_CALL methodB(sal_Int16 aShort)
+ {}
+ virtual Sequence< StructB > SAL_CALL methodC(const StructC& aStructC, StructA& aStructA)
+ { return Sequence< StructB >(); }
+};
+
+//==================================================================================================
+static inline uik_equals( const Uik & rUik1, const Uik & rUik2 )
+{
+ return (rUik1.m_Data1 == rUik2.m_Data1 &&
+ rUik1.m_Data2 == rUik2.m_Data2 &&
+ rUik1.m_Data3 == rUik2.m_Data3 &&
+ rUik1.m_Data4 == rUik2.m_Data4 &&
+ rUik1.m_Data5 == rUik2.m_Data5);
+}
+//==================================================================================================
+static sal_Bool test_corefl( const Reference< XIdlReflection > & xRefl )
+{
+ Reference< XIdlClass > xClass;
+ Reference< XHierarchicalNameAccess > xHNameAccess( xRefl, UNO_QUERY );
+ TEST_ENSHURE(xHNameAccess.is(), "### cannot get XHierarchicalNameAccess!" );
+
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.StructA"))->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 2b");
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.ExceptionB"))->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 2c");
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA")).is(), "test_RegCoreReflection(): error 2e");
+ // const
+
+ TEST_ENSHURE(*(const sal_Bool *)xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstBoolean")).getValue() == aConstBoolean, "test_RegCoreReflection(): error 4c");
+ TEST_ENSHURE(*(const sal_Int8 *)xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstByte")).getValue() == aConstByte, "test_RegCoreReflection(): error 4e");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstShort")) == aConstShort, "test_RegCoreReflection(): error 4g");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstUShort")) == aConstUShort, "test_RegCoreReflection(): error 4i");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstLong")) == aConstLong, "test_RegCoreReflection(): error 4k");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstULong")) == aConstULong, "test_RegCoreReflection(): error 4m");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstFloat")) == aConstFloat, "test_RegCoreReflection(): error 4o");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstDouble")) == aConstDouble, "test_RegCoreReflection(): error 4q");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstString")) == aConstString, "test_RegCoreReflection(): error 4s");
+
+ // Enums
+
+ xClass = xRefl->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA"));
+
+ TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 5");
+
+ Sequence<Reference< XIdlField > > fields = xClass->getFields();
+
+ TEST_ENSHURE(
+ (fields.getLength() == 3) &&
+ (fields.getArray()[0]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_1") )) &&
+ (*(EnumA*)fields.getArray()[0]->get(Any()).getValue() == EnumA_VAL_1) &&
+ (fields.getArray()[1]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_2") )) &&
+ (*(EnumA*)fields.getArray()[1]->get(Any()).getValue() == EnumA_VAL_2) &&
+ (fields.getArray()[2]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_3") )) &&
+ (*(EnumA*)fields.getArray()[2]->get(Any()).getValue() == EnumA_VAL_3),
+ "test_RegCoreReflection(): error 6");
+
+
+ // Interface
+
+ Reference< XIdlClass > xA = xRefl->forName( OUString::createFromAscii("ModuleC.XInterfaceB") );
+
+ xClass = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceB"));
+
+ TEST_ENSHURE(xClass == xA, "test_RegCoreReflection(): error 7");
+ TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 7a");
+
+ typelib_TypeDescription * pTD = 0;
+ OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM("ModuleC.XInterfaceB") );
+ typelib_typedescription_getByName( &pTD, aModuleName.pData );
+ TEST_ENSHURE( pTD, "### cannot get typedescription for ModuleC.XInterfaceB!" );
+
+ TEST_ENSHURE( uik_equals( *(Uik *)&((typelib_InterfaceTypeDescription *)pTD)->aUik,
+ xClass->getUik() ),
+ "test_RegCoreReflection(): error 8" );
+ typelib_typedescription_release( pTD );
+
+ TEST_ENSHURE(xClass->getSuperclasses().getLength() == 1, "test_RegCoreReflection(): error 9");
+ TEST_ENSHURE(xClass->getSuperclasses().getArray()[0]->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 10");
+ TEST_ENSHURE(xClass->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11");
+ TEST_ENSHURE(xA->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[3]->getName() == OUString::createFromAscii("methodA"), "test_RegCoreReflection(): 12");
+ TEST_ENSHURE(xClass->getMethods().getArray()[3]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 13");
+ TEST_ENSHURE(xClass->getMethods().getArray()[3]->getParameterTypes().getLength() == 0, "test_RegCoreReflection(): error 14");
+ TEST_ENSHURE(xClass->getMethods().getArray()[3]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 15");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("methodB") ), "test_RegCoreReflection(): error 16");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getMode() == MethodMode_ONEWAY, "test_RegCoreReflection(): error 16a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 16");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 17");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_SHORT, "test_RegCoreReflection(): error 18");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aName == OUString( RTL_CONSTASCII_USTRINGPARAM("aShort") ), "test_RegCoreReflection(): error 18a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aType == xRefl->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("short") ) ), "test_RegCoreReflection(): error 18b");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aMode == ParamMode_IN, "test_RegCoreReflection(): error 18c");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 19");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getName() == OUString::createFromAscii("methodC"), "test_RegCoreReflection(): error 20");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getMode() == MethodMode_TWOWAY, "test_RegCoreReflection(): error 20a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 21");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 22");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructB"), "test_RegCoreReflection(): error 23");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getLength() == 2, "test_RegCoreReflection(): error 24");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 25");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 26");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 27");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 28");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 29");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getName() == OUString::createFromAscii("methodD"), "test_RegCoreReflection(): error 30");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getReturnType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 31");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getReturnType()->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 32");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 33");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_ENUM, "test_RegCoreReflection(): error 34");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ModuleB.EnumA"), "test_RegCoreReflection(): error 35");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getLength() == 3, "test_RegCoreReflection(): error 36");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 37");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ExceptionA"), "test_RegCoreReflection(): error 38");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 38");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.ExceptionB"), "test_RegCoreReflection(): error 39");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 40");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getName() == OUString::createFromAscii("ModuleA.ExceptionC"), "test_RegCoreReflection(): error 41");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getLength() == 3, "test_RegCoreReflection(): error 42");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getTypeClass() == TypeClass_BOOLEAN, "test_RegCoreReflection(): error 43");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getName() == OUString::createFromAscii("boolean"), "test_RegCoreReflection(): error 43a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 44");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 45");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 46");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getName() == OUString::createFromAscii("ModuleA.XInterface1"), "test_RegCoreReflection(): error 47");
+
+ // SequenceReflections
+
+ TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 48");
+ TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getComponentType().is(), "test_RegCoreReflection(): error 49");
+ TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[][]ModuleA.StructA") )->getComponentType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 50");
+ TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]com.sun.star.uno.XInterface") ) == xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructC") ))->getField(OUString::createFromAscii("aInterfaceSeq"))->getType(), "test_RegCoreReflection(): error 51");
+
+ StructC aStructC;
+ aStructC.aLong = aConstLong;
+ aStructC.aShort = aConstShort;
+ aStructC.aFloat = aConstFloat;
+ aStructC.aDouble = aConstDouble;
+ aStructC.aString = aConstString;
+ aStructC.aInterfaceSeq = Sequence<Reference<XInterface > >();
+
+ Any aAny;
+
+ xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aInterfaceSeq"))->getType()->createObject(aAny);
+
+ TEST_ENSHURE(aAny.getValueType() == ::getCppuType( (const Sequence<Reference< XInterface > > *)0 ), "test_RegCoreReflection(): error 51a");
+
+ Any aStructAny(&aStructC, ::getCppuType( (const StructC *) 0 ));
+
+ sal_Int32 nLong = aConstLong * 2;
+ aAny.setValue( &nLong, ::getCppuType( (const sal_Int32 *)0 ) );
+
+ TEST_ENSHURE(*(sal_Int32*)xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructA") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->get(
+ Any(&aStructC, ::getCppuType( (const StructC *)0 ))).getValue() == aConstLong, "test_RegCoreReflection(): error 52");
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.StructA"))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->getAccessMode() == FieldAccessMode_READWRITE, "test_RegCoreReflection(): error 52a");
+ xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructC") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->set(aStructAny, aAny);
+ TEST_ENSHURE(*(sal_Int32*)xRefl->forName(OUString::createFromAscii("ModuleA.StructB"))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->get(aStructAny).getValue() == *(sal_Int32*)aAny.getValue(), "test_RegCoreReflection(): error 53");
+
+ xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->createObject(aAny);
+
+ TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("[]ModuleA.StructA")), "test_RegCoreReflection(): error 54");
+ xRefl->forName(OUString::createFromAscii("[][]ModuleA.StructA"))->createObject(aAny);
+
+ TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[][]ModuleA.StructA") ), "test_RegCoreReflection(): error 56");
+
+// xClass = xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.XIntroTest") ));
+
+// TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 58");
+// TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 59");
+// TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("string"), "test_RegCoreReflection(): error 60");
+
+// xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->createObject(aAny);
+// TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[]string") ), "test_RegCoreReflection(): error 61");
+
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("[][][]unsigned long"))->getComponentType()->getComponentType()->getComponentType()->getTypeClass() == TypeClass_UNSIGNED_LONG, "test_RegCoreReflection(): error 62");
+
+ try
+ {
+ Any bla = xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->get(Any());
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 63");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ try
+ {
+ Any blup;
+ blup <<= aStructC;
+ Any gulp;
+ xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 64");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ try
+ {
+ Any gulp;
+ gulp <<= 3.14f;
+ Any blup;
+ blup <<= aStructC;
+ xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 65");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ Any gulp;
+ gulp <<= OUString(OUString::createFromAscii("Test"));
+ Any blup;
+ blup <<= aStructC;
+ xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
+
+ Reference< XInterfaceA > xAI = new OInterfaceA();
+
+ try
+ {
+ Sequence< Any > params;
+
+ Any a;
+ a <<= xAI;
+ Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params);
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 66");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ StructA aStructA;
+
+ {
+ Sequence< Any > params(2);
+
+ params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
+ params.getArray()[1].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
+
+ Any a;
+ a <<= xAI;
+ Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params);
+ }
+ try
+ {
+ Sequence< Any > params(2);
+
+ params.getArray()[0].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
+ params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
+
+ Any a;
+ a <<= xAI;
+ Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params);
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 67");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ Sequence< Any > params(2);
+
+ params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
+ params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
+
+ Any a;
+ a <<= xAI;
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params).getValueType()
+ == ::getCppuType( (const Sequence<StructB> *)0 ), "test_RegCoreReflection(): error 68");
+
+ return sal_True;
+}
+
+#ifdef UNX
+#define REG_PREFIX "lib"
+#define DLL_POSTFIX ".so"
+#else
+#define REG_PREFIX ""
+#define DLL_POSTFIX ".dll"
+#endif
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int __cdecl main( int argc, char * argv[] )
+#endif
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
+
+ sal_Bool bSucc = sal_False;
+ try
+ {
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.ImplementationRegistration") ) ), UNO_QUERY );
+ OSL_ENSHURE( xImplReg.is(), "### no impl reg!" );
+
+ OUString aLibName( OUString::createFromAscii(REG_PREFIX) );
+ aLibName += OUString::createFromAscii("corefl");
+#ifndef OS2
+ aLibName += OUString::createFromAscii(DLL_POSTFIX);
+#endif
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), aLibName, Reference< XSimpleRegistry >() );
+
+ Reference< XIdlReflection > xRefl( xMgr->createInstance( OUString::createFromAscii("com.sun.star.reflection.CoreReflection") ), UNO_QUERY );
+ OSL_ENSHURE( xRefl.is(), "### no corereflection!" );
+
+ bSucc = test_corefl( xRefl );
+ }
+ catch (Exception & rExc)
+ {
+ OSL_ENSHURE( sal_False, "### exception occured!" );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### exception occured: " );
+ OSL_TRACE( aMsg.getStr() );
+ OSL_TRACE( "\n" );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+
+ printf( "testcorefl %s !\n", (bSucc ? "succeeded" : "failed") );
+ return (bSucc ? 0 : -1);
+}
diff --git a/stoc/test/testcorefl.idl b/stoc/test/testcorefl.idl
new file mode 100644
index 000000000000..317a39b1743d
--- /dev/null
+++ b/stoc/test/testcorefl.idl
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * $RCSfile: testcorefl.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <com/sun/star/uno/XInterface.idl>
+
+module ModuleA
+{
+ exception ExceptionA
+ {
+ boolean aBoolean;
+ };
+
+ struct StructA
+ {
+ long aLong;
+ short aShort;
+ };
+
+ struct StructB : StructA
+ {
+ double aDouble;
+ float aFloat;
+ };
+
+ struct StructC : StructB
+ {
+ string aString;
+ sequence<com::sun::star::uno::XInterface> aInterfaceSeq;
+ };
+
+ exception ExceptionB : ExceptionA
+ {
+ StructC aStructC;
+ };
+
+ [ uik(e227a3A1-33d6-12d1-aabe02a0-249d5590), ident("InterfaceB", 1.0) ]
+ interface XInterface1 : com::sun::star::uno::XInterface
+ {
+ };
+
+ exception ExceptionC : ExceptionB
+ {
+ XInterface1 aInterface1;
+ };
+
+ module ModuleB
+ {
+ enum EnumA { VAL_1, VAL_2, VAL_3 = 17};
+ };
+
+};
+
+module ModuleC
+{
+ const boolean aConstBoolean = True;
+ const byte aConstByte = 0;
+ const short aConstShort = -1;
+ const unsigned short aConstUShort = 1;
+ const long aConstLong = -2;
+ const unsigned long aConstULong = 2;
+// const hyper aConstHyper = -3;
+// const unsigned hyper aConstUHyper = 3;
+ const float aConstFloat = 3.14;
+ const double aConstDouble = 3.14e-10;
+ const string aConstString = "test";
+
+
+ [ uik(e227a3A0-33d6-11d1-aabe02a0-249d5590), ident("InterfaceA", 1.0) ]
+ interface XInterfaceA : com::sun::star::uno::XInterface
+ {
+ void methodA();
+ [oneway] void methodB([in] short aShort);
+ sequence<ModuleA::StructB> methodC([in] ModuleA::StructC aStructC, [inout] ModuleA::StructA aStructA);
+ };
+
+ [ uik(e227a3A1-33d6-11d1-aabe02a0-12345678), ident("InterfaceB", 1.0) ]
+ interface XInterfaceB : XInterfaceA
+ {
+ [attribute] string aString;
+
+ XInterfaceA methodD([in] ModuleA::ModuleB::EnumA aEnumA) raises (ModuleA::ExceptionA, ModuleA::ExceptionB, ModuleA::ExceptionC);
+ };
+};
diff --git a/stoc/test/testiadapter.cxx b/stoc/test/testiadapter.cxx
new file mode 100644
index 000000000000..40101cacac3b
--- /dev/null
+++ b/stoc/test/testiadapter.cxx
@@ -0,0 +1,1029 @@
+/*************************************************************************
+ *
+ * $RCSfile: testiadapter.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#include <osl/diagnose.h>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/weak.hxx>
+
+#include <test/XLanguageBindingTest.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/script/XInvocationAdapterFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+
+
+using namespace test;
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::script;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+
+//==================================================================================================
+sal_Bool equals( const test::TestElement & rData1, const test::TestElement & rData2 )
+{
+ OSL_ENSHURE( rData1.Bool == rData2.Bool, "### bool does not match!" );
+ OSL_ENSHURE( rData1.Char == rData2.Char, "### char does not match!" );
+ OSL_ENSHURE( rData1.Byte == rData2.Byte, "### byte does not match!" );
+ OSL_ENSHURE( rData1.Short == rData2.Short, "### short does not match!" );
+ OSL_ENSHURE( rData1.UShort == rData2.UShort, "### unsigned short does not match!" );
+ OSL_ENSHURE( rData1.Long == rData2.Long, "### long does not match!" );
+ OSL_ENSHURE( rData1.ULong == rData2.ULong, "### unsigned long does not match!" );
+ OSL_ENSHURE( rData1.Hyper == rData2.Hyper, "### hyper does not match!" );
+ OSL_ENSHURE( rData1.UHyper == rData2.UHyper, "### unsigned hyper does not match!" );
+ OSL_ENSHURE( rData1.Float == rData2.Float, "### float does not match!" );
+ OSL_ENSHURE( rData1.Double == rData2.Double, "### double does not match!" );
+ OSL_ENSHURE( rData1.Enum == rData2.Enum, "### enum does not match!" );
+ OSL_ENSHURE( rData1.String == rData2.String, "### string does not match!" );
+ OSL_ENSHURE( rData1.Interface == rData2.Interface, "### interface does not match!" );
+ OSL_ENSHURE( rData1.Any == rData2.Any, "### any does not match!" );
+
+ return (rData1.Bool == rData2.Bool &&
+ rData1.Char == rData2.Char &&
+ rData1.Byte == rData2.Byte &&
+ rData1.Short == rData2.Short &&
+ rData1.UShort == rData2.UShort &&
+ rData1.Long == rData2.Long &&
+ rData1.ULong == rData2.ULong &&
+ rData1.Hyper == rData2.Hyper &&
+ rData1.UHyper == rData2.UHyper &&
+ rData1.Float == rData2.Float &&
+ rData1.Double == rData2.Double &&
+ rData1.Enum == rData2.Enum &&
+ rData1.String == rData2.String &&
+ rData1.Interface == rData2.Interface &&
+ rData1.Any == rData2.Any);
+}
+//==================================================================================================
+sal_Bool equals( const test::TestData & rData1, const test::TestData & rData2 )
+{
+ sal_Int32 nLen;
+
+ if ((rData1.Sequence == rData2.Sequence) &&
+ equals( (const test::TestElement &)rData1, (const test::TestElement &)rData2 ) &&
+ (nLen = rData1.Sequence.getLength()) == rData2.Sequence.getLength())
+ {
+ // once again by hand sequence ==
+ const test::TestElement * pElements1 = rData1.Sequence.getConstArray();
+ const test::TestElement * pElements2 = rData2.Sequence.getConstArray();
+ for ( ; nLen--; )
+ {
+ if (! equals( pElements1[nLen], pElements2[nLen] ))
+ {
+ OSL_ENSHURE( sal_False, "### sequence element did not match!" );
+ return sal_False;
+ }
+ }
+ return sal_True;
+ }
+ return sal_False;
+}
+//==================================================================================================
+void assign( test::TestElement & rData,
+ sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny )
+{
+ rData.Bool = bBool;
+ rData.Char = cChar;
+ rData.Byte = nByte;
+ rData.Short = nShort;
+ rData.UShort = nUShort;
+ rData.Long = nLong;
+ rData.ULong = nULong;
+ rData.Hyper = nHyper;
+ rData.UHyper = nUHyper;
+ rData.Float = fFloat;
+ rData.Double = fDouble;
+ rData.Enum = eEnum;
+ rData.String = rStr;
+ rData.Interface = xTest;
+ rData.Any = rAny;
+}
+//==================================================================================================
+void assign( test::TestData & rData,
+ sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny,
+ const com::sun::star::uno::Sequence< test::TestElement >& rSequence )
+{
+ assign( (test::TestElement &)rData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, xTest, rAny );
+ rData.Sequence = rSequence;
+}
+
+//==================================================================================================
+class Test_Impl : public WeakImplHelper1< XLanguageBindingTest >
+{
+ test::TestData _aData, _aStructData;
+
+public:
+ virtual ~Test_Impl()
+ { OSL_TRACE( "> scalar Test_Impl dtor <\n" ); }
+
+ // XLBTestBase
+ virtual void SAL_CALL setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny,
+ const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ const test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException);
+
+ virtual test::TestData SAL_CALL setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException);
+
+ virtual test::TestData SAL_CALL getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence< test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL getBool() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Bool; }
+ virtual sal_Int8 SAL_CALL getByte() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Byte; }
+ virtual sal_Unicode SAL_CALL getChar() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Char; }
+ virtual sal_Int16 SAL_CALL getShort() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Short; }
+ virtual sal_uInt16 SAL_CALL getUShort() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.UShort; }
+ virtual sal_Int32 SAL_CALL getLong() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Long; }
+ virtual sal_uInt32 SAL_CALL getULong() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.ULong; }
+ virtual sal_Int64 SAL_CALL getHyper() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Hyper; }
+ virtual sal_uInt64 SAL_CALL getUHyper() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.UHyper; }
+ virtual float SAL_CALL getFloat() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Float; }
+ virtual double SAL_CALL getDouble() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Double; }
+ virtual test::TestEnum SAL_CALL getEnum() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Enum; }
+ virtual rtl::OUString SAL_CALL getString() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.String; }
+ virtual com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getInterface( ) throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Interface; }
+ virtual com::sun::star::uno::Any SAL_CALL getAny() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Any; }
+ virtual com::sun::star::uno::Sequence< test::TestElement > SAL_CALL getSequence() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Sequence; }
+ virtual test::TestData SAL_CALL getStruct() throw(com::sun::star::uno::RuntimeException)
+ { return _aStructData; }
+
+ virtual void SAL_CALL setBool( sal_Bool _bool ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Bool = _bool; }
+ virtual void SAL_CALL setByte( sal_Int8 _byte ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Byte = _byte; }
+ virtual void SAL_CALL setChar( sal_Unicode _char ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Char = _char; }
+ virtual void SAL_CALL setShort( sal_Int16 _short ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Short = _short; }
+ virtual void SAL_CALL setUShort( sal_uInt16 _ushort ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.UShort = _ushort; }
+ virtual void SAL_CALL setLong( sal_Int32 _long ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Long = _long; }
+ virtual void SAL_CALL setULong( sal_uInt32 _ulong ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.ULong = _ulong; }
+ virtual void SAL_CALL setHyper( sal_Int64 _hyper ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Hyper = _hyper; }
+ virtual void SAL_CALL setUHyper( sal_uInt64 _uhyper ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.UHyper = _uhyper; }
+ virtual void SAL_CALL setFloat( float _float ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Float = _float; }
+ virtual void SAL_CALL setDouble( double _double ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Double = _double; }
+ virtual void SAL_CALL setEnum( test::TestEnum _enum ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Enum = _enum; }
+ virtual void SAL_CALL setString( const ::rtl::OUString& _string ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.String = _string; }
+ virtual void SAL_CALL setInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _interface ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Interface = _interface; }
+ virtual void SAL_CALL setAny( const ::com::sun::star::uno::Any& _any ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Any = _any; }
+ virtual void SAL_CALL setSequence( const ::com::sun::star::uno::Sequence<test::TestElement >& _sequence ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Sequence = _sequence; }
+ virtual void SAL_CALL setStruct( const test::TestData& _struct ) throw(::com::sun::star::uno::RuntimeException)
+ { _aStructData = _struct; }
+
+ // XLanguageBindingTest
+ virtual test::TestData SAL_CALL raiseException( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, sal_Int16& nShort, sal_uInt16& nUShort, sal_Int32& nLong, sal_uInt32& nULong, sal_Int64& nHyper, sal_uInt64& nUHyper, float& fFloat, double& fDouble, test::TestEnum& eEnum, ::rtl::OUString& aString, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInterface, ::com::sun::star::uno::Any& aAny, ::com::sun::star::uno::Sequence<test::TestElement >& aSequence,test::TestData& aStruct )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getRuntimeException() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRuntimeException( sal_Int32 _runtimeexception ) throw(::com::sun::star::uno::RuntimeException);
+};
+//==================================================================================================
+class XLB_Invocation : public WeakImplHelper1< XInvocation >
+{
+ Reference< XLanguageBindingTest > _xLBT;
+
+public:
+ XLB_Invocation( const Reference< XMultiServiceFactory > & xMgr,
+ const Reference< XLanguageBindingTest > & xLBT )
+ : _xLBT( xLBT )
+ {}
+
+ // XInvocation
+ virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() throw(::com::sun::star::uno::RuntimeException)
+ { return Reference< XIntrospectionAccess >(); }
+ virtual Any SAL_CALL invoke( const OUString & rFunctionName,
+ const Sequence< Any > & rParams,
+ Sequence< sal_Int16 > & rOutParamIndex,
+ Sequence< Any > & rOutParam ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const OUString & rPropertyName, const Any & rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual Any SAL_CALL getValue( const OUString & rPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasProperty( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+};
+//__________________________________________________________________________________________________
+Any XLB_Invocation::invoke( const OUString & rFunctionName,
+ const Sequence< Any > & rParams,
+ Sequence< sal_Int16 > & rOutParamIndex,
+ Sequence< Any > & rOutParam )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ Any aRet;
+
+ OSL_ASSERT( rOutParam.getLength() == 0 );
+ OSL_ASSERT( rOutParamIndex.getLength() == 0 );
+
+ try
+ {
+ sal_Bool aBool;
+ sal_Unicode aChar;
+ sal_Int8 nByte;
+ sal_Int16 nShort;
+ sal_uInt16 nUShort;
+ sal_Int32 nLong;
+ sal_uInt32 nULong;
+ sal_Int64 nHyper;
+ sal_uInt64 nUHyper;
+ float fFloat;
+ double fDouble;
+ TestEnum eEnum;
+ OUString aString;
+ Reference< XInterface > xInterface;
+ Any aAny;
+ Sequence< TestElement > aSeq;
+ TestData aData;
+
+ if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues") ))
+ {
+ OSL_ASSERT( rParams.getLength() == 17 );
+ aBool = *(sal_Bool *)rParams[0].getValue();
+ aChar = *(sal_Unicode *)rParams[1].getValue();
+ rParams[2] >>= nByte;
+ rParams[3] >>= nShort;
+ rParams[4] >>= nUShort;
+ rParams[5] >>= nLong;
+ rParams[6] >>= nULong;
+ rParams[7] >>= nHyper;
+ rParams[8] >>= nUHyper;
+ rParams[9] >>= fFloat;
+ rParams[10] >>= fDouble;
+ rParams[11] >>= eEnum;
+ rParams[12] >>= aString;
+ rParams[13] >>= xInterface;
+ rParams[14] >>= aAny;
+ rParams[15] >>= aSeq;
+ rParams[16] >>= aData;
+
+ _xLBT->setValues( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
+ nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
+ aAny, aSeq, aData );
+
+ rOutParamIndex.realloc( 0 );
+ rOutParam.realloc( 0 );
+ }
+ else if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues2") ))
+ {
+ aBool = *(sal_Bool *)rParams[0].getValue();
+ aChar = *(sal_Unicode *)rParams[1].getValue();
+ rParams[2] >>= nByte;
+ rParams[3] >>= nShort;
+ rParams[4] >>= nUShort;
+ rParams[5] >>= nLong;
+ rParams[6] >>= nULong;
+ rParams[7] >>= nHyper;
+ rParams[8] >>= nUHyper;
+ rParams[9] >>= fFloat;
+ rParams[10] >>= fDouble;
+ rParams[11] >>= eEnum;
+ rParams[12] >>= aString;
+ rParams[13] >>= xInterface;
+ rParams[14] >>= aAny;
+ rParams[15] >>= aSeq;
+ rParams[16] >>= aData;
+
+ aRet <<= _xLBT->setValues2( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
+ nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
+ aAny, aSeq, aData );
+
+ rOutParamIndex.realloc( 17 );
+ rOutParamIndex[0] = 0;
+ rOutParamIndex[1] = 1;
+ rOutParamIndex[2] = 2;
+ rOutParamIndex[3] = 3;
+ rOutParamIndex[4] = 4;
+ rOutParamIndex[5] = 5;
+ rOutParamIndex[6] = 6;
+ rOutParamIndex[7] = 7;
+ rOutParamIndex[8] = 8;
+ rOutParamIndex[9] = 9;
+ rOutParamIndex[10] = 10;
+ rOutParamIndex[11] = 11;
+ rOutParamIndex[12] = 12;
+ rOutParamIndex[13] = 13;
+ rOutParamIndex[14] = 14;
+ rOutParamIndex[15] = 15;
+ rOutParamIndex[16] = 16;
+
+ rOutParam.realloc( 17 );
+ rOutParam[0].setValue( &aBool, ::getCppuBooleanType() );
+ rOutParam[1].setValue( &aChar, ::getCppuCharType() );
+ rOutParam[2] <<= nByte;
+ rOutParam[3] <<= nShort;
+ rOutParam[4] <<= nUShort;
+ rOutParam[5] <<= nLong;
+ rOutParam[6] <<= nULong;
+ rOutParam[7] <<= nHyper;
+ rOutParam[8] <<= nUHyper;
+ rOutParam[9] <<= fFloat;
+ rOutParam[10] <<= fDouble;
+ rOutParam[11] <<= eEnum;
+ rOutParam[12] <<= aString;
+ rOutParam[13] <<= xInterface;
+ rOutParam[14] <<= aAny;
+ rOutParam[15] <<= aSeq;
+ rOutParam[16] <<= aData;
+ }
+ else if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("getValues") ))
+ {
+ aRet <<= _xLBT->getValues( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
+ nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
+ aAny, aSeq, aData );
+
+ rOutParamIndex.realloc( 17 );
+ rOutParamIndex[0] = 0;
+ rOutParamIndex[1] = 1;
+ rOutParamIndex[2] = 2;
+ rOutParamIndex[3] = 3;
+ rOutParamIndex[4] = 4;
+ rOutParamIndex[5] = 5;
+ rOutParamIndex[6] = 6;
+ rOutParamIndex[7] = 7;
+ rOutParamIndex[8] = 8;
+ rOutParamIndex[9] = 9;
+ rOutParamIndex[10] = 10;
+ rOutParamIndex[11] = 11;
+ rOutParamIndex[12] = 12;
+ rOutParamIndex[13] = 13;
+ rOutParamIndex[14] = 14;
+ rOutParamIndex[15] = 15;
+ rOutParamIndex[16] = 16;
+
+ rOutParam.realloc( 17 );
+ rOutParam[0].setValue( &aBool, ::getCppuBooleanType() );
+ rOutParam[1].setValue( &aChar, ::getCppuCharType() );
+ rOutParam[2] <<= nByte;
+ rOutParam[3] <<= nShort;
+ rOutParam[4] <<= nUShort;
+ rOutParam[5] <<= nLong;
+ rOutParam[6] <<= nULong;
+ rOutParam[7] <<= nHyper;
+ rOutParam[8] <<= nUHyper;
+ rOutParam[9] <<= fFloat;
+ rOutParam[10] <<= fDouble;
+ rOutParam[11] <<= eEnum;
+ rOutParam[12] <<= aString;
+ rOutParam[13] <<= xInterface;
+ rOutParam[14] <<= aAny;
+ rOutParam[15] <<= aSeq;
+ rOutParam[16] <<= aData;
+ }
+ else if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raiseException") ))
+ {
+ aRet <<= _xLBT->raiseException( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
+ nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
+ aAny, aSeq, aData );
+
+ rOutParamIndex.realloc( 17 );
+ rOutParamIndex[0] = 0;
+ rOutParamIndex[1] = 1;
+ rOutParamIndex[2] = 2;
+ rOutParamIndex[3] = 3;
+ rOutParamIndex[4] = 4;
+ rOutParamIndex[5] = 5;
+ rOutParamIndex[6] = 6;
+ rOutParamIndex[7] = 7;
+ rOutParamIndex[8] = 8;
+ rOutParamIndex[9] = 9;
+ rOutParamIndex[10] = 10;
+ rOutParamIndex[11] = 11;
+ rOutParamIndex[12] = 12;
+ rOutParamIndex[13] = 13;
+ rOutParamIndex[14] = 14;
+ rOutParamIndex[15] = 15;
+ rOutParamIndex[16] = 16;
+
+ rOutParam.realloc( 17 );
+ rOutParam[0].setValue( &aBool, ::getCppuBooleanType() );
+ rOutParam[1].setValue( &aChar, ::getCppuCharType() );
+ rOutParam[2] <<= nByte;
+ rOutParam[3] <<= nShort;
+ rOutParam[4] <<= nUShort;
+ rOutParam[5] <<= nLong;
+ rOutParam[6] <<= nULong;
+ rOutParam[7] <<= nHyper;
+ rOutParam[8] <<= nUHyper;
+ rOutParam[9] <<= fFloat;
+ rOutParam[10] <<= fDouble;
+ rOutParam[11] <<= eEnum;
+ rOutParam[12] <<= aString;
+ rOutParam[13] <<= xInterface;
+ rOutParam[14] <<= aAny;
+ rOutParam[15] <<= aSeq;
+ rOutParam[16] <<= aData;
+ }
+ else
+ {
+ OSL_ENSHURE( sal_False, "no XLanguageBindingTest call received on invocation!" );
+ }
+ }
+ catch (IllegalArgumentException & rExc)
+ {
+ // thrown by raiseException() call
+ InvocationTargetException aExc;
+ aExc.TargetException <<= rExc;
+ throw aExc;
+ }
+ catch (Exception &)
+ {
+ OSL_ENSHURE( sal_False, "### unexpected exception caught!" );
+ throw;
+ }
+
+ return aRet;
+}
+//__________________________________________________________________________________________________
+void XLB_Invocation::setValue( const OUString & rName, const Any & rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ))
+ _xLBT->setBool( *(const sal_Bool *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ))
+ _xLBT->setByte( *(const sal_Int8 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ))
+ _xLBT->setChar( *(const sal_Unicode *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ))
+ _xLBT->setShort( *(const sal_Int16 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ))
+ _xLBT->setUShort( *(const sal_uInt16 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ))
+ _xLBT->setLong( *(const sal_Int32 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ))
+ _xLBT->setULong( *(const sal_uInt32 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ))
+ _xLBT->setHyper( *(const sal_Int64 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ))
+ _xLBT->setUHyper( *(const sal_uInt64 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ))
+ _xLBT->setFloat( *(const float *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ))
+ _xLBT->setDouble( *(const double *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ))
+ _xLBT->setEnum( *(const TestEnum *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ))
+ _xLBT->setString( *(const OUString *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ))
+ _xLBT->setInterface( *(const Reference< XInterface > *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ))
+ _xLBT->setAny( rValue );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ))
+ _xLBT->setSequence( *(const Sequence< TestElement > *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ))
+ _xLBT->setStruct( *(const TestData *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ))
+ _xLBT->setRuntimeException( *(const sal_Int32 *)rValue.getValue() );
+}
+//__________________________________________________________________________________________________
+Any XLB_Invocation::getValue( const OUString & rName )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
+{
+ Any aRet;
+ if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ))
+ {
+ sal_Bool aBool = _xLBT->getBool();
+ aRet.setValue( &aBool, ::getCppuBooleanType() );
+ }
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ))
+ aRet <<= _xLBT->getByte();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ))
+ {
+ sal_Unicode aChar = _xLBT->getChar();
+ aRet.setValue( &aChar, ::getCppuCharType() );
+ }
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ))
+ aRet <<= _xLBT->getShort();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ))
+ aRet <<= _xLBT->getUShort();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ))
+ aRet <<= _xLBT->getLong();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ))
+ aRet <<= _xLBT->getULong();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ))
+ aRet <<= _xLBT->getHyper();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ))
+ aRet <<= _xLBT->getUHyper();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ))
+ aRet <<= _xLBT->getFloat();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ))
+ aRet <<= _xLBT->getDouble();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ))
+ aRet <<= _xLBT->getEnum();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ))
+ aRet <<= _xLBT->getString();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ))
+ aRet <<= _xLBT->getInterface();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ))
+ aRet <<= _xLBT->getAny();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ))
+ aRet <<= _xLBT->getSequence();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ))
+ aRet <<= _xLBT->getStruct();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ))
+ aRet <<= _xLBT->getRuntimeException();
+ return aRet;
+}
+//__________________________________________________________________________________________________
+sal_Bool XLB_Invocation::hasMethod( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raiseException") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("getValues") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues2") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("acquire") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("release") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("queryInterface") ));
+}
+//__________________________________________________________________________________________________
+sal_Bool XLB_Invocation::hasProperty( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ) );
+}
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+void Test_Impl::setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny,
+ const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ const test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ assign( _aData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, xTest, rAny, rSequence );
+ _aStructData = rStruct;
+}
+//__________________________________________________________________________________________________
+test::TestData Test_Impl::setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ assign( _aData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, xTest, rAny, rSequence );
+ _aStructData = rStruct;
+ return _aStructData;
+}
+//__________________________________________________________________________________________________
+test::TestData Test_Impl::getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ bBool = _aData.Bool;
+ cChar = _aData.Char;
+ nByte = _aData.Byte;
+ nShort = _aData.Short;
+ nUShort = _aData.UShort;
+ nLong = _aData.Long;
+ nULong = _aData.ULong;
+ nHyper = _aData.Hyper;
+ nUHyper = _aData.UHyper;
+ fFloat = _aData.Float;
+ fDouble = _aData.Double;
+ eEnum = _aData.Enum;
+ rStr = _aData.String;
+ xTest = _aData.Interface;
+ rAny = _aData.Any;
+ rSequence = _aData.Sequence;
+ rStruct = _aStructData;
+ return _aStructData;
+}
+
+//==================================================================================================
+sal_Bool performTest( const Reference<XLanguageBindingTest > & xLBT )
+{
+ OSL_ENSHURE( xLBT.is(), "### no test interface!" );
+ if (xLBT.is())
+ {
+ // this data is never ever granted access to by calls other than equals(), assign()!
+ test::TestData aData; // test against this data
+
+ Reference<XInterface > xI( *new OWeakObject() );
+
+ assign( (test::TestElement &)aData,
+ sal_True, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210,
+ (float)17.0815, 3.1415926359, TestEnum_LOLA, OUString::createFromAscii("dumdidum"), xI,
+ Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
+
+ OSL_ENSHURE( aData.Any == xI, "### unexpected any!" );
+ OSL_ENSHURE( !(aData.Any != xI), "### unexpected any!" );
+
+ aData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aData, 1 );
+ // aData complete
+ //================================================================================
+
+ // this is a manually copy of aData for first setting...
+ test::TestData aSetData;
+
+ assign( (test::TestElement &)aSetData,
+ aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort,
+ aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, aData.Double,
+ aData.Enum, aData.String, xI,
+ Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
+
+ aSetData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aSetData, 1 );
+
+ xLBT->setValues(
+ aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, aSetData.UShort,
+ aSetData.Long, aSetData.ULong, aSetData.Hyper, aSetData.UHyper, aSetData.Float, aSetData.Double,
+ aSetData.Enum, aSetData.String, aSetData.Interface, aSetData.Any, aSetData.Sequence, aSetData );
+
+ {
+ test::TestData aRet, aRet2;
+ xLBT->getValues(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+
+ OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) );
+
+ // set last retrieved values
+ test::TestData aSV2ret = xLBT->setValues2(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+
+ OSL_ASSERT( equals( aData, aSV2ret ) && equals( aData, aRet2 ) );
+ }
+ {
+ test::TestData aRet, aRet2;
+ test::TestData aGVret = xLBT->getValues(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+
+ OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) && equals( aData, aGVret ) );
+
+ // set last retrieved values
+ xLBT->setBool( aRet.Bool );
+ xLBT->setChar( aRet.Char );
+ xLBT->setByte( aRet.Byte );
+ xLBT->setShort( aRet.Short );
+ xLBT->setUShort( aRet.UShort );
+ xLBT->setLong( aRet.Long );
+ xLBT->setULong( aRet.ULong );
+ xLBT->setHyper( aRet.Hyper );
+ xLBT->setUHyper( aRet.UHyper );
+ xLBT->setFloat( aRet.Float );
+ xLBT->setDouble( aRet.Double );
+ xLBT->setEnum( aRet.Enum );
+ xLBT->setString( aRet.String );
+ xLBT->setInterface( aRet.Interface );
+ xLBT->setAny( aRet.Any );
+ xLBT->setSequence( aRet.Sequence );
+ xLBT->setStruct( aRet2 );
+ }
+ {
+ test::TestData aRet, aRet2;
+ aRet.Hyper = xLBT->getHyper();
+ aRet.UHyper = xLBT->getUHyper();
+ aRet.Float = xLBT->getFloat();
+ aRet.Double = xLBT->getDouble();
+ aRet.Byte = xLBT->getByte();
+ aRet.Char = xLBT->getChar();
+ aRet.Bool = xLBT->getBool();
+ aRet.Short = xLBT->getShort();
+ aRet.UShort = xLBT->getUShort();
+ aRet.Long = xLBT->getLong();
+ aRet.ULong = xLBT->getULong();
+ aRet.Enum = xLBT->getEnum();
+ aRet.String = xLBT->getString();
+ aRet.Interface = xLBT->getInterface();
+ aRet.Any = xLBT->getAny();
+ aRet.Sequence = xLBT->getSequence();
+ aRet2 = xLBT->getStruct();
+
+ return (equals( aData, aRet ) && equals( aData, aRet2 ));
+ }
+ }
+ return sal_False;
+}
+
+//__________________________________________________________________________________________________
+test::TestData Test_Impl::raiseException( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, sal_Int16& nShort, sal_uInt16& nUShort, sal_Int32& nLong, sal_uInt32& nULong, sal_Int64& nHyper, sal_uInt64& nUHyper, float& fFloat, double& fDouble, test::TestEnum& eEnum, ::rtl::OUString& aString, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInterface, ::com::sun::star::uno::Any& aAny, ::com::sun::star::uno::Sequence< test::TestElement >& aSequence, test::TestData& aStruct )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ IllegalArgumentException aExc;
+ aExc.ArgumentPosition = 5;
+ aExc.Message = OUString::createFromAscii("dum dum dum ich tanz im kreis herum...");
+ aExc.Context = *this;
+ throw aExc;
+ return test::TestData();
+}
+//__________________________________________________________________________________________________
+sal_Int32 Test_Impl::getRuntimeException() throw(::com::sun::star::uno::RuntimeException)
+{
+ RuntimeException aExc;
+ aExc.Message = OUString::createFromAscii("dum dum dum ich tanz im kreis herum...");
+ aExc.Context = *this;
+ throw aExc;
+ return 0;
+}
+//__________________________________________________________________________________________________
+void Test_Impl::setRuntimeException( sal_Int32 _runtimeexception ) throw(::com::sun::star::uno::RuntimeException)
+{
+ RuntimeException aExc;
+ aExc.Message = OUString::createFromAscii("dum dum dum ich tanz im kreis herum...");
+ aExc.Context = *this;
+ throw aExc;
+}
+
+//==================================================================================================
+sal_Bool raiseException( const Reference<XLanguageBindingTest > & xLBT )
+{
+ try
+ {
+ try
+ {
+ try
+ {
+ test::TestData aRet, aRet2;
+ xLBT->raiseException(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+ return sal_False;
+ }
+ catch (IllegalArgumentException aExc)
+ {
+ OSL_ENSHURE( aExc.ArgumentPosition == 5 &&
+// aExc.Context == xLBT &&
+ aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
+ "### unexpected exception content!" );
+
+ Reference<XLanguageBindingTest > xLBT(
+ Reference<XLanguageBindingTest >::query( aExc.Context ) );
+
+ OSL_ENSHURE( xLBT.is(), "### unexpected source of exception!" );
+ if (xLBT.is())
+ xLBT->getRuntimeException();
+ else
+ return sal_False;
+ }
+ }
+ catch (const RuntimeException & rExc)
+ {
+ OSL_ENSHURE(//rExc.Context == xLBT &&
+ rExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
+ "### unexpected exception content!" );
+
+ Reference<XLanguageBindingTest > xLBT(
+ Reference<XLanguageBindingTest >::query( rExc.Context ) );
+
+ OSL_ENSHURE( xLBT.is(), "### unexpected source of exception!" );
+ if (xLBT.is())
+ xLBT->setRuntimeException( 0xcafebabe );
+ else
+ return sal_False;
+ }
+ }
+ catch (Exception & aExc)
+ {
+ OSL_ENSHURE( //aExc.Context == xLBT &&
+ aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
+ "### unexpected exception content!" );
+ return (//aExc.Context == xLBT &&
+ aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")));
+ }
+ return sal_False;
+}
+
+//==================================================================================================
+static sal_Bool test_adapter( const Reference< XMultiServiceFactory > & xMgr )
+{
+ Reference< XInvocationAdapterFactory > xAdapFac(
+ xMgr->createInstance( OUString::createFromAscii("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY );
+
+ Reference< XLanguageBindingTest > xOriginal( (XLanguageBindingTest *)new Test_Impl() );
+ Reference< XInvocation > xInvok( new XLB_Invocation( xMgr, xOriginal ) );
+ Reference< XLanguageBindingTest > xLBT( xAdapFac->createAdapter(
+ xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY );
+
+ return (performTest( xLBT ) && raiseException( xLBT ));
+}
+
+#ifdef UNX
+#define REG_PREFIX "lib"
+#define DLL_POSTFIX ".so"
+#else
+#define REG_PREFIX ""
+#define DLL_POSTFIX ".dll"
+#endif
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int __cdecl main( int argc, char * argv[] )
+#endif
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
+
+ sal_Bool bSucc = sal_False;
+ try
+ {
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.ImplementationRegistration") ) ),
+ UNO_QUERY );
+ OSL_ENSHURE( xImplReg.is(), "### no impl reg!" );
+
+ OUString aLibName( OUString::createFromAscii(REG_PREFIX "invadp" DLL_POSTFIX) );
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), aLibName, Reference< XSimpleRegistry >() );
+
+ bSucc = test_adapter( xMgr );
+ }
+ catch (Exception & rExc)
+ {
+ OSL_ENSHURE( sal_False, "### exception occured!" );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### exception occured: " );
+ OSL_TRACE( aMsg.getStr() );
+ OSL_TRACE( "\n" );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+
+ printf( "testiadapter %s !\n", (bSucc ? "succeeded" : "failed") );
+ return (bSucc ? 0 : -1);
+}
diff --git a/stoc/test/testintrosp.cxx b/stoc/test/testintrosp.cxx
new file mode 100644
index 000000000000..2e917fcbc008
--- /dev/null
+++ b/stoc/test/testintrosp.cxx
@@ -0,0 +1,1645 @@
+/*************************************************************************
+ *
+ * $RCSfile: testintrosp.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/servicefactory.hxx>
+
+#include <vos/diagnose.hxx>
+#include <vos/dynload.hxx>
+
+#include <ModuleA/XIntroTest.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertyConcept.hpp>
+#include <com/sun/star/beans/MethodConcept.hpp>
+#include <com/sun/star/beans/XExactName.hpp>
+#include <com/sun/star/container/XElementAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+//#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <stdio.h>
+#include <string.h>
+
+
+using namespace rtl;
+using namespace cppu;
+using namespace vos;
+using namespace ModuleA;
+//using namespace ModuleB;
+//using namespace ModuleC;
+//using namespace ModuleA::ModuleB;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::container;
+using namespace com::sun::star::beans::PropertyAttribute;
+
+
+typedef WeakImplHelper4< XIntroTest, XPropertySet, XNameAccess, XIndexAccess > ImplIntroTestHelper;
+typedef WeakImplHelper1< XPropertySetInfo > ImplPropertySetInfoHelper;
+
+
+#define DEFAULT_INDEX_ACCESS_COUNT 10
+#define DEFAULT_NAME_ACCESS_COUNT 5
+
+#ifdef _DEBUG
+#define TEST_ENSHURE(c, m) VOS_ENSHURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) VOS_VERIFY(c)
+#endif
+
+//class IntroTestWritelnOutput;
+
+
+
+//**************************************************************
+//*** Hilfs-Funktion, um vom Type eine XIdlClass zu bekommen ***
+//**************************************************************
+Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XMultiServiceFactory > & xMgr )
+{
+ static Reference< XIdlReflection > xRefl;
+
+ // void als Default-Klasse eintragen
+ Reference<XIdlClass> xRetClass;
+ typelib_TypeDescription * pTD = 0;
+ rType.getDescription( &pTD );
+ if( pTD )
+ {
+ OUString sOWName( pTD->pTypeName );
+ if( !xRefl.is() )
+ {
+ xRefl = Reference< XIdlReflection >( xMgr->createInstance(
+ OUString::createFromAscii("com.sun.star.reflection.CoreReflection") ), UNO_QUERY );
+ VOS_ENSHURE( xRefl.is(), "### no corereflection!" );
+ }
+ xRetClass = xRefl->forName( sOWName );
+ }
+ return xRetClass;
+}
+
+
+//****************************************************
+//*** Hilfs-Funktion, um Any als UString auszugeben ***
+//****************************************************
+// ACHTUNG: Kann mal an eine zentrale Stelle uebernommen werden
+// Wird zunaechst nur fuer einfache Datentypen ausgefuehrt
+
+OUString AnyToString( const Any& aValue, sal_Bool bIncludeType, const Reference< XMultiServiceFactory > & xMgr )
+{
+ Type aValType = aValue.getValueType();
+ TypeClass eType = aValType.getTypeClass();
+ char pBuffer[50];
+
+ OUString aRetStr;
+ switch( eType )
+ {
+ case TypeClass_TYPE: aRetStr = OUString::createFromAscii("TYPE TYPE"); break;
+ case TypeClass_INTERFACE: aRetStr = OUString::createFromAscii("TYPE INTERFACE"); break;
+ case TypeClass_SERVICE: aRetStr = OUString::createFromAscii("TYPE SERVICE"); break;
+ case TypeClass_STRUCT: aRetStr = OUString::createFromAscii("TYPE STRUCT"); break;
+ case TypeClass_TYPEDEF: aRetStr = OUString::createFromAscii("TYPE TYPEDEF"); break;
+ case TypeClass_UNION: aRetStr = OUString::createFromAscii("TYPE UNION"); break;
+ case TypeClass_ENUM: aRetStr = OUString::createFromAscii("TYPE ENUM"); break;
+ case TypeClass_EXCEPTION: aRetStr = OUString::createFromAscii("TYPE EXCEPTION"); break;
+ case TypeClass_ARRAY: aRetStr = OUString::createFromAscii("TYPE ARRAY"); break;
+ case TypeClass_SEQUENCE: aRetStr = OUString::createFromAscii("TYPE SEQUENCE"); break;
+ case TypeClass_VOID: aRetStr = OUString::createFromAscii("TYPE void"); break;
+ case TypeClass_ANY: aRetStr = OUString::createFromAscii("TYPE any"); break;
+ case TypeClass_UNKNOWN: aRetStr = OUString::createFromAscii("TYPE unknown"); break;
+ case TypeClass_BOOLEAN:
+ {
+ sal_Bool b = *(sal_Bool*)aValue.getValue();
+ //aRet.setValue( &b, getCppuBooleanType() );
+ //aValue >>= b;
+ aRetStr = OUString::valueOf( b );
+ break;
+ }
+ case TypeClass_CHAR:
+ {
+ sal_Unicode c = *(sal_Unicode*)aValue.getValue();
+ //aValue >>= c;
+ //getCppuCharType()
+ aRetStr = OUString::valueOf( c );
+ break;
+ }
+ case TypeClass_STRING:
+ {
+ aValue >>= aRetStr;
+ break;
+ }
+ case TypeClass_FLOAT:
+ {
+ float f;
+ aValue >>= f;
+ sprintf( pBuffer, "%f", f );
+ aRetStr = OUString( pBuffer, strlen( pBuffer ), RTL_TEXTENCODING_ASCII_US );
+ break;
+ }
+ case TypeClass_DOUBLE:
+ {
+ double d;
+ aValue >>= d;
+ sprintf( pBuffer, "%f", d );
+ aRetStr = OUString( pBuffer, strlen( pBuffer ), RTL_TEXTENCODING_ASCII_US );
+ break;
+ }
+ case TypeClass_BYTE:
+ {
+ sal_Int8 n;
+ aValue >>= n;
+ aRetStr = OUString::valueOf( (sal_Int32) n );
+ break;
+ }
+ case TypeClass_SHORT:
+ {
+ sal_Int16 n;
+ aValue >>= n;
+ aRetStr = OUString::valueOf( (sal_Int32) n );
+ break;
+ }
+ case TypeClass_LONG:
+ {
+ sal_Int32 n;
+ aValue >>= n;
+ aRetStr = OUString::valueOf( n );
+ break;
+ }
+ /*
+ case TypeClass_HYPER:
+ {
+ aRetStr = L"TYPE HYPER";
+ break;
+ }
+ case TypeClass_UNSIGNED_SHORT:
+ {
+ aRetStr = StringToUString(WSString(aValue.getUINT16()), CHARSET_SYSTEM);
+ break;
+ }
+ case TypeClass_UNSIGNED_LONG:
+ {
+ aRetStr = StringToUString(WSString(aValue.getUINT32()), CHARSET_SYSTEM);
+ break;
+ }
+ case TypeClass_UNSIGNED_HYPER:
+ {
+ aRetStr = L"TYPE UNSIGNED_HYPER";
+ break;
+ }
+ */
+ }
+
+ if( bIncludeType )
+ {
+ Reference< XIdlClass > xIdlClass = TypeToIdlClass( aValType, xMgr );
+ aRetStr = aRetStr + OUString( OUString::createFromAscii(" (Typ: ") ) + xIdlClass->getName() + OUString::createFromAscii(")");
+ }
+ return aRetStr;
+}
+
+/*
+// Hilfs-Funktion, um ein UString in einen Any zu konvertieren
+UsrAny StringToAny( UString aStr, TypeClass eTargetType )
+{
+ UsrAny aRetAny;
+ switch( eTargetType )
+ {
+ case TypeClass_INTERFACE: break;
+ case TypeClass_SERVICE: break;
+ case TypeClass_STRUCT: break;
+ case TypeClass_TYPEDEF: break;
+ case TypeClass_UNION: break;
+ case TypeClass_ENUM: break;
+ case TypeClass_EXCEPTION: break;
+ case TypeClass_ARRAY: break;
+ case TypeClass_SEQUENCE: break;
+ case TypeClass_VOID: break;
+ case TypeClass_ANY: break;
+ case TypeClass_UNKNOWN: break;
+ case TypeClass_BOOLEAN: aRetAny.setBOOL( short(aStr)!=0 ); break;
+ case TypeClass_CHAR: aRetAny.setChar( char(aStr) ); break;
+ case TypeClass_STRING: aRetAny.setString( aStr ); break;
+ case TypeClass_FLOAT: aRetAny.setFloat( (float)strtod( aStr.GetStr(), NULL ) ); break;
+ case TypeClass_DOUBLE: aRetAny.setDouble( strtod( aStr.GetStr(), NULL ) ); break;
+ case TypeClass_BYTE: aRetAny.setBYTE( BYTE(short(aStr)) ); break;
+ case TypeClass_SHORT: aRetAny.setINT16( short(aStr) ); break;
+ case TypeClass_LONG: aRetAny.setINT32( long(aStr) ); break;
+ case TypeClass_HYPER: break;
+ case TypeClass_UNSIGNED_SHORT: aRetAny.setUINT16( USHORT(aStr) ); break;
+ case TypeClass_UNSIGNED_LONG: aRetAny.setUINT32( ULONG(aStr) ); break;
+ case TypeClass_UNSIGNED_HYPER: break;
+ }
+ return aRetAny;
+}
+*/
+
+
+//*****************************************
+//*** XPropertySetInfo fuer Test-Klasse ***
+//*****************************************
+
+class ImplPropertySetInfo : public ImplPropertySetInfoHelper
+{
+ friend class ImplIntroTest;
+
+ Reference< XMultiServiceFactory > mxMgr;
+
+public:
+ ImplPropertySetInfo( const Reference< XMultiServiceFactory > & xMgr )
+ : mxMgr( xMgr ) {}
+ //: mxMgr( xMgr ), ImplPropertySetInfoHelper( xMgr ) {}
+
+/*
+ // Methoden von XInterface
+ virtual sal_Bool SAL_CALL queryInterface( const Uik & rUik, Any & ifc ) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw() { OWeakObject::release(); }
+ //ALT: sal_Bool queryInterface( Uik aUik, Reference<XInterface> & rOut );
+*/
+
+ // Methods of XPropertySetInfo
+ virtual Sequence< Property > SAL_CALL getProperties( )
+ throw(RuntimeException);
+ virtual Property SAL_CALL getPropertyByName( const OUString& aName )
+ throw(UnknownPropertyException, RuntimeException);
+ virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name )
+ throw(RuntimeException);
+ //virtual Sequence< Property > SAL_CALL getProperties(void) throw( RuntimeException );
+ //virtual Property SAL_CALL getPropertyByName(const OUString& Name) throw( RuntimeException );
+ //virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& Name) throw( RuntimeException );
+};
+
+
+/*
+// Methoden von XInterface
+sal_Bool SAL_CALL ImplPropertySetInfo::queryInterface( const Uik & rUik, Any & ifc )
+ throw( RuntimeException )
+{
+ // PropertySet-Implementation
+ if( com::sun::star::uno::queryInterface( rUik, ifc,
+ SAL_STATIC_CAST(XPropertySetInfo*, this) ) )
+ return sal_True;
+
+ return OWeakObject::queryInterface( rUik, ifc );
+}
+
+sal_Bool ImplPropertySetInfo::queryInterface( Uik aUik, Reference<XInterface> & rOut )
+{
+ if( aUik == XPropertySetInfo::getSmartUik() )
+ rOut = (XPropertySetInfo *)this;
+ else
+ UsrObject::queryInterface( aUik, rOut );
+ return rOut.is();
+}
+*/
+
+Sequence< Property > ImplPropertySetInfo::getProperties(void)
+ throw( RuntimeException )
+{
+ static Sequence<Property> * pSeq = NULL;
+
+ if( !pSeq )
+ {
+ // die Informationen für die Properties "Width", "Height" und "Name" anlegen
+ pSeq = new Sequence<Property>( 3 );
+ Property * pAry = pSeq->getArray();
+
+ pAry[0].Name = OUString::createFromAscii("Factor");
+ pAry[0].Handle = -1;
+ pAry[0].Type = getCppuType( (double*) NULL );
+ //pAry[0].Type = TypeToIdlClass( getCppuType( (double*) NULL ), mxMgr );
+ //pAry[0].Type = Double_getReflection()->getIdlClass();
+ pAry[0].Attributes = BOUND | TRANSIENT;
+
+ pAry[1].Name = OUString::createFromAscii("MyCount");
+ pAry[1].Handle = -1;
+ pAry[1].Type = getCppuType( (sal_Int32*) NULL );
+ //pAry[1].Type = TypeToIdlClass( getCppuType( (sal_Int32*) NULL ), mxMgr );
+ //pAry[1].Type = INT32_getReflection()->getIdlClass();
+ pAry[1].Attributes = BOUND | TRANSIENT;
+
+ pAry[2].Name = OUString::createFromAscii("Info");
+ pAry[2].Handle = -1;
+ pAry[2].Type = getCppuType( (OUString*) NULL );
+ //pAry[2].Type = TypeToIdlClass( getCppuType( (OUString*) NULL ), mxMgr );
+ //pAry[2].Type = OUString_getReflection()->getIdlClass();
+ pAry[2].Attributes = TRANSIENT;
+ }
+ // Die Information über alle drei Properties liefern.
+ return *pSeq;
+}
+
+Property ImplPropertySetInfo::getPropertyByName(const OUString& Name)
+ throw( UnknownPropertyException, RuntimeException )
+{
+ Sequence<Property> aSeq = getProperties();
+ const Property * pAry = aSeq.getConstArray();
+
+ for( sal_Int32 i = aSeq.getLength(); i--; )
+ {
+ if( pAry[i].Name == Name )
+ return pAry[i];
+ }
+ // Property unbekannt, also leere liefern
+ return Property();
+}
+
+sal_Bool ImplPropertySetInfo::hasPropertyByName(const OUString& Name)
+ throw( RuntimeException )
+{
+ Sequence<Property> aSeq = getProperties();
+ const Property * pAry = aSeq.getConstArray();
+
+ for( sal_Int32 i = aSeq.getLength(); i--; )
+ {
+ if( pAry[i].Name == Name )
+ return sal_True;
+ }
+ // Property unbekannt, also leere liefern
+ return sal_False;
+}
+
+
+
+
+//*****************************************************************
+
+
+
+class ImplIntroTest : public ImplIntroTestHelper
+{
+ Reference< XMultiServiceFactory > mxMgr;
+
+ friend class ImplPropertySetInfo;
+
+ // Properties fuer das PropertySet
+ Any aAnyArray[10];
+
+ // Optionale Schnittstelle fuer die writeln-Ausgabe
+ //IntroTestWritelnOutput* m_pOutput;
+
+ Reference< XPropertySetInfo > m_xMyInfo;
+
+ OUString m_ObjectName;
+
+ int m_nMarkusAge;
+ int m_nMarkusChildrenCount;
+
+ long m_lDroenk;
+ sal_Int16 m_nBla;
+ sal_Int16 m_nBlub;
+ sal_Int16 m_nGulp;
+ sal_Int16 m_nLaber;
+ TypeClass eTypeClass;
+ Sequence< OUString > aStringSeq;
+ Sequence< Sequence< Sequence< sal_Int16 > > > aMultSeq;
+ Reference< XIntroTest > m_xIntroTest;
+
+ // Daten fuer NameAccess
+ Reference< XIntroTest >* pNameAccessTab;
+
+ // Daten fuer IndexAccess
+ Reference< XIntroTest >* pIndexAccessTab;
+ sal_Int16 iIndexAccessCount;
+
+ // struct-Properties
+ Property m_aFirstStruct;
+ PropertyValue m_aSecondStruct;
+
+ // Listener merken (zunaechst einfach, nur einen pro Property)
+ Reference< XPropertyChangeListener > aPropChangeListener;
+ OUString aPropChangeListenerStr;
+ Reference< XVetoableChangeListener > aVetoPropChangeListener;
+ OUString aVetoPropChangeListenerStr;
+
+ void Init( void );
+
+public:
+ ImplIntroTest( const Reference< XMultiServiceFactory > & xMgr )
+ : mxMgr( xMgr )
+ //: mxMgr( xMgr ), ImplIntroTestHelper( xMgr )
+ {
+ Init();
+ }
+
+ /*
+ ImplIntroTest( IntroTestWritelnOutput* pOutput_ )
+ {
+ Init();
+ m_pOutput = pOutput_;
+ }
+ */
+
+ //SMART_UNO_DECLARATION(ImplIntroTest,UsrObject);
+
+ //BOOL queryInterface( Uik aUik, Reference< XInterface > & rOut );
+ //Reference< XIdlClass > getIdlClass();
+
+ // Trotz virtual inline, um Schreibarbeit zu sparen (nur fuer Testzwecke)
+ // XPropertySet
+ virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo( )
+ throw(RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException);
+ virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+ {}
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+ {}
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+ {}
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+ {}
+
+ /*
+ virtual void setIndexedPropertyValue(const OUString& aPropertyName, INT32 nIndex, const Any& aValue) {}
+ virtual Any getIndexedPropertyValue(const UString& aPropertyName, INT32 nIndex) const { return Any(); }
+ virtual void addPropertyChangeListener(const UString& aPropertyName, const XPropertyChangeListenerRef& aListener)
+ THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
+ virtual void removePropertyChangeListener(const UString& aPropertyName, const XPropertyChangeListenerRef& aListener)
+ THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
+ virtual void addVetoableChangeListener(const UString& aPropertyName, const XVetoableChangeListenerRef& aListener)
+ THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
+ virtual void removeVetoableChangeListener(const UString& aPropertyName, const XVetoableChangeListenerRef& aListener)
+ THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
+ */
+
+ // XIntroTest-Methoden
+ // Attributes
+ virtual OUString SAL_CALL getObjectName() throw(RuntimeException)
+ { return m_ObjectName; }
+ virtual void SAL_CALL setObjectName( const OUString& _objectname ) throw(RuntimeException)
+ { m_ObjectName = _objectname; }
+ virtual OUString SAL_CALL getFirstName()
+ throw(RuntimeException);
+ virtual OUString SAL_CALL getLastName() throw(RuntimeException)
+ { return OUString( OUString::createFromAscii("Meyer") ); }
+ virtual sal_Int16 SAL_CALL getAge() throw(RuntimeException)
+ { return m_nMarkusAge; }
+ virtual sal_Int16 SAL_CALL getChildrenCount() throw(RuntimeException)
+ { return m_nMarkusChildrenCount; }
+ virtual void SAL_CALL setChildrenCount( sal_Int16 _childrencount ) throw(RuntimeException)
+ { m_nMarkusChildrenCount = _childrencount; }
+ virtual Property SAL_CALL getFirstStruct() throw(RuntimeException)
+ { return m_aFirstStruct; }
+ virtual void SAL_CALL setFirstStruct( const Property& _firststruct ) throw(RuntimeException)
+ { m_aFirstStruct = _firststruct; }
+ virtual PropertyValue SAL_CALL getSecondStruct() throw(RuntimeException)
+ { return m_aSecondStruct; }
+ virtual void SAL_CALL setSecondStruct( const PropertyValue& _secondstruct ) throw(RuntimeException)
+ { m_aSecondStruct = _secondstruct; }
+
+ // Methods
+ virtual void SAL_CALL writeln( const OUString& Text )
+ throw(RuntimeException);
+ virtual sal_Int32 SAL_CALL getDroenk( ) throw(RuntimeException)
+ { return m_lDroenk; }
+ virtual Reference< ::ModuleA::XIntroTest > SAL_CALL getIntroTest( ) throw(RuntimeException);
+ virtual sal_Int32 SAL_CALL getUps( sal_Int32 l ) throw(RuntimeException)
+ { return 2*l; }
+ virtual void SAL_CALL setDroenk( sal_Int32 l ) throw(RuntimeException)
+ { m_lDroenk = l; }
+ virtual sal_Int16 SAL_CALL getBla( ) throw(RuntimeException)
+ { return m_nBla; }
+ virtual void SAL_CALL setBla( sal_Int32 n ) throw(RuntimeException)
+ { m_nBla = (sal_Int16)n; }
+ virtual sal_Int16 SAL_CALL getBlub( ) throw(RuntimeException)
+ { return m_nBlub; }
+ virtual void SAL_CALL setBlub( sal_Int16 n ) throw(RuntimeException)
+ { m_nBlub = n; }
+ virtual sal_Int16 SAL_CALL getGulp( ) throw(RuntimeException)
+ { return m_nGulp; }
+ virtual sal_Int16 SAL_CALL setGulp( sal_Int16 n ) throw(RuntimeException)
+ { m_nGulp = n; return 1; }
+ virtual TypeClass SAL_CALL getTypeClass( sal_Int16 n ) throw(RuntimeException)
+ { return eTypeClass; }
+ virtual void SAL_CALL setTypeClass( TypeClass t, double d1, double d2 ) throw(RuntimeException)
+ { eTypeClass = t; }
+ virtual Sequence< OUString > SAL_CALL getStrings( ) throw(RuntimeException)
+ { return aStringSeq; }
+ virtual void SAL_CALL setStrings( const Sequence< OUString >& Strings ) throw(RuntimeException)
+ { aStringSeq = Strings; }
+ virtual void SAL_CALL setStringsPerMethod( const Sequence< OUString >& Strings, sal_Int16 n ) throw(RuntimeException)
+ { aStringSeq = Strings; }
+ virtual Sequence< Sequence< Sequence< sal_Int16 > > > SAL_CALL getMultiSequence( ) throw(RuntimeException)
+ { return aMultSeq; }
+ virtual void SAL_CALL setMultiSequence( const Sequence< Sequence< Sequence< sal_Int16 > > >& Seq ) throw(RuntimeException)
+ { aMultSeq = Seq; }
+ virtual void SAL_CALL addPropertiesChangeListener( const Sequence< OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener )
+ throw(RuntimeException);
+ virtual void SAL_CALL removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& Listener )
+ throw(RuntimeException);
+
+
+ // Methods of XElementAccess
+ virtual Type SAL_CALL getElementType( )
+ throw(RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( )
+ throw(RuntimeException);
+ //virtual XIdlClassRef getElementType(void) constTHROWS( (UsrSystemException) );
+ //virtual BOOL hasElements(void) const THROWS( (UsrSystemException) );
+
+ // XNameAccess-Methoden
+ // Methods
+ virtual Any SAL_CALL getByName( const OUString& aName )
+ throw(NoSuchElementException, WrappedTargetException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getElementNames( )
+ throw(RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
+ throw(RuntimeException);
+ //virtual Any getByName(const UString& Name) const
+ //THROWS( (NoSuchElementException, WrappedTargetException, UsrSystemException) );
+ //virtual Sequence<UString> getElementNames(void) const THROWS( (UsrSystemException) );
+ //virtual BOOL hasByName(const UString& Name) const THROWS( (UsrSystemException) );
+
+ // XIndexAccess-Methoden
+ // Methods
+ virtual sal_Int32 SAL_CALL getCount( )
+ throw(RuntimeException);
+ virtual Any SAL_CALL getByIndex( sal_Int32 Index )
+ throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
+ //virtual INT32 getCount(void) const THROWS( (UsrSystemException) );
+ //virtual Any getByIndex(INT32 Index) const
+ //THROWS( (IndexOutOfBoundsException, WrappedTargetException, UsrSystemException) );
+};
+
+//SMART_UNO_IMPLEMENTATION(ImplIntroTest,UsrObject)
+
+void ImplIntroTest::Init( void )
+{
+ // Eindeutigen Namen verpassen
+ static sal_Int32 nObjCount = 0;
+ OUString aName( OUString::createFromAscii("IntroTest-Obj Nr. ") );
+ aName += OUString::valueOf( nObjCount );
+ setObjectName( aName );
+
+ // Properties initialisieren
+ aAnyArray[0] <<= 3.14;
+ aAnyArray[1] <<= (sal_Int32)42;
+ aAnyArray[2] <<= OUString( OUString::createFromAscii("Hallo") );
+
+ // Output-Interface
+ //m_pOutput = NULL;
+
+ // Einmal fuer den internen Gebrauch die PropertySetInfo abholen
+ m_xMyInfo = getPropertySetInfo();
+ m_xMyInfo->acquire(); // sonst raucht es am Programm-Ende ab
+
+ m_nMarkusAge = 33;
+ m_nMarkusChildrenCount = 2;
+
+ m_lDroenk = 314;
+ m_nBla = 42;
+ m_nBlub = 111;
+ m_nGulp = 99;
+ m_nLaber = 1;
+ eTypeClass = TypeClass_INTERFACE;
+
+ // String-Sequence intitialisieren
+ aStringSeq.realloc( 3 );
+ OUString* pStr = aStringSeq.getArray();
+ pStr[ 0 ] = OUString( OUString::createFromAscii("String 0") );
+ pStr[ 1 ] = OUString( OUString::createFromAscii("String 1") );
+ pStr[ 2 ] = OUString( OUString::createFromAscii("String 2") );
+
+ // structs initialisieren
+ m_aFirstStruct.Name = OUString::createFromAscii("FirstStruct-Name");
+ m_aFirstStruct.Handle = 77777;
+ //XIdlClassRef Type;
+ m_aFirstStruct.Attributes = -222;
+
+ //XInterfaceRef Source;
+ Any Value;
+ Value <<= 2.718281828459;
+ m_aSecondStruct.Value = Value;
+ //XIdlClassRef ListenerType;
+ m_aSecondStruct.State = PropertyState_DIRECT_VALUE;
+
+ // IndexAccess
+ iIndexAccessCount = DEFAULT_INDEX_ACCESS_COUNT;
+ pIndexAccessTab = NULL;
+ pNameAccessTab = NULL;
+}
+
+/*
+BOOL ImplIntroTest::queryInterface( Uik aUik, XInterfaceRef & rOut )
+{
+ if( aUik == XIntroTest::getSmartUik() )
+ rOut = (XIntroTest*)this;
+ else if( aUik == XPropertySet::getSmartUik() )
+ rOut = (XPropertySet*)this;
+ else if( aUik == XNameAccess::getSmartUik() )
+ rOut = (XNameAccess*)this;
+ else if( aUik == XIndexAccess::getSmartUik() )
+ rOut = (XIndexAccess*)this;
+ else if( aUik == ((XElementAccess*)NULL)->getSmartUik() )
+ rOut = (XElementAccess*)(XIndexAccess *)this;
+ else
+ UsrObject::queryInterface( aUik, rOut );
+ return rOut.is();
+}
+
+XIdlClassRef ImplIntroTest::getIdlClass()
+{
+ static XIdlClassRef xClass = createStandardClass( L"ImplIntroTest",
+ UsrObject::getUsrObjectIdlClass(), 4,
+ XIntroTest_getReflection(),
+ XPropertySet_getReflection(),
+ XNameAccess_getReflection(),
+ XIndexAccess_getReflection() );
+ return xClass;
+}
+*/
+
+Reference< XPropertySetInfo > ImplIntroTest::getPropertySetInfo()
+ throw(RuntimeException)
+{
+ static ImplPropertySetInfo aInfo( mxMgr );
+ // Alle Objekt haben die gleichen Properties, deshalb kann
+ // die Info für alle gleich sein
+ return &aInfo;
+
+ //if( m_xMyInfo == NULL )
+ // ((ImplIntroTest*)this)->m_xMyInfo = new ImplPropertySetInfo( this );
+ //return m_xMyInfo;
+}
+
+void ImplIntroTest::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+//void ImplIntroTest::setPropertyValue( const UString& aPropertyName, const Any& aValue )
+// THROWS( (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, UsrSystemException) )
+{
+ if( aPropChangeListener.is() && aPropertyName == aPropChangeListenerStr )
+ {
+ PropertyChangeEvent aEvt;
+ aEvt.Source = (OWeakObject*)this;
+ aEvt.PropertyName = aPropertyName;
+ aEvt.PropertyHandle = 0L;
+ //aEvt.OldValue;
+ //aEvt.NewValue;
+ //aEvt.PropagationId;
+ aPropChangeListener->propertyChange( aEvt );
+ }
+ if( aVetoPropChangeListener.is() && aPropertyName == aVetoPropChangeListenerStr )
+ {
+ PropertyChangeEvent aEvt;
+ aEvt.Source = (OWeakObject*)this;
+ aEvt.PropertyName = aVetoPropChangeListenerStr;
+ aEvt.PropertyHandle = 0L;
+ //aEvt.OldValue;
+ //aEvt.NewValue;
+ //aEvt.PropagationId;
+ aVetoPropChangeListener->vetoableChange( aEvt );
+ }
+
+ Sequence<Property> aPropSeq = m_xMyInfo->getProperties();
+ sal_Int32 nLen = aPropSeq.getLength();
+ for( sal_Int32 i = 0 ; i < nLen ; i++ )
+ {
+ Property aProp = aPropSeq.getArray()[ i ];
+ if( aProp.Name == aPropertyName )
+ aAnyArray[i] = aValue;
+ }
+}
+
+Any ImplIntroTest::getPropertyValue( const OUString& PropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+//Any ImplIntroTest::getPropertyValue(const UString& aPropertyName) const
+ //THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) )
+{
+ Sequence<Property> aPropSeq = m_xMyInfo->getProperties();
+ sal_Int32 nLen = aPropSeq.getLength();
+ for( sal_Int32 i = 0 ; i < nLen ; i++ )
+ {
+ Property aProp = aPropSeq.getArray()[ i ];
+ if( aProp.Name == PropertyName )
+ return aAnyArray[i];
+ }
+ return Any();
+}
+
+OUString ImplIntroTest::getFirstName(void)
+ throw(RuntimeException)
+{
+ return OUString( OUString::createFromAscii("Markus") );
+}
+
+void ImplIntroTest::writeln( const OUString& Text )
+ throw(RuntimeException)
+{
+ OString aStr( Text.getStr(), Text.getLength(), RTL_TEXTENCODING_ASCII_US );
+
+ // Haben wir ein Output?
+ //if( m_pOutput )
+ //{
+ //m_pOutput->doWriteln( TextStr );
+ //}
+ // Sonst einfach rausbraten
+ //else
+ {
+ printf( "%s", aStr.getStr() );
+ }
+}
+
+Reference< XIntroTest > ImplIntroTest::getIntroTest()
+ throw(RuntimeException)
+//XIntroTestRef ImplIntroTest::getIntroTest(void) THROWS( (UsrSystemException) )
+{
+ if( !m_xIntroTest.is() )
+ m_xIntroTest = new ImplIntroTest( mxMgr );
+ return m_xIntroTest;
+}
+
+// Methoden von XElementAccess
+Type ImplIntroTest::getElementType( )
+ throw(RuntimeException)
+//XIdlClassRef ImplIntroTest::getElementType(void) const THROWS( (UsrSystemException) )
+{
+ // TODO
+ Type aRetType;
+ return aRetType;
+ //return Reference< XIdlClass >();
+ //return Void_getReflection()->getIdlClass();
+}
+
+sal_Bool ImplIntroTest::hasElements( )
+ throw(RuntimeException)
+//BOOL ImplIntroTest::hasElements(void) const THROWS( (UsrSystemException) )
+{
+ return sal_True;
+}
+
+// XNameAccess-Methoden
+sal_Int32 getIndexForName( const OUString& ItemName )
+{
+ OUString aLeftStr = ItemName.copy( 0, 4 );
+ if( aLeftStr == OUString::createFromAscii("Item") )
+ {
+ // TODO
+ OUString aNumStr = ItemName.copy( 4 );
+ //sal_Int32 iIndex = (INT32)UStringToString( aNumStr, CHARSET_SYSTEM );
+ //if( iIndex < DEFAULT_NAME_ACCESS_COUNT )
+ //return iIndex;
+ }
+ return -1;
+}
+
+
+Any ImplIntroTest::getByName( const OUString& aName )
+ throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+//Any ImplIntroTest::getByName(const UString& Name) const
+ //THROWS( (NoSuchElementException, WrappedTargetException, UsrSystemException) )
+{
+ Any aRetAny;
+
+ if( !pNameAccessTab )
+ ((ImplIntroTest*)this)->pNameAccessTab = new Reference< XIntroTest >[ DEFAULT_NAME_ACCESS_COUNT ];
+
+ sal_Int32 iIndex = getIndexForName( aName );
+ if( iIndex != -1 )
+ {
+ if( !pNameAccessTab[iIndex].is() )
+ {
+ ImplIntroTest* p = new ImplIntroTest( mxMgr );
+ OUString aName( OUString::createFromAscii("IntroTest by Name-Access, Index = ") );
+ aName += OUString::valueOf( iIndex );
+ //aName = aName + StringToUString( String( iIndex ), CHARSET_SYSTEM );
+ p->setObjectName( aName );
+ pNameAccessTab[iIndex] = p;
+ }
+
+ Reference< XIntroTest > xRet = pNameAccessTab[iIndex];
+ aRetAny = makeAny( xRet );
+
+ //aRetAny.set( &xRet, XIntroTest_getReflection() );
+ //return (UsrObject*)(XIntroTest*)pNameAccessTab[iIndex];
+ }
+ return aRetAny;
+}
+
+Sequence< OUString > ImplIntroTest::getElementNames( )
+ throw(RuntimeException)
+//Sequence<UString> ImplIntroTest::getElementNames(void) const THROWS( (UsrSystemException) )
+{
+ Sequence<OUString> aStrSeq( DEFAULT_NAME_ACCESS_COUNT );
+ OUString* pStr = aStrSeq.getArray();
+ for( sal_Int32 i = 0 ; i < DEFAULT_NAME_ACCESS_COUNT ; i++ )
+ {
+ OUString aName( OUString::createFromAscii("Item") );
+ aName += OUString::valueOf( i );
+ //aName = aName + StringToUString( i, CHARSET_SYSTEM );
+ pStr[i] = aName;
+ }
+ return aStrSeq;
+}
+
+sal_Bool ImplIntroTest::hasByName( const OUString& aName )
+ throw(RuntimeException)
+//BOOL ImplIntroTest::hasByName(const UString& Name) const THROWS( (UsrSystemException) )
+{
+ return ( getIndexForName( aName ) != -1 );
+}
+
+// XIndexAccess-Methoden
+sal_Int32 ImplIntroTest::getCount( )
+ throw(RuntimeException)
+//sal_Int32 ImplIntroTest::getCount(void) const THROWS( (UsrSystemException) )
+{
+ return iIndexAccessCount;
+}
+
+Any ImplIntroTest::getByIndex( sal_Int32 Index )
+ throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+//Any ImplIntroTest::getByIndex( sal_Int32 Index ) const
+ //THROWS( (IndexOutOfBoundsException, WrappedTargetException, UsrSystemException) )
+{
+ Any aRetAny;
+
+ if( !pIndexAccessTab )
+ ((ImplIntroTest*)this)->pIndexAccessTab = new Reference< XIntroTest >[ iIndexAccessCount ];
+
+ if( Index < iIndexAccessCount )
+ {
+ if( !pNameAccessTab[Index].is() )
+ {
+ ImplIntroTest* p = new ImplIntroTest( mxMgr );
+ OUString aName( OUString::createFromAscii("IntroTest by Index-Access, Index = ") );
+ aName += OUString::valueOf( Index );
+ //aName = aName + StringToUString( String( iIndex ), CHARSET_SYSTEM );
+ p->setObjectName( aName );
+ pIndexAccessTab[Index] = p;
+ }
+ Reference< XIntroTest > xRet = pIndexAccessTab[Index];
+ aRetAny = makeAny( xRet );
+ }
+ return aRetAny;
+}
+
+void ImplIntroTest::addPropertiesChangeListener( const Sequence< OUString >& PropertyNames,
+ const Reference< XPropertiesChangeListener >& Listener )
+ throw(RuntimeException)
+//void ImplIntroTest::addPropertiesChangeListener
+//(const Sequence< UString >& PropertyNames, const XPropertiesChangeListenerRef& Listener)
+ //THROWS( (UsrSystemException) )
+{
+}
+
+void ImplIntroTest::removePropertiesChangeListener
+ ( const Reference< XPropertiesChangeListener >& Listener )
+ throw(RuntimeException)
+//void ImplIntroTest::removePropertiesChangeListener(const XPropertiesChangeListenerRef& Listener)
+ //THROWS( (UsrSystemException) )
+{
+}
+
+
+
+struct DefItem
+{
+ char* pName;
+ sal_Int32 nConcept;
+};
+
+// Spezial-Wert fuer Method-Concept, um "normale" Funktionen kennzeichnen zu koennen
+#define MethodConcept_NORMAL_IMPL 0x80000000
+
+
+// Test-Objekt liefern
+Any getIntrospectionTestObject( const Reference< XMultiServiceFactory > & xMgr )
+{
+ Any aObjAny;
+ Reference< XIntroTest > xTestObj = new ImplIntroTest( xMgr );
+ aObjAny.setValue( &xTestObj, ::getCppuType( (const Reference< XIntroTest > *)0 ) );
+ return aObjAny;
+}
+
+static sal_Bool test_introsp( Reference< XMultiServiceFactory > xMgr,
+ Reference< XIdlReflection > xRefl, Reference< XIntrospection > xIntrospection )
+{
+ DefItem pPropertyDefs[] =
+ {
+ { "Factor", PropertyConcept::PROPERTYSET },
+ { "MyCount", PropertyConcept::PROPERTYSET },
+ { "Info", PropertyConcept::PROPERTYSET },
+ { "ObjectName", PropertyConcept::ATTRIBUTES },
+ { "FirstName", PropertyConcept::ATTRIBUTES },
+ { "LastName", PropertyConcept::ATTRIBUTES },
+ { "Age", PropertyConcept::ATTRIBUTES },
+ { "ChildrenCount", PropertyConcept::ATTRIBUTES },
+ { "FirstStruct", PropertyConcept::ATTRIBUTES },
+ { "SecondStruct", PropertyConcept::ATTRIBUTES },
+ { "Droenk", PropertyConcept::METHODS },
+ { "IntroTest", PropertyConcept::METHODS },
+ { "Bla", PropertyConcept::METHODS },
+ { "Blub", PropertyConcept::METHODS },
+ { "Gulp", PropertyConcept::METHODS },
+ { "Strings", PropertyConcept::METHODS },
+ { "MultiSequence", PropertyConcept::METHODS },
+ { "PropertySetInfo", PropertyConcept::METHODS },
+ { "ElementType", PropertyConcept::METHODS },
+ { "ElementNames", PropertyConcept::METHODS },
+ { "Count", PropertyConcept::METHODS },
+ { "Types", PropertyConcept::METHODS },
+ { "ImplementationId", PropertyConcept::METHODS },
+ { NULL, 0 }
+ };
+
+ // Tabelle der Property-Namen, die gefunden werden muessen
+ char* pDemandedPropNames[] =
+ {
+ "Factor",
+ "MyCount",
+ "Info",
+ "ObjectName",
+ "FirstName",
+ "LastName",
+ "Age",
+ "ChildrenCount",
+ "FirstStruct",
+ "SecondStruct",
+ "Droenk",
+ "IntroTest",
+ "Bla",
+ "Blub",
+ "Gulp",
+ "Strings",
+ "MultiSequence",
+ "PropertySetInfo",
+ "ElementType",
+ "ElementNames",
+ "Count",
+ "Types"
+ "ImplementationId"
+ };
+
+ char* pDemandedPropVals[] =
+ {
+ "3.140000",
+ "42",
+ "Hallo",
+ "IntroTest-Obj Nr. 0",
+ "Markus",
+ "Meyer",
+ "33",
+ "2",
+ "TYPE STRUCT",
+ "TYPE STRUCT",
+ "314",
+ "TYPE INTERFACE",
+ "42",
+ "111",
+ "99",
+ "TYPE SEQUENCE",
+ "TYPE SEQUENCE",
+ "TYPE INTERFACE",
+ "TYPE TYPE",
+ "TYPE SEQUENCE",
+ "10",
+ "TYPE SEQUENCE",
+ "TYPE SEQUENCE",
+ };
+
+ char* pDemandedModifiedPropVals[] =
+ {
+ "4.140000",
+ "43",
+ "Hallo (Modified!)",
+ "IntroTest-Obj Nr. 0 (Modified!)",
+ "Markus",
+ "Meyer",
+ "33",
+ "3",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "315",
+ "Wert wurde nicht modifiziert",
+ "42",
+ "112",
+ "99",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "10",
+ "Wert wurde nicht modifiziert"
+ "Wert wurde nicht modifiziert"
+ };
+
+ char* pDemandedPropTypes[] =
+ {
+ "double",
+ "long",
+ "string",
+ "string",
+ "string",
+ "string",
+ "short",
+ "short",
+ "com.sun.star.beans.Property",
+ "com.sun.star.beans.PropertyValue",
+ "long",
+ "ModuleA.XIntroTest",
+ "short",
+ "short",
+ "short",
+ "[]string",
+ "[][][]short",
+ "com.sun.star.beans.XPropertySetInfo",
+ "type",
+ "[]string",
+ "long",
+ "[]type",
+ "[]byte",
+ };
+ //is() nDemandedPropCount = 22;
+
+
+ DefItem pMethodDefs[] =
+ {
+ { "queryInterface", MethodConcept_NORMAL_IMPL },
+ { "acquire", MethodConcept::DANGEROUS },
+ { "release", MethodConcept::DANGEROUS },
+ { "writeln", MethodConcept_NORMAL_IMPL },
+ { "getDroenk", MethodConcept::PROPERTY },
+ { "getIntroTest", MethodConcept::PROPERTY },
+ { "getUps", MethodConcept_NORMAL_IMPL },
+ { "setDroenk", MethodConcept::PROPERTY },
+ { "getBla", MethodConcept::PROPERTY },
+ { "setBla", MethodConcept_NORMAL_IMPL },
+ { "getBlub", MethodConcept::PROPERTY },
+ { "setBlub", MethodConcept::PROPERTY },
+ { "getGulp", MethodConcept::PROPERTY },
+ { "setGulp", MethodConcept_NORMAL_IMPL },
+ { "getTypeClass", MethodConcept_NORMAL_IMPL },
+ { "setTypeClass", MethodConcept_NORMAL_IMPL },
+ { "getStrings", MethodConcept::PROPERTY },
+ { "setStrings", MethodConcept::PROPERTY },
+ { "setStringsPerMethod", MethodConcept_NORMAL_IMPL },
+ { "getMultiSequence", MethodConcept::PROPERTY },
+ { "setMultiSequence", MethodConcept::PROPERTY },
+ { "addPropertiesChangeListener", MethodConcept::LISTENER },
+ { "removePropertiesChangeListener", MethodConcept::LISTENER },
+ { "getPropertySetInfo", MethodConcept::PROPERTY },
+ { "setPropertyValue", MethodConcept_NORMAL_IMPL },
+ { "getPropertyValue", MethodConcept_NORMAL_IMPL },
+ { "addPropertyChangeListener", MethodConcept::LISTENER },
+ { "removePropertyChangeListener", MethodConcept::LISTENER },
+ { "addVetoableChangeListener", MethodConcept::LISTENER },
+ { "removeVetoableChangeListener", MethodConcept::LISTENER },
+ { "getElementType", MethodConcept::PROPERTY | MethodConcept::NAMECONTAINER| MethodConcept::INDEXCONTAINER | MethodConcept::ENUMERATION },
+ { "hasElements", MethodConcept::NAMECONTAINER | MethodConcept::INDEXCONTAINER | MethodConcept::ENUMERATION },
+ { "getByName", MethodConcept::NAMECONTAINER },
+ { "getElementNames", MethodConcept::PROPERTY | MethodConcept::NAMECONTAINER },
+ { "hasByName", MethodConcept::NAMECONTAINER },
+ { "getCount", MethodConcept::PROPERTY | MethodConcept::INDEXCONTAINER },
+ { "getByIndex", MethodConcept::INDEXCONTAINER },
+ { "getTypes", MethodConcept::PROPERTY },
+ { "getImplementationId", MethodConcept::PROPERTY },
+ { "queryAdapter", MethodConcept_NORMAL_IMPL },
+ { NULL, 0 }
+ };
+
+ OString aErrorStr;
+
+ //******************************************************
+
+ // Test-Objekt anlegen
+ Any aObjAny = getIntrospectionTestObject( xMgr );
+
+ // Introspection-Service holen
+ //Reference< XMultiServiceFactory > xServiceManager(getProcessServiceManager(), USR_QUERY);
+ //Reference< XIntrospection > xIntrospection( xMgr->createInstance(L"com.sun.star.beans.Introspection"), UNO_QUERY );
+ //TEST_ENSHURE( xIntrospection.is(), "Creation of introspection instance failed" );
+ //if( !xIntrospection.is() )
+ //return sal_False;
+
+ // und unspecten
+ Reference< XIntrospectionAccess > xAccess = xIntrospection->inspect( aObjAny );
+ xAccess = xIntrospection->inspect( aObjAny );
+ xAccess = xIntrospection->inspect( aObjAny );
+ TEST_ENSHURE( xAccess.is(), "introspection failed, no XIntrospectionAccess returned" );
+ if( !xAccess.is() )
+ return sal_False;
+
+ // Ergebnis der Introspection pruefen
+
+ // XPropertySet-UIK ermitteln
+ Type aType = getCppuType( (Reference< XPropertySet >*) NULL );
+ //typelib_InterfaceTypeDescription* pTypeDesc = NULL;
+ //aType.getDescription( (typelib_TypeDescription**)&pTypeDesc );
+ //Uik aPropertySetUik = *(Uik*)&pTypeDesc->aUik;
+ //typelib_typedescription_release( (typelib_TypeDescription*)pTypeDesc );
+
+ Reference< XInterface > xPropSetIface = xAccess->queryAdapter( aType );
+ //Reference< XInterface > xPropSetIface = xAccess->queryAdapter( aPropertySetUik );
+ Reference< XPropertySet > xPropSet( xPropSetIface, UNO_QUERY );
+ //XPropertySetRef xPropSet = (XPropertySet*)xPropSetIface->
+ // queryInterface( XPropertySet::getSmartUik() );
+ TEST_ENSHURE( xPropSet.is(), "Could not get XPropertySet by queryAdapter()" );
+
+ // XExactName
+ Reference< XExactName > xExactName( xAccess, UNO_QUERY );
+ TEST_ENSHURE( xExactName.is(), "Introspection unterstuetzt kein ExactName" );
+
+ // Schleife ueber alle Kombinationen von Concepts
+ for( sal_Int32 nConcepts = 0 ; nConcepts < 16 ; nConcepts++ )
+ {
+//printf( "*******************************************************\n" );
+//printf( "nConcepts = %ld\n", nConcepts );
+
+ // Wieviele Properties sollten es sein
+ sal_Int32 nDemandedPropCount = 0;
+ sal_Int32 iList = 0;
+ while( pPropertyDefs[ iList ].pName )
+ {
+ if( pPropertyDefs[ iList ].nConcept & nConcepts )
+ nDemandedPropCount++;
+ iList++;
+ }
+
+ if( xPropSet.is() )
+ {
+ Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ //Sequence<Property> aRetSeq = xPropSetInfo->getProperties();
+ Sequence<Property> aRetSeq = xAccess->getProperties( nConcepts );
+
+ sal_Int32 nLen = aRetSeq.getLength();
+
+ aErrorStr = "Expected to find ";
+ aErrorStr += OString::valueOf( nDemandedPropCount );
+ aErrorStr += " properties but found ";
+ aErrorStr += OString::valueOf( nLen );
+ TEST_ENSHURE( nLen == nDemandedPropCount, aErrorStr.getStr() );
+
+ // cout << "**********************************\n";
+ // cout << "*** Ergebnis der Introspection ***\n";
+ // cout << "**********************************\n";
+ // cout << "\nIntrospection hat " << nLen << " Properties gefunden:\n";
+
+ const Property* pProps = aRetSeq.getConstArray();
+ Any aPropVal;
+ sal_Int32 i;
+ iList = 0;
+ for( i = 0 ; i < nLen ; i++ )
+ {
+ const Property aProp = pProps[ i ];
+
+ // Naechste Passende Methode in der Liste suchen
+ while( pPropertyDefs[ iList ].pName )
+ {
+ if( pPropertyDefs[ iList ].nConcept & nConcepts )
+ break;
+ iList++;
+ }
+ sal_Int32 iDemanded = iList;
+ iList++;
+
+ OUString aPropName = aProp.Name;
+ OString aNameStr( aPropName.getStr(), aPropName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ //UStringToString(aPropName, CHARSET_SYSTEM);
+
+//printf( "Property = %s\n", aNameStr.getStr() );
+
+ OString aDemandedName = pPropertyDefs[ iDemanded ].pName;
+ //OString aDemandedName = pDemandedPropNames[ i ];
+ aErrorStr = "Expected property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", found \"";
+ aErrorStr += aNameStr;
+ aErrorStr += "\"";
+ TEST_ENSHURE( aNameStr == aDemandedName, aErrorStr.getStr() );
+ // cout << "Property " << (i+1) << ": \"" << (const char*)UStringToString(aPropName, CHARSET_SYSTEM) << "\"";
+
+
+ Type aPropType = aProp.Type;
+ OString aTypeNameStr( OUStringToOString(aPropType.getTypeName(), RTL_TEXTENCODING_ASCII_US) );
+ //Reference< XIdlClass > xPropType = aProp.Type;
+ //OString aTypeNameStr( xPropType->getName(), xPropType->getName().getLength(), RTL_TEXTENCODING_ASCII_US );
+ OString aDemandedTypeNameStr = pDemandedPropTypes[ iDemanded ];
+ //OString aDemandedTypeNameStr = pDemandedPropTypes[ i ];
+ aErrorStr = "Property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", expected type >";
+ aErrorStr += aDemandedTypeNameStr;
+ aErrorStr += "< found type >";
+ aErrorStr += aTypeNameStr;
+ aErrorStr += "<";
+ TEST_ENSHURE( aTypeNameStr == aDemandedTypeNameStr, aErrorStr.getStr() );
+ // cout << " (Prop-Typ: " << (const char*)UStringToString(xPropType->getName(), CHARSET_SYSTEM) << ")";
+
+ // Wert des Property lesen und ausgeben
+ aPropVal = xPropSet->getPropertyValue( aPropName );
+ // cout << "\n\tWert = " << (const char*)UStringToString(AnyToString( aPropVal, sal_True ), CHARSET_SYSTEM);
+
+ OString aValStr = OUStringToOString( AnyToString( aPropVal, sal_False, xMgr ), RTL_TEXTENCODING_ASCII_US );
+ OString aDemandedValStr = pDemandedPropVals[ iDemanded ];
+ //OString aDemandedValStr = pDemandedPropVals[ i ];
+ aErrorStr = "Property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", expected val >";
+ aErrorStr += aDemandedValStr;
+ aErrorStr += "< found val >";
+ aErrorStr += aValStr;
+ aErrorStr += "<";
+ TEST_ENSHURE( aValStr == aDemandedValStr, aErrorStr.getStr() );
+
+ // Wert pruefen und typgerecht modifizieren
+ TypeClass eType = aPropVal.getValueType().getTypeClass();
+ //Reference< XIdlClass > xIdlClass = aPropVal.getReflection()->getIdlClass();
+ //TypeClass eType = xIdlClass->getTypeClass();
+ Any aNewVal;
+ sal_Bool bModify = sal_True;
+ switch( eType )
+ {
+ case TypeClass_STRING:
+ {
+ OUString aStr;
+ aPropVal >>= aStr;
+ //OString aStr = aPropVal.getString();
+ aStr = aStr + OUString::createFromAscii(" (Modified!)");
+ aNewVal <<= aStr;
+ break;
+ }
+ case TypeClass_DOUBLE:
+ {
+ double d;
+ aPropVal >>= d;
+ aNewVal <<= d + 1.0;
+ break;
+ }
+ case TypeClass_SHORT:
+ {
+ sal_Int16 n;
+ aPropVal >>= n;
+ aNewVal <<= sal_Int16( n + 1 );
+ break;
+ }
+ case TypeClass_LONG:
+ {
+ sal_Int32 n;
+ aPropVal >>= n;
+ aNewVal <<= sal_Int32( n + 1 );
+ break;
+ }
+ default:
+ bModify = sal_False;
+ break;
+ }
+
+ // Modifizieren nur beim letzten Durchlauf
+ if( nConcepts == 15 )
+ {
+ // XExactName pruefen, dafuer alles gross machen
+ // (Introspection ist mit LowerCase implementiert, also anders machen)
+ OUString aUpperUStr = aPropName.toUpperCase();
+ OUString aExactName = xExactName->getExactName( aUpperUStr );
+ if( aExactName != aPropName )
+ {
+ aErrorStr = "Property \"";
+ aErrorStr += OUStringToOString( aPropName, RTL_TEXTENCODING_ASCII_US );
+ aErrorStr += "\", not found as \"";
+ aErrorStr += OUStringToOString(aUpperUStr, RTL_TEXTENCODING_ASCII_US );
+ aErrorStr += "\" using XExactName";
+ TEST_ENSHURE( sal_False, aErrorStr.getStr() );
+ }
+ }
+ else
+ {
+ bModify = sal_False;
+ }
+
+ // Neuen Wert setzen, wieder lesen und ausgeben
+ if( bModify )
+ {
+ // cout.flush();
+
+ // 1.7.1999, UnknownPropertyException bei ReadOnly-Properties abfangen
+ try
+ {
+ xPropSet->setPropertyValue( aPropName, aNewVal );
+ }
+ catch(UnknownPropertyException e1)
+ {
+ }
+
+ aPropVal = xPropSet->getPropertyValue( aPropName );
+ // cout << "\n\tModifizierter Wert = " << (const char*) UStringToString(AnyToString( aPropVal, sal_True ), CHARSET_SYSTEM) << "\n";
+
+ OUString aStr = AnyToString( aPropVal, sal_False, xMgr );
+ OString aModifiedValStr = OUStringToOString( aStr, RTL_TEXTENCODING_ASCII_US );
+ OString aDemandedModifiedValStr = pDemandedModifiedPropVals[ i ];
+ aErrorStr = "Property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", expected modified val >";
+ aErrorStr += aDemandedModifiedValStr;
+ aErrorStr += "< found val >";
+ aErrorStr += aModifiedValStr;
+ aErrorStr += "<";
+ TEST_ENSHURE( aModifiedValStr == aDemandedModifiedValStr, aErrorStr.getStr() );
+ }
+ else
+ {
+ // cout << "\n\tWert wurde nicht modifiziert\n";
+ }
+
+ // Checken, ob alle Properties auch einzeln gefunden werden
+ aErrorStr = "property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\" not found with hasProperty()";
+ OUString aWDemandedName = OStringToOUString(aDemandedName, RTL_TEXTENCODING_ASCII_US );
+ sal_Bool bProperty = xAccess->hasProperty( aWDemandedName, nConcepts );
+ //sal_Bool bProperty = xAccess->hasProperty( aWDemandedName, PropertyConcept::ALL - PropertyConcept::DANGEROUS );
+ TEST_ENSHURE( bProperty, aErrorStr.getStr() );
+
+ aErrorStr = "property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\" not equal to same Property in sequence returned by getProperties()";
+ try
+ {
+ Property aGetProp = xAccess->getProperty( aWDemandedName, nConcepts );
+ //Property aGetProp = xAccess->getProperty( aWDemandedName, PropertyConcept::ALL );
+ //TEST_ENSHURE( aGetProp == aProp , aErrorStr.getStr() );
+ }
+ catch (RuntimeException e1)
+ {
+ aErrorStr = "property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", exception was thrown when trying getProperty()";
+ TEST_ENSHURE( sal_False, aErrorStr.getStr() );
+ }
+
+ }
+ }
+ }
+
+ // Schleife ueber alle Kombinationen von Concepts
+ for( nConcepts = 0 ; nConcepts < 128 ; nConcepts++ )
+ {
+//printf( "*******************************************************\n" );
+//printf( "nConcepts = %ld\n", nConcepts );
+
+ // Das 2^6-Bit steht fuer "den Rest"
+ sal_Int32 nRealConcepts = nConcepts;
+ if( nConcepts & 0x40 )
+ nRealConcepts |= (0xFFFFFFFF - 0x3F);
+
+ // Wieviele Methoden sollten es sein
+ sal_Int32 nDemandedMethCount = 0;
+ sal_Int32 iList = 0;
+ while( pMethodDefs[ iList ].pName )
+ {
+ if( pMethodDefs[ iList ].nConcept & nRealConcepts )
+ nDemandedMethCount++;
+ iList++;
+ }
+
+ // Methoden-Array ausgeben
+ //aMethodSeq = xAccess->getMethods
+ Sequence< Reference< XIdlMethod > > aMethodSeq = xAccess->getMethods( nRealConcepts );
+ //Sequence<XIdlMethodRef> aMethodSeq = xAccess->getMethods
+ // ( MethodConcept::ALL - MethodConcept::DANGEROUS - MethodConcept::PROPERTY );
+ sal_Int32 nLen = aMethodSeq.getLength();
+ // cout << "\n\n*** Methoden ***\n";
+ // cout << "Introspection hat " << nLen << " Methoden gefunden:\n";
+
+ aErrorStr = "Expected to find ";
+ aErrorStr += OString::valueOf( nDemandedMethCount );
+ aErrorStr += " methods but found ";
+ aErrorStr += OString::valueOf( nLen );
+ TEST_ENSHURE( nLen == nDemandedMethCount, aErrorStr.getStr() );
+
+ const Reference< XIdlMethod >* pMethods = aMethodSeq.getConstArray();
+ sal_Int32 i;
+ iList = 0;
+
+ for( i = 0 ; i < nLen ; i++ )
+ {
+ // Methode ansprechen
+ const Reference< XIdlMethod >& rxMethod = pMethods[i];
+
+ // Methode ausgeben
+ OUString aMethName = rxMethod->getName();
+ OString aNameStr = OUStringToOString(aMethName, RTL_TEXTENCODING_ASCII_US );
+
+//printf( "Method = %s\n", aNameStr.getStr() );
+
+ // Naechste Passende Methode in der Liste suchen
+ while( pMethodDefs[ iList ].pName )
+ {
+ if( pMethodDefs[ iList ].nConcept & nRealConcepts )
+ break;
+ iList++;
+ }
+ OString aDemandedName = pMethodDefs[ iList ].pName;
+ iList++;
+
+ //OString aDemandedName = pDemandedMethNames[ i ];
+ aErrorStr = "Expected method \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", found \"";
+ aErrorStr += aNameStr;
+ aErrorStr += "\"";
+ TEST_ENSHURE( aNameStr == aDemandedName, aErrorStr.getStr() );
+ // cout << "Methode " << (i+1) << ": " << (const char*) UStringToString(rxMethod->getReturnType()->getName(), CHARSET_SYSTEM)
+ // << " " << (const char*) UStringToString(rxMethod->getName(), CHARSET_SYSTEM) << "( ";
+
+ // Checken, ob alle Methoden auch einzeln gefunden werden
+ aErrorStr = "method \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\" not found with hasMethod()";
+ OUString aWDemandedName = OStringToOUString(aDemandedName, RTL_TEXTENCODING_ASCII_US );
+ sal_Bool bMethod = xAccess->hasMethod( aWDemandedName, nRealConcepts );
+ //sal_Bool bMethod = xAccess->hasMethod( aWDemandedName, MethodConcept::ALL );
+ TEST_ENSHURE( bMethod, aErrorStr.getStr() );
+
+ aErrorStr = "method \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\" not equal to same method in sequence returned by getMethods()";
+ try
+ {
+ Reference< XIdlMethod > xGetMethod = xAccess->getMethod( aWDemandedName, nRealConcepts );
+ //XIdlMethodRef xGetMethod = xAccess->getMethod( aWDemandedName, MethodConcept::ALL );
+ TEST_ENSHURE( xGetMethod == rxMethod , aErrorStr.getStr() );
+ }
+ catch (RuntimeException e1)
+ {
+ aErrorStr = "method \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", exception was thrown when trying getMethod()";
+ TEST_ENSHURE( sal_False, aErrorStr.getStr() );
+ }
+ }
+ }
+
+ // Listener-Klassen ausgeben
+ Sequence< Type > aClassSeq = xAccess->getSupportedListeners();
+ sal_Int32 nLen = aClassSeq.getLength();
+ // cout << "\n\n*** Anmeldbare Listener ***\n";
+ // cout << "Introspection hat " << nLen << " Listener gefunden:\n";
+
+ const Type* pListeners = aClassSeq.getConstArray();
+ for( sal_Int32 i = 0 ; i < nLen ; i++ )
+ {
+ // Methode ansprechen
+ const Type& aListenerType = pListeners[i];
+
+ // Namen besorgen
+ OUString aListenerClassName = aListenerType.getTypeName();
+ // cout << "Listener " << (i+1) << ": " << (const char*)UStringToString(aListenerClassName, CHARSET_SYSTEM) << "\n";
+ }
+
+
+ // Performance bei hasMethod testen.
+ //CheckMethodPerformance( xAccess, "queryInterface", 100000 );
+ //CheckMethodPerformance( xAccess, "getIdlClasses", 100000 );
+
+ // cout.flush();
+
+
+
+
+ return sal_True;
+}
+
+
+
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int __cdecl main( int argc, char * argv[] )
+#endif
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory( OUString::createFromAscii("stoctest.rdb") ) );
+
+ sal_Bool bSucc = sal_False;
+ try
+ {
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstance( OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration") ), UNO_QUERY );
+ VOS_ENSHURE( xImplReg.is(), "### no impl reg!" );
+
+ // Register services
+ OUString libName;
+
+ // CoreReflection
+ ORealDynamicLoader::computeLibraryName( OUString::createFromAscii("corefl"), libName);
+ xImplReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ libName, Reference< XSimpleRegistry >() );
+ Reference< XIdlReflection > xRefl( xMgr->createInstance( OUString::createFromAscii("com.sun.star.reflection.CoreReflection") ), UNO_QUERY );
+ VOS_ENSHURE( xRefl.is(), "### no corereflection!" );
+
+ // Introspection
+ ORealDynamicLoader::computeLibraryName( OUString::createFromAscii("insp"), libName);
+ xImplReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ libName, Reference< XSimpleRegistry >() );
+ Reference< XIntrospection > xIntrosp( xMgr->createInstance( OUString::createFromAscii("com.sun.star.beans.Introspection") ), UNO_QUERY );
+ VOS_ENSHURE( xRefl.is(), "### no corereflection!" );
+
+ bSucc = test_introsp( xMgr, xRefl, xIntrosp );
+ //bSucc = test_corefl( xRefl );
+ }
+ catch (Exception & rExc)
+ {
+ VOS_ENSHURE( sal_False, "### exception occured!" );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ VOS_TRACE( "### exception occured: " );
+ VOS_TRACE( aMsg.getStr() );
+ VOS_TRACE( "\n" );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+
+ printf( "testintrosp %s !\n", (bSucc ? "succeeded" : "failed") );
+ return (bSucc ? 0 : -1);
+}
+
+
+
+
+
+
+
+//*****************************
+//*** TEST-Implementationen ***
+//*****************************
+// Bleibt auf Dauer nicht drin, dient als exportierbare Test-Klasse
+// z.B. fuer Basic-Anbindung
+
+
+
+
+
+
diff --git a/stoc/test/testintrosp.idl b/stoc/test/testintrosp.idl
new file mode 100644
index 000000000000..74d3ee7610e3
--- /dev/null
+++ b/stoc/test/testintrosp.idl
@@ -0,0 +1,255 @@
+/*************************************************************************
+ *
+ * $RCSfile: testintrosp.idl,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef __com_sun_star_beans_XIntroTest_idl__
+#define __com_sun_star_beans_XIntroTest_idl__
+
+#ifndef __com_sun_star_uno_XInterface_idl__
+#include <com/sun/star/uno/XInterface.idl>
+#endif
+
+#ifndef __com_sun_star_beans_Property_idl__
+#include <com/sun/star/beans/Property.idl>
+#endif
+
+#ifndef __com_sun_star_beans_PropertyValue_idl__
+#include <com/sun/star/beans/PropertyValue.idl>
+#endif
+
+#ifndef __com_sun_star_uno_TypeClass_idl__
+#include <com/sun/star/uno/TypeClass.idl>
+#endif
+
+#ifndef __com_sun_star_beans_XPropertiesChangeListener_idl__
+#include <com/sun/star/beans/XPropertiesChangeListener.idl>
+#endif
+
+
+//=============================================================================
+
+module ModuleA
+{
+//module com { module sun { module star { module beans {
+
+//interface XPropertyChangeListener;
+//interface XPropertiesChangeListener;
+
+//=============================================================================
+/** This is a test interface for introspection.
+
+ <p>IMPORTANT: FOR TEST ONLY!
+
+ <p>The following interface is just for testing purposes. It will not
+ stay in the product. It is only used as an exportable test class,
+ i.e. for BASIC integration.
+
+ @deprecated
+*/
+[ uik(E227A4AB-33D6-11D1-AABE00A0-249D5590), ident( "XIntroTest", 1.0 ) ]
+interface XIntroTest: com::sun::star::uno::XInterface
+{
+ //-------------------------------------------------------------------------
+ /** contains the ID-String of the implementation.
+ */
+ [attribute] string ObjectName;
+
+ //-------------------------------------------------------------------------
+ /** contains the first name of a person.
+ */
+ [readonly, attribute] string FirstName;
+
+ //-------------------------------------------------------------------------
+ /** contains the last name of a person.
+ */
+ [readonly, attribute] string LastName;
+
+ //-------------------------------------------------------------------------
+ /** contains the age of a person.
+ */
+ [readonly, attribute] short Age;
+
+ //-------------------------------------------------------------------------
+ /** contains the number of children person has.
+ */
+ [attribute] short ChildrenCount;
+
+ //-------------------------------------------------------------------------
+ /** contains a struct of type Property.
+ */
+ [attribute] com::sun::star::beans::Property FirstStruct;
+
+ //-------------------------------------------------------------------------
+ /** contains a struct of type PropertyValue.
+ */
+ [attribute] com::sun::star::beans::PropertyValue SecondStruct;
+
+ //-------------------------------------------------------------------------
+ /** Ausgabe-Methode
+ */
+ void writeln( [in] string Text );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ long getDroenk();
+
+ //-------------------------------------------------------------------------
+ /** Weitere Introspection-Test-Objekt holen
+ */
+ XIntroTest getIntroTest();
+ //com::sun::star::beans::XIntroTest getIntroTest();
+
+ //-------------------------------------------------------------------------
+ /** !!! No property, because parameter exists
+ */
+ long getUps( [in] long l );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setDroenk( [in] long l );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ short getBla();
+
+ //-------------------------------------------------------------------------
+ /** !!! Not the set method for property Bla, because param type != return type.
+ */
+ void setBla( [in] long n );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ short getBlub();
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setBlub( [in] short n );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ short getGulp();
+
+ //-------------------------------------------------------------------------
+ /** !!! Not the set method for property Gulp, because return type != void.
+ */
+ short setGulp( [in] short n );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ com::sun::star::uno::TypeClass getTypeClass( [in] short n );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setTypeClass( [in] com::sun::star::uno::TypeClass t,
+ [in] double d1,
+ [in] double d2 );
+
+ //-------------------------------------------------------------------------
+ /**
+ */
+ sequence<string> getStrings();
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setStrings( [in] sequence<string> Strings );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setStringsPerMethod( [in] sequence<string> Strings,
+ [in] short n );
+
+ //-------------------------------------------------------------------------
+ /**
+ */
+ sequence< sequence< sequence< short > > > getMultiSequence();
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setMultiSequence( [in] sequence< sequence< sequence< short > > > Seq );
+
+ //-------------------------------------------------------------------------
+ /**Add a PropertiesChangeListener
+ */
+ [oneway] void addPropertiesChangeListener( [in] sequence< string > PropertyNames,
+ [in] com::sun::star::beans::XPropertiesChangeListener Listener );
+
+ //-------------------------------------------------------------------------
+ /**Remove a PropertiesChangeListener
+ */
+ [oneway] void removePropertiesChangeListener( [in] com::sun::star::beans::XPropertiesChangeListener Listener );
+
+};
+
+//=============================================================================
+
+};
+//}; }; }; };
+
+#endif
diff --git a/stoc/test/testloader.cxx b/stoc/test/testloader.cxx
new file mode 100644
index 000000000000..c2a664f46eed
--- /dev/null
+++ b/stoc/test/testloader.cxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * $RCSfile: testloader.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#ifndef _VOS_MODULE_HXX_
+#include <vos/module.hxx>
+#endif
+#ifndef _VOS_DIAGNOSE_HXX_
+#include <vos/diagnose.hxx>
+#endif
+
+
+#include <com/sun/star/loader/XImplementationLoader.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _VOS_DYNLOAD_HXX_
+#include <vos/dynload.hxx>
+#endif
+
+#if defined ( UNX ) || defined ( MAC )
+#include <limits.h>
+#define _MAX_PATH PATH_MAX
+#endif
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::loader;
+using namespace com::sun::star::lang;
+using namespace vos;
+using namespace rtl;
+
+#ifdef _DEBUG
+#define TEST_ENSHURE(c, m) VOS_ENSHURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) VOS_VERIFY(c)
+#endif
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ Reference<XInterface> xIFace;
+
+ OModule* pModule = new OModule(OUString());
+
+ OUString dllName;
+ NAMESPACE_VOS(ORealDynamicLoader)::computeLibraryName(OUString::createFromAscii("cpld"), dllName);
+
+ if (pModule->load(dllName))
+ {
+ // try to get provider from module
+ component_getFactoryFunc pCompFactoryFunc = (component_getFactoryFunc)
+ pModule->getSymbol( OUString::createFromAscii(COMPONENT_GETFACTORY) );
+
+ if (pCompFactoryFunc)
+ {
+ XSingleServiceFactory * pRet = (XSingleServiceFactory *)(*pCompFactoryFunc)(
+ "com.sun.star.comp.stoc.DLLComponentLoader", 0, 0 );
+ if (pRet)
+ {
+ xIFace = pRet;
+ pRet->release();
+ }
+ }
+ }
+
+ TEST_ENSHURE( xIFace.is(), "testloader error1");
+
+ Reference<XSingleServiceFactory> xFactory( Reference<XSingleServiceFactory>::query(xIFace) );
+
+ TEST_ENSHURE( xFactory.is(), "testloader error2");
+
+ Reference<XInterface> xLoader = xFactory->createInstance();
+
+ TEST_ENSHURE( xLoader.is(), "testloader error3");
+
+ Reference<XServiceInfo> xServInfo( Reference<XServiceInfo>::query(xLoader) );
+
+ TEST_ENSHURE( xServInfo.is(), "testloader error4");
+
+ TEST_ENSHURE( xServInfo->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.comp.stoc.DLLComponentLoader") ), "testloader error5");
+ TEST_ENSHURE( xServInfo->supportsService(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")) ), "testloader error6");
+ TEST_ENSHURE( xServInfo->getSupportedServiceNames().getLength() == 1, "testloader error7");
+
+ xIFace.clear();
+ xFactory.clear();
+ xLoader.clear();
+ xServInfo.clear();
+
+ delete pModule;
+
+ printf("Test Dll ComponentLoader, OK!\n");
+
+ return(0);
+}
+
+
diff --git a/stoc/test/testproxyfac.cxx b/stoc/test/testproxyfac.cxx
new file mode 100644
index 000000000000..61772e08be74
--- /dev/null
+++ b/stoc/test/testproxyfac.cxx
@@ -0,0 +1,243 @@
+/*************************************************************************
+ *
+ * $RCSfile: testproxyfac.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <osl/diagnose.h>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/queryinterface.hxx>
+
+#include <com/sun/star/uno/XAggregation.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/util/XProxyFactory.hpp>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <stdio.h>
+
+
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+
+static sal_Int32 s_n = 0;
+
+//==================================================================================================
+class Test1 : public WeakImplHelper2< XServiceInfo, XProxyFactory >
+{
+public:
+ virtual ~Test1()
+ { ++s_n; }
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (RuntimeException)
+ { return OUString::createFromAscii( "a" ); }
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException)
+ { return sal_False; }
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException)
+ { return Sequence< OUString >(); }
+ // XProxyFactory
+ virtual Reference< XAggregation > SAL_CALL createProxy( const Reference< XInterface > & xTarget ) throw (RuntimeException)
+ { return Reference< XAggregation >(); }
+};
+//==================================================================================================
+class Test2 : public WeakImplHelper1< XServiceInfo >
+{
+ Reference< XAggregation > _xAgg;
+public:
+ static Reference< XInterface > createTest2( const Reference< XAggregation > & xAgg )
+ {
+ Test2 * p = new Test2();
+ Reference< XInterface > xRet( (XInterface *)(XServiceInfo *)p );
+ p->_xAgg = xAgg;
+ xAgg->release(); // ref to 1
+ p->acquire(); // for xAgg dtor
+ p->_xAgg->setDelegator( xRet );
+ return xRet;
+ }
+ virtual ~Test2()
+ { ++s_n; }
+
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw (RuntimeException)
+ {
+ Any aRet( OWeakObject::queryInterface( rType ) );
+ if (! aRet.hasValue())
+ {
+ aRet = cppu::queryInterface( rType, (XServiceInfo *)this );
+ if (! aRet.hasValue())
+ return _xAgg->queryAggregation( rType );
+ }
+ return aRet;
+ }
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (RuntimeException)
+ { return OUString::createFromAscii( "b" ); }
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException)
+ { return sal_False; }
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException)
+ { return Sequence< OUString >(); }
+};
+
+static sal_Bool test_proxyfac( const Reference< XProxyFactory > & xProxyFac )
+{
+ {
+ Reference< XServiceInfo > x1( new Test1() );
+ Reference< XServiceInfo > x1p( xProxyFac->createProxy( x1 ), UNO_QUERY );
+// if (x1->getImplementationName() != x1p->getImplementationName() ||
+// !x1->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ))
+// {
+// return sal_False;
+// }
+// if (x1 == x1p)
+// return sal_False;
+ //
+
+ Reference< XAggregation > xAgg( xProxyFac->createProxy( x1 ) );
+ Reference< XInterface > xMaster( Test2::createTest2( xAgg ) );
+
+ Reference< XServiceInfo > x2( xMaster, UNO_QUERY );
+ Test2 * pt2 = static_cast< Test2 * >( x2.get() );
+
+ if ((Test2 *)(XServiceInfo *)xMaster.get() != pt2 ||
+ !pt2->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("b") ) ||
+ !x2->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("b") ))
+ {
+ return sal_False;
+ }
+
+ if (x2 == x1 || x2 == x1p)
+ return sal_False;
+ if (x2 != xAgg)
+ return sal_False;
+
+ if (x1->getImplementationName() == x2->getImplementationName() ||
+ x1p->getImplementationName() == x2->getImplementationName())
+ {
+ return sal_False;
+ }
+
+ if (s_n)
+ return sal_False;
+ }
+ return s_n == 2;
+}
+
+#ifdef UNX
+#define REG_PREFIX "lib"
+#define DLL_POSTFIX ".so"
+#else
+#define REG_PREFIX ""
+#define DLL_POSTFIX ".dll"
+#endif
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int __cdecl main( int argc, char * argv[] )
+#endif
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
+
+ sal_Bool bSucc = sal_False;
+ try
+ {
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.ImplementationRegistration") ) ), UNO_QUERY );
+ OSL_ENSHURE( xImplReg.is(), "### no impl reg!" );
+
+ OUString aLibName( OUString::createFromAscii(REG_PREFIX) );
+ aLibName += OUString::createFromAscii("proxyfac");
+#ifndef OS2
+ aLibName += OUString::createFromAscii(DLL_POSTFIX);
+#endif
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), aLibName, Reference< XSimpleRegistry >() );
+
+ Reference< XProxyFactory > xProxyFac( xMgr->createInstance( OUString::createFromAscii("com.sun.star.util.ProxyFactory") ), UNO_QUERY );
+ OSL_ENSHURE( xProxyFac.is(), "### no proxy factory!" );
+
+ bSucc = test_proxyfac( xProxyFac );
+ }
+ catch (Exception & rExc)
+ {
+ OSL_ENSHURE( sal_False, "### exception occured!" );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### exception occured: " );
+ OSL_TRACE( aMsg.getStr() );
+ OSL_TRACE( "\n" );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+
+ printf( "testproxyfac %s !\n", (bSucc ? "succeeded" : "failed") );
+ return (bSucc ? 0 : -1);
+}
diff --git a/stoc/test/testregistry.cxx b/stoc/test/testregistry.cxx
new file mode 100644
index 000000000000..8ff0cf91bd36
--- /dev/null
+++ b/stoc/test/testregistry.cxx
@@ -0,0 +1,671 @@
+/*************************************************************************
+ *
+ * $RCSfile: testregistry.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef _VOS_MODULE_HXX_
+#include <vos/module.hxx>
+#endif
+#ifndef _VOS_DIAGNOSE_HXX_
+#include <vos/diagnose.hxx>
+#endif
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+#ifndef _VOS_DYNLOAD_HXX_
+#include <vos/dynload.hxx>
+#endif
+
+#ifndef _REGISTRY_REGISTRY_HXX_
+#include <registry/registry.hxx>
+#endif
+
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+#if defined ( UNX ) || defined ( MAC )
+#include <limits.h>
+#define _MAX_PATH PATH_MAX
+#endif
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace vos;
+using namespace rtl;
+
+#ifdef _DEBUG
+#define TEST_ENSHURE(c, m) VOS_ENSHURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) VOS_VERIFY(c)
+#endif
+
+OString userRegEnv("STAR_USER_REGISTRY=");
+
+OUString getExePath()
+{
+ OStartupInfo startupInfo;
+ OUString exe;
+
+ VOS_VERIFY(startupInfo.getExecutableFile(exe) == OStartupInfo::E_None);
+
+#if defined(WIN32) || defined(__OS2__) || defined(WNT)
+ exe = exe.copy(0, exe.getLength() - 16);
+#else
+ exe = exe.copy(0, exe.getLength() - 12);
+#endif
+ return exe;
+}
+
+void setStarUserRegistry()
+{
+ RegistryLoader* pLoader = new RegistryLoader();
+
+ if (!pLoader->isLoaded())
+ {
+ delete pLoader;
+ return;
+ }
+
+ Registry *myRegistry = new Registry(*pLoader);
+ delete pLoader;
+
+ RegistryKey rootKey, rKey, rKey2;
+
+ OUString userReg = getExePath();
+ userReg += OUString::createFromAscii("user.rdb");
+ if(myRegistry->open(userReg, REG_READWRITE))
+ {
+ TEST_ENSHURE(!myRegistry->create(userReg), "setStarUserRegistry error 1");
+ }
+
+ TEST_ENSHURE(!myRegistry->close(), "setStarUserRegistry error 9");
+ delete myRegistry;
+
+ userRegEnv += OUStringToOString(userReg, RTL_TEXTENCODING_ASCII_US);
+ putenv((char *)userRegEnv.getStr());
+}
+
+void setLinkInDefaultRegistry(const OUString& linkName, const OUString& linkTarget)
+{
+ RegistryLoader* pLoader = new RegistryLoader();
+
+ if (!pLoader->isLoaded())
+ {
+ delete pLoader;
+ return;
+ }
+
+ Registry *myRegistry = new Registry(*pLoader);
+ delete pLoader;
+
+ RegistryKey rootKey;
+
+ OUString appReg = getExePath();
+ appReg += OUString::createFromAscii("stoctest.rdb");
+
+ TEST_ENSHURE(!myRegistry->open(appReg, REG_READWRITE), "setLinkInDefaultRegistry error 1");
+ TEST_ENSHURE(!myRegistry->openRootKey(rootKey), "setLinkInDefaultRegistry error 2");
+
+ TEST_ENSHURE(!rootKey.createLink(linkName, linkTarget), "setLinkInDefaultRegistry error 3");
+
+ TEST_ENSHURE(!rootKey.closeKey(), "setLinkInDefaultRegistry error 4");
+ TEST_ENSHURE(!myRegistry->close(), "setLinkInDefaultRegistry error 5");
+
+ delete myRegistry;
+}
+
+
+void test_SimpleRegistry()
+{
+ Reference<XInterface> xIFace;
+ OModule* pModule = new OModule(OUString());
+
+ OUString dllName;
+ NAMESPACE_VOS(ORealDynamicLoader)::computeLibraryName(OUString::createFromAscii("simreg"), dllName);
+
+ if (pModule->load(dllName))
+ {
+ // try to get provider from module
+ component_getFactoryFunc pCompFactoryFunc = (component_getFactoryFunc)
+ pModule->getSymbol( OUString::createFromAscii(COMPONENT_GETFACTORY) );
+
+ if (pCompFactoryFunc)
+ {
+ XSingleServiceFactory * pRet = (XSingleServiceFactory *)(*pCompFactoryFunc)(
+ "com.sun.star.comp.stoc.SimpleRegistry", 0, 0 );
+ if (pRet)
+ {
+ xIFace = pRet;
+ pRet->release();
+ }
+ }
+ }
+
+ TEST_ENSHURE( xIFace.is(), "test_SimpleRegistry error1");
+
+ Reference<XSingleServiceFactory> xFactory( Reference<XSingleServiceFactory>::query(xIFace) );
+ xIFace.clear();
+
+ TEST_ENSHURE( xFactory.is(), "testloader error11");
+
+ Reference<XInterface> xIFace2 = xFactory->createInstance();
+ xFactory.clear();
+
+ TEST_ENSHURE( xIFace2.is(), "testloader error12");
+
+ Reference<XServiceInfo> xServInfo( Reference<XServiceInfo>::query(xIFace2) );
+
+ TEST_ENSHURE( xServInfo.is(), "test_SimpleRegistry error2");
+
+ TEST_ENSHURE( xServInfo->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.comp.stoc.SimpleRegistry") ), "test_SimpleRegistry error3");
+ TEST_ENSHURE( xServInfo->supportsService(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.SimpleRegistry"))), "test_SimpleRegistry error4");
+ TEST_ENSHURE( xServInfo->getSupportedServiceNames().getLength() == 1, "test_SimpleRegistry error5");
+ xServInfo.clear();
+
+ Reference<XSimpleRegistry> xReg( Reference<XSimpleRegistry>::query(xIFace2) );
+ xIFace2.clear();
+
+ TEST_ENSHURE( xReg.is(), "test_SimpleRegistry error6");
+
+ try
+ {
+ xReg->open(OUString( RTL_CONSTASCII_USTRINGPARAM("testreg.rdb") ), sal_False, sal_True);
+
+ TEST_ENSHURE( xReg->isValid() != sal_False, "test_SimpleRegistry error 7" );
+ TEST_ENSHURE( xReg->isReadOnly() == sal_False, "test_SimpleRegistry error 8" );
+
+ Reference<XRegistryKey> xRootKey(xReg->getRootKey());
+ TEST_ENSHURE( xRootKey->isValid(), "test_SimpleRegistry error 9" );
+
+ Reference<XRegistryKey> xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FirstKey") ));
+
+ Reference<XRegistryKey> xSubKey = xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FirstSubKey") ));
+ xSubKey->setLongValue(123456789);
+
+ xSubKey = xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SecondSubKey") ));
+ xSubKey->setAsciiValue(OUString( RTL_CONSTASCII_USTRINGPARAM("ich bin ein acsii value") ));
+
+ xSubKey = xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("ThirdSubKey") ));
+ xSubKey->setStringValue(OUString( RTL_CONSTASCII_USTRINGPARAM("ich bin ein unicode value") ));
+
+ xSubKey = xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FourthSubKey") ));
+ Sequence<sal_Int8> aSeq((sal_Int8*)"ich bin ein binary value", 25);
+ xSubKey->setBinaryValue(aSeq);
+
+ Sequence<OUString> seqNames = xKey->getKeyNames();
+ Sequence< Reference<XRegistryKey> > seqKeys = xKey->openKeys();
+
+ OUString name;
+ for (sal_Int32 i=0; i < seqNames.getLength(); i++)
+ {
+ name = seqNames.getArray()[i];
+ xSubKey = seqKeys.getArray()[i];
+
+ if (name == OUString( RTL_CONSTASCII_USTRINGPARAM("/FirstKey/FirstSubKey") ))
+ {
+ TEST_ENSHURE( xSubKey->getLongValue() == 123456789,
+ "test_SimpleRegistry error 10" );
+ } else
+ if (name == OUString( RTL_CONSTASCII_USTRINGPARAM("/FirstKey/SecondSubKey") ))
+ {
+ TEST_ENSHURE( xSubKey->getAsciiValue() == OUString( RTL_CONSTASCII_USTRINGPARAM("ich bin ein acsii value") ),
+ "test_SimpleRegistry error 11" );
+ } else
+ if (name == OUString( RTL_CONSTASCII_USTRINGPARAM("/FirstKey/ThirdSubKey") ))
+ {
+ TEST_ENSHURE( xSubKey->getStringValue() == OUString( RTL_CONSTASCII_USTRINGPARAM("ich bin ein unicode value") ),
+ "test_SimpleRegistry error 12" );
+ } else
+ if (name == OUString( RTL_CONSTASCII_USTRINGPARAM("/FirstKey/FourthSubKey") ))
+ {
+ Sequence<sal_Int8> seqByte = xSubKey->getBinaryValue();
+ TEST_ENSHURE(!strcmp(((const char*)seqByte.getArray()), "ich bin ein binary value"),
+ "test_SimpleRegistry error 13" );
+ }
+
+ seqKeys.getArray()[i]->closeKey();
+ }
+
+ xKey->closeKey();
+
+ xRootKey->deleteKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FirstKey") ));
+ xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SecondFirstKey" )));
+
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SecondKey") ));
+ sal_Int32 pLongs[3] = {123, 456, 789};
+ Sequence<sal_Int32> seqLongs(pLongs, 3);
+ xKey->setLongListValue(seqLongs);
+
+ Sequence<sal_Int32> seqLongs2;
+ seqLongs2 = xKey->getLongListValue();
+ TEST_ENSHURE( seqLongs.getLength() == 3, "test_SimpleRegistry error 14" );
+ TEST_ENSHURE( seqLongs.getArray()[0] == 123, "test_SimpleRegistry error 15" );
+ TEST_ENSHURE( seqLongs.getArray()[1] == 456, "test_SimpleRegistry error 16" );
+ TEST_ENSHURE( seqLongs.getArray()[2] == 789, "test_SimpleRegistry error 17" );
+
+
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("ThirdKey") ));
+ OUString pAscii[3];
+ pAscii[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") );
+ pAscii[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") );
+ pAscii[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("ich") );
+
+ Sequence<OUString> seqAscii(pAscii, 3);
+ xKey->setAsciiListValue(seqAscii);
+
+ Sequence<OUString> seqAscii2;
+ seqAscii2 = xKey->getAsciiListValue();
+ TEST_ENSHURE( seqAscii2.getLength() == 3, "test_SimpleRegistry error 18" );
+ TEST_ENSHURE( seqAscii2.getArray()[0] == OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") ), "test_SimpleRegistry error 19");
+ TEST_ENSHURE( seqAscii2.getArray()[1] == OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") ), "test_SimpleRegistry error 20");
+ TEST_ENSHURE( seqAscii2.getArray()[2] == OUString( RTL_CONSTASCII_USTRINGPARAM("ich") ), "test_SimpleRegistry error 21");
+
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FourthKey") ));
+ OUString pUnicode[3];
+ pUnicode[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") );
+ pUnicode[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") );
+ pUnicode[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("ich als unicode") );
+
+ Sequence<OUString> seqUnicode(pUnicode, 3);
+ xKey->setStringListValue(seqUnicode);
+
+ Sequence<OUString> seqUnicode2;
+ seqUnicode2 = xKey->getStringListValue();
+ TEST_ENSHURE( seqUnicode2.getLength() == 3, "test_SimpleRegistry error 22" );
+ TEST_ENSHURE( seqUnicode2.getArray()[0] == OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") ), "test_SimpleRegistry error 23");
+ TEST_ENSHURE( seqUnicode2.getArray()[1] == OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") ), "test_SimpleRegistry error 24");
+ TEST_ENSHURE( seqUnicode2.getArray()[2] == OUString( RTL_CONSTASCII_USTRINGPARAM("ich als unicode") ), "test_SimpleRegistry error 25");
+
+
+ xReg->open(OUString( RTL_CONSTASCII_USTRINGPARAM("testreg2.rdb") ), False, True);
+ TEST_ENSHURE( xReg->isValid() != sal_False, "test_SimpleRegistry error 25" );
+ xRootKey = xReg->getRootKey();
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("ThirdKey/FirstSubKey/WithSubSubKey") ));
+ xKey->closeKey();
+ xRootKey->closeKey();
+ xReg->close();
+
+ xReg->open(OUString( RTL_CONSTASCII_USTRINGPARAM("testreg.rdb") ), False, False);
+ TEST_ENSHURE( xReg->isValid() != sal_False, "test_SimpleRegistry error 26" );
+
+ xReg->mergeKey(OUString(), OUString( RTL_CONSTASCII_USTRINGPARAM("testreg2.rdb") ));
+
+ xRootKey = xReg->getRootKey();
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FirstKey/SecondSubKey") ));
+ TEST_ENSHURE( !xKey.is(), "test_SimpleRegistry error 27" );
+
+ // Test Links
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FifthKey") ));
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("MyFirstLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/ThirdKey/FirstSubKey") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/FifthKey/MyFirstLink") ));
+ TEST_ENSHURE( xKey->isValid(), "test_SimpleRegistry error 27" );
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/ThirdKey/FirstSubKey") ), "test_SimpleRegistry error 28" );
+
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ));
+
+ TEST_ENSHURE( xKey->getLinkTarget(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ), "test_SimpleRegistry error 29" );
+
+ try
+ {
+ TEST_ENSHURE( xKey->getResolvedName(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink/BlaBlaBla") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink/BlaBlaBla") ), "test_SimpleRegistry error 30" );
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ xRootKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/MyThirdLink") ));
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SixthKey") ));
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("MyThirdLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ));
+
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/SixthSubKey") ));
+
+ try
+ {
+ xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ));
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ TEST_ENSHURE( xRootKey->getLinkTarget(OUString( RTL_CONSTASCII_USTRINGPARAM("/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ), "test_SimpleRegistry error 31" );
+
+ xRootKey->deleteLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ));
+
+ xRootKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/ThirdKey/FirstSubKey/WithSubSubKey") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SixthKey") ));
+ seqNames = xKey->getKeyNames();
+ seqKeys = xKey->openKeys();
+
+ TEST_ENSHURE( seqNames.getArray()[0] == OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/SixthSubKey") ),
+ "test_SimpleRegistry error 32" );
+ TEST_ENSHURE( seqNames.getArray()[1] == OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/MyThirdLink") ),
+ "test_SimpleRegistry error 33" );
+
+ TEST_ENSHURE( seqKeys.getArray()[0]->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/SixthSubKey") ),
+ "test_SimpleRegistry error 34" );
+ TEST_ENSHURE( seqKeys.getArray()[1]->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/ThirdKey/FirstSubKey/WithSubSubKey") ),
+ "test_SimpleRegistry error 35" );
+
+ xRootKey->deleteLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ));
+
+// xRootKey->closeKey();
+
+// xReg->open(L"testreg2.rdb", False, True);
+// xReg->destroy();
+ }
+ catch(InvalidRegistryException&)
+ {
+ TEST_ENSHURE(0, "exception InvalidRegistryExcption raised while doing test_SimpleRegistry");
+ }
+ catch(InvalidValueException&)
+ {
+ TEST_ENSHURE(0, "exception InvalidValueExcption raised while doing test_SimpleRegistry()");
+ }
+
+ xReg.clear();
+
+ delete pModule;
+
+ printf("Test SimpleRegistry, OK!\n");
+}
+
+
+void test_DefaultRegistry()
+{
+// Reference < XMultiServiceFactory > rSMgr = ::cppu::createDefaultRegistryServiceFactory( );
+
+ // Test NestedRegistry
+ OUString exePath( getExePath() );
+ OUString userRdb(exePath);
+ OUString applicatRdb(exePath);
+
+ userRdb += OUString::createFromAscii("user.rdb");
+ applicatRdb += OUString::createFromAscii("stoctest.rdb");
+
+ Reference < XMultiServiceFactory > rSMgr = ::cppu::createRegistryServiceFactory( userRdb, applicatRdb, sal_False,
+ OUString::createFromAscii("//./e:/src596/stoc/wntmsci3/bin") );
+
+ Reference< XPropertySet > xPropSet( rSMgr, UNO_QUERY);
+ TEST_ENSHURE( xPropSet.is(), "test_DefaultRegistry error0");
+
+ Any aPropertyAny( xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Registry")) ) );
+ TEST_ENSHURE( aPropertyAny.hasValue(), "test_DefaultRegistry error1");
+
+ Reference<XSimpleRegistry> xReg;
+ aPropertyAny >>= xReg;
+ TEST_ENSHURE( xReg.is(), "test_DefaultRegistry error1a");
+
+ Reference<XServiceInfo> xServInfo( Reference<XServiceInfo>::query(xReg) );
+
+ TEST_ENSHURE( xServInfo.is(), "test_DefaultRegistry error2");
+
+ TEST_ENSHURE( xServInfo->getImplementationName() == OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.NestedRegistry") ), "test_DefualtRegistry error3");
+ TEST_ENSHURE( xServInfo->supportsService(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.NestedRegistry") )), "test_DefaultRegistry error4");
+ TEST_ENSHURE( xServInfo->getSupportedServiceNames().getLength() == 1, "test_DefaultRegistry error5");
+ xServInfo.clear();
+
+ TEST_ENSHURE( xReg.is(), "test_DefaultRegistry error6");
+
+ try
+ {
+ Reference<XRegistryKey> xRootKey(xReg->getRootKey());
+
+ Reference<XRegistryKey> xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/UCR/com/sun/star/registry/XSimpleRegistry") ));
+
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/UCR/com/sun/star/registry/XSimpleRegistry") ),
+ "test_DefaultRegistry error 7" );
+
+ xReg->mergeKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("testreg.rdb") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test/ThirdKey/FirstSubKey/WithSubSubKey") ));
+ if (xKey.is())
+ xKey->setLongValue(123456789);
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test/ThirdKey/FirstSubKey") ));
+ if (xKey.is())
+ {
+ xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SecondSubSubKey") ));
+
+ Sequence<OUString> seqNames = xKey->getKeyNames();
+
+ TEST_ENSHURE( seqNames.getLength() == 2, "test_DefaultRegistry error 8" );
+ }
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey") ));
+ if (xKey.is())
+ {
+ RegistryValueType valueType = xKey->getValueType();
+ TEST_ENSHURE( valueType == RegistryValueType_ASCIILIST, "test_DefaultRegistry error 9" );
+
+ Sequence<OUString> seqValue = xKey->getAsciiListValue();
+
+ TEST_ENSHURE( seqValue.getLength() == 3, "test_DefaultRegistry error 10" );
+ TEST_ENSHURE( seqValue.getArray()[0] == OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") ),
+ "test_DefaultRegistry error 11" );
+ TEST_ENSHURE( seqValue.getArray()[1] == OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") ),
+ "test_DefaultRegistry error 12" );
+ TEST_ENSHURE( seqValue.getArray()[2] == OUString( RTL_CONSTASCII_USTRINGPARAM("ich") ),
+ "test_DefaultRegistry error 13" );
+
+ Sequence<sal_Int32> seqLong(3);
+ seqLong.getArray()[0] = 1234;
+ seqLong.getArray()[1] = 4567;
+ seqLong.getArray()[2] = 7890;
+
+ xKey->setLongListValue(seqLong);
+
+ Sequence<sal_Int32> seqLongValue = xKey->getLongListValue();
+
+ TEST_ENSHURE( seqLongValue.getLength() == 3, "test_DefaultRegistry error 14" );
+ TEST_ENSHURE( seqLongValue.getArray()[0] == 1234, "test_DefaultRegistry error 15" );
+ TEST_ENSHURE( seqLongValue.getArray()[1] == 4567, "test_DefaultRegistry error 16" );
+ TEST_ENSHURE( seqLongValue.getArray()[2] == 7890, "test_DefaultRegistry error 17" );
+ }
+
+ // Test Links
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey") ));
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("MyFirstLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey/FirstSubKey") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey/MyFirstLink") ));
+ TEST_ENSHURE( xKey->isValid(), "test_DefaultRegistry error 18" );
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey/FirstSubKey") ),
+ "test_DefaultRegistry error 19" );
+
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ));
+
+ TEST_ENSHURE( xKey->getLinkTarget(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ),
+ "test_DefaultRegistry error 20" );
+
+ try
+ {
+ TEST_ENSHURE( xKey->getResolvedName(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink/BlaBlaBla") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink/BlaBlaBla") ),
+ "test_DefaultRegistry error 21" );
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ xRootKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/SixthKey/MyThirdLink") ));
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/SixthKey") ));
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("MyThirdLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ));
+
+ try
+ {
+ xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ));
+ }
+ catch(InvalidRegistryException&)
+ {
+ printf("test InvalidRegistryExcption OK!\n");
+ }
+
+ TEST_ENSHURE( xRootKey->getLinkTarget(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ),
+ "test_DefaultRegistry error 22" );
+
+ xRootKey->deleteLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/DefaultLink/SecondSubSubKey") ));
+ if (xKey.is())
+ {
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey/FirstSubKey/SecondSubSubKey") ), "test_DefaultRegistry error 23" );
+ }
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/DefaultLink/ThirdSubSubKey") ));
+ if (xKey.is())
+ {
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey/FirstSubKey/ThirdSubSubKey") ),
+ "test_DefaultRegistry error 24" );
+ }
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test") ));
+ TEST_ENSHURE( xKey->isValid(), "test_DefaultRegistry error 25" );
+
+ xRootKey->deleteKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test") ));
+
+ xReg->mergeKey(OUString( RTL_CONSTASCII_USTRINGPARAM("AllFromTestreg2") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("testreg2.rdb") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/AllFromTestreg2/ThirdKey/FirstSubKey") ));
+ if (xKey.is())
+ {
+ xRootKey->deleteKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/AllFromTestreg2") ));
+ }
+/*
+ Reference<XSimpleRegistry> xSimplReg( xMgr->createInstance(L"com.sun.star.registry.SimpleRegistry"), USR_QUERY );
+
+ xSimplReg->open(L"testreg2.rdb", False, True);
+ xSimplReg->destroy();
+
+ xSimplReg->open(L"testreg.rdb", False, True);
+ xSimplReg->destroy();
+*/
+ }
+ catch(InvalidRegistryException&)
+ {
+ TEST_ENSHURE(0, "exception InvalidRegistryExcption raised while doing test_DefaultRegistry");
+ }
+ catch(InvalidValueException&)
+ {
+ TEST_ENSHURE(0, "exception InvalidValueExcption raised while doing test_DefaultRegistry()");
+ }
+ xReg.clear();
+
+ // shutdown
+ Reference< ::com::sun::star::lang::XComponent > xComp( rSMgr, UNO_QUERY );
+ VOS_ENSHURE( xComp.is(), "### serivce manager has to implement XComponent!" );
+ xComp->dispose();
+
+ printf("Test DefaultRegistry, OK!\n");
+}
+
+
+
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ setStarUserRegistry();
+ setLinkInDefaultRegistry(OUString::createFromAscii("/Test/DefaultLink"),
+ OUString::createFromAscii("/Test/FifthKey/MyFirstLink"));
+
+ test_SimpleRegistry();
+ test_DefaultRegistry();
+
+ return(0);
+}
+
+
diff --git a/stoc/test/testsmgr.cxx b/stoc/test/testsmgr.cxx
new file mode 100644
index 000000000000..a711898bad74
--- /dev/null
+++ b/stoc/test/testsmgr.cxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * $RCSfile: testsmgr.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <stdio.h>
+#ifndef _VOS_MODULE_HXX_
+#include <vos/module.hxx>
+#endif
+#ifndef _VOS_DIAGNOSE_HXX_
+#include <vos/diagnose.hxx>
+#endif
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+#ifndef _VOS_DYNLOAD_HXX_
+#include <vos/dynload.hxx>
+#endif
+
+#ifndef _REGISTRY_REGISTRY_HXX_
+#include <registry/registry.hxx>
+#endif
+
+#ifndef _UNO_MAPPING_HXX_
+#include <uno/mapping.hxx>
+#endif
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#include "testsmgr_cpnt/testsmgr_cpnt.hxx"
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifdef _DEBUG
+#define TEST_ENSHURE(c, m) VOS_ENSHURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) VOS_VERIFY(c)
+#endif
+
+
+using namespace ::rtl;
+using namespace ::vos;
+OString userRegEnv("STAR_USER_REGISTRY=");
+
+OUString getExePath()
+{
+ OStartupInfo startupInfo;
+ OUString exe;
+
+ VOS_VERIFY(startupInfo.getExecutableFile(exe) == OStartupInfo::E_None);
+
+#if defined(WIN32) || defined(__OS2__) || defined(WNT)
+ exe = exe.copy(0, exe.getLength() - 16);
+#else
+ exe = exe.copy(0, exe.getLength() - 12);
+#endif
+ return exe;
+}
+
+void setStarUserRegistry()
+{
+ RegistryLoader* pLoader = new RegistryLoader();
+
+ if (!pLoader->isLoaded())
+ {
+ delete pLoader;
+ return;
+ }
+
+ Registry *myRegistry = new Registry(*pLoader);
+ delete pLoader;
+
+ RegistryKey rootKey, rKey, rKey2;
+
+ OUString userReg = getExePath();
+ userReg += OUString::createFromAscii("user.rdb");
+ if(myRegistry->open(userReg, REG_READWRITE))
+ {
+ TEST_ENSHURE(!myRegistry->create(userReg), "setStarUserRegistry error 1");
+ }
+
+ TEST_ENSHURE(!myRegistry->close(), "setStarUserRegistry error 9");
+ delete myRegistry;
+
+ userRegEnv += OUStringToOString(userReg, RTL_TEXTENCODING_ASCII_US);
+ putenv((char *)userRegEnv.getStr());
+}
+
+
+
+void SAL_CALL main()
+{
+ printf( "ServiceManagerTest : \r");
+ setStarUserRegistry();
+ fflush( stdout );
+ test_ServiceManager();
+
+ printf( "ServiceManagerTest : OK\n" );
+}
diff --git a/stoc/unosdk.mk b/stoc/unosdk.mk
new file mode 100644
index 000000000000..8dce4dc6c673
--- /dev/null
+++ b/stoc/unosdk.mk
@@ -0,0 +1,69 @@
+#*************************************************************************
+#
+# $RCSfile: unosdk.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:33 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PPATH=inc
+
+FILES= \
+ $(PPATH)\stoc\component.hxx
+
+unosdk: $(FILES)
+ docpp -H -m -f -u -d ..\..\doc\stoc $(FILES)
diff --git a/unoil/prj/d.lst b/unoil/prj/d.lst
new file mode 100644
index 000000000000..fc59dec761f2
--- /dev/null
+++ b/unoil/prj/d.lst
@@ -0,0 +1 @@
+..\%__SRC%\class\unoil.jar %_DEST%\bin%_EXT%\unoil.jar
diff --git a/unoil/util/makefile.mk b/unoil/util/makefile.mk
new file mode 100644
index 000000000000..112c95274752
--- /dev/null
+++ b/unoil/util/makefile.mk
@@ -0,0 +1,79 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:28:28 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..
+PRJNAME = unoil
+TARGET = unoil
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = com
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/xml2cmp/prj/d.lst b/xml2cmp/prj/d.lst
new file mode 100644
index 000000000000..868797deba5d
--- /dev/null
+++ b/xml2cmp/prj/d.lst
@@ -0,0 +1,2 @@
+..\%__SRC%\bin\xml2cmp.exe %_DEST%\bin%_EXT%\xml2cmp.exe
+..\%__SRC%\bin\xml2cmp %_DEST%\bin%_EXT%\xml2cmp
diff --git a/xml2cmp/source/inc/lst_str.h b/xml2cmp/source/inc/lst_str.h
new file mode 100644
index 000000000000..d56342ecae3a
--- /dev/null
+++ b/xml2cmp/source/inc/lst_str.h
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * $RCSfile: lst_str.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CPV_LST_STR_H
+#define CPV_LST_STR_H
+
+#include "str.h"
+
+
+typedef struct LSElem
+{
+ Cstring * pData;
+ struct LSElem * pNext;
+} LSElem;
+
+
+typedef struct LSIterator
+{
+ LSElem * pElement;
+} LSIterator;
+
+
+typedef struct ListCstring
+{
+ LSElem * dpStart;
+ LSElem * pEnd;
+ Bool bAutoDeleteData;
+} ListCstring;
+
+
+#define ListCstring_THIS ListCstring * pThis
+#define LSIterator_THIS LSIterator * pThis
+#define LSElem_THIS LSElem * pThis
+
+
+
+void ListCstring_CTOR( ListCstring_THIS,
+ Bool i_bAutoDeleteData );
+void ListCstring_DTOR( ListCstring_THIS );
+
+void LS_Add( ListCstring_THIS,
+ Cstring * i_pData );
+void LS_Empty( ListCstring_THIS,
+ Bool i_bDeleteData );
+void LS_Append( ListCstring_THIS,
+ char * i_sStrings[],
+ intt i_nNrOfStrings );
+Bool LS_IsEmpty( ListCstring_THIS );
+
+LSIterator LS_Begin( ListCstring_THIS );
+
+
+void LSIterator_CTOR( LSIterator_THIS,
+ LSElem * i_pElement );
+void LSI_opp( LSIterator_THIS ); /** operator++() */
+
+Bool LSI_obool( LSIterator_THIS );
+Cstring * LSI_optr( LSIterator_THIS ); /** operator->() */
+
+
+void LSElem_CTOR( LSElem_THIS,
+ Cstring * i_pData );
+void LSElem_DTOR( LSElem_THIS );
+
+Cstring * LSE_Data( LSElem_THIS );
+LSElem * LSE_Next( LSElem_THIS );
+
+void LSE_SetNext( LSElem_THIS,
+ LSElem * i_pNext );
+void LSE_DeleteData( LSElem_THIS );
+
+
+
+#endif
+
diff --git a/xml2cmp/source/inc/new_del.h b/xml2cmp/source/inc/new_del.h
new file mode 100644
index 000000000000..9854a3bc3a96
--- /dev/null
+++ b/xml2cmp/source/inc/new_del.h
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * $RCSfile: new_del.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CPV_NEW_DEL_H
+#define CPV_NEW_DEL_H
+
+
+void * New(
+ intt i_nSize );
+void Delete(
+ void * io_pMemory );
+
+/* at ASSIGN_NEW ptr must be an L-Value. */
+#define ASSIGN_NEW( ptr, type ) \
+ { ptr = New( sizeof( type ) ); type##_CTOR( ptr ); }
+
+#define ASSIGN_NEW1( ptr, type, param1 ) \
+ { ptr = New( sizeof( type ) ); type##_CTOR( ptr, param1 ); }
+
+#define ASSIGN_NEW2( ptr, type, param1, param2 ) \
+ { ptr = New( sizeof( type ) ); type##_CTOR( ptr, param1, param2 ); }
+
+#define ASSIGN_NEW3( ptr, type, param1, param2, param3 ) \
+ { ptr = New( sizeof( type ) ); type##_CTOR( ptr, param1, param2, param3 ); }
+
+#define DELETE( ptr, type ) \
+ { type##_DTOR( ptr ); Delete(ptr); }
+
+#endif
+
+
diff --git a/xml2cmp/source/inc/precomp.h b/xml2cmp/source/inc/precomp.h
new file mode 100644
index 000000000000..6cd3998b0ee2
--- /dev/null
+++ b/xml2cmp/source/inc/precomp.h
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * $RCSfile: precomp.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CPV_PRECOMP_H
+#define CPV_PRECOMP_H
+
+#define _NO_BOOL_TYPE_
+
+typedef short Bool;
+#define True 1
+#define False 0
+
+
+
+typedef long intt;
+
+#define AND &&
+#define OR ||
+#define NOT !
+
+
+#define REF( x ) (&(x))
+#define MREF( x ) (&(pThis->x))
+#define THIS_ pThis
+
+
+
+#endif
+
+
+
diff --git a/xml2cmp/source/inc/str.h b/xml2cmp/source/inc/str.h
new file mode 100644
index 000000000000..71814185e29e
--- /dev/null
+++ b/xml2cmp/source/inc/str.h
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * $RCSfile: str.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CPV_STR_H
+#define CPV_STR_H
+
+
+#ifdef UNX
+#define stricmp(str1,str2) strcasecmp(str1, str2)
+#define strnicmp(str1,str2,n) strncasecmp(str1, str2, n)
+#endif
+
+
+typedef struct Cstring
+{
+ char * dpText;
+ intt nLength;
+
+} Cstring;
+
+#define Cstring_THIS Cstring * pThis
+
+
+void Cstring_CTOR( Cstring_THIS,
+ char * pText );
+void Cstring_DTOR( Cstring * pThis );
+
+void Cs_Assign( Cstring_THIS,
+ char * i_pNewText );
+void Cs_AssignPart( Cstring_THIS,
+ char * i_pNewText,
+ intt i_nLength );
+
+void Cs_AddCs( Cstring_THIS,
+ Cstring * i_pAddedText );
+void Cs_Add( Cstring_THIS,
+ char * i_pAddedText );
+
+char * Cs_Str( Cstring_THIS );
+intt Cs_Length( Cstring_THIS );
+
+void Cs_ToUpper( Cstring_THIS );
+
+
+
+#endif
+
diff --git a/xml2cmp/source/inc/textbuff.h b/xml2cmp/source/inc/textbuff.h
new file mode 100644
index 000000000000..4ba64631d9da
--- /dev/null
+++ b/xml2cmp/source/inc/textbuff.h
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * $RCSfile: textbuff.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CTLS_TEXTBUFF_H
+#define CTLS_TEXTBUFF_H
+
+#include "textfile.h"
+
+
+typedef struct TextBuffer
+{
+ char * dpText;
+ intt nSize;
+
+ intt nPosition;
+
+} TextBuffer;
+
+#define TextBuffer_THIS TextBuffer * pThis
+
+
+#define ENDS '\0'
+#define ENDL '\n'
+
+typedef enum E_TB_Relation
+{
+ tb_begin,
+ tb_cur,
+ tb_end
+} E_TB_Relation;
+
+
+void TextBuffer_CTOR( TextBuffer_THIS,
+ intt i_nSize );
+void TextBuffer_DTOR( TextBuffer_THIS );
+void TB_Resize( TextBuffer_THIS,
+ intt i_nNewSize );
+
+Bool TB_oin( TextBuffer_THIS, /** operator>>(char *) */
+ char * i_pText );
+Bool TB_oinChar( TextBuffer_THIS, /** operator>>(char) */
+ char i_cChar );
+Bool TB_oinFile( TextBuffer_THIS, /** operator>>(TextFile*) */
+ TextFile * i_pFile );
+void TB_opp( TextBuffer_THIS ); /** operator++ */
+
+intt TB_Goto( TextBuffer_THIS,
+ intt i_nPosition,
+ E_TB_Relation i_nRelation ); /** tb_begin, tb_cur, tb_end */
+
+
+char * TB_Text( TextBuffer_THIS );
+char TB_CurChar( TextBuffer_THIS );
+char * TB_CurCharPtr( TextBuffer_THIS );
+intt TB_Size( TextBuffer_THIS );
+intt TB_Position( TextBuffer_THIS );
+Bool TB_EndOfBuffer( TextBuffer_THIS );
+
+
+#endif
+
diff --git a/xml2cmp/source/inc/textfile.h b/xml2cmp/source/inc/textfile.h
new file mode 100644
index 000000000000..fee8527dad43
--- /dev/null
+++ b/xml2cmp/source/inc/textfile.h
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * $RCSfile: textfile.h,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef CPV_TEXTFILE_H
+#define CPV_TEXTFILE_H
+
+#include <stdio.h>
+#include "str.h"
+
+
+
+typedef struct TextFile
+{
+ Cstring sName;
+ FILE * hFile;
+ intt nLastAction;
+} TextFile;
+
+#define TextFile_THIS TextFile * pThis
+
+
+
+void TextFile_CTOR( TextFile_THIS,
+ char * i_pName );
+void TextFile_DTOR( TextFile_THIS );
+
+Bool TF_Open( TextFile_THIS,
+ char * i_sOptions ); /* options for second parameter of fopen */
+Bool TF_Create( TextFile_THIS );
+void TF_Close( TextFile_THIS );
+
+void TF_Goto( TextFile_THIS,
+ intt i_nPosition );
+intt TF_Read( TextFile_THIS,
+ char * o_pBuffer,
+ intt i_nNrOfBytes );
+intt TF_Write( TextFile_THIS,
+ char * i_pBuffer,
+ intt i_nNrOfBytes );
+intt TF_WriteStr( TextFile_THIS,
+ char * i_pString );
+
+intt TF_Position( TextFile_THIS );
+intt TF_Size( TextFile_THIS );
+
+
+
+
+#endif
+
+
+
diff --git a/xml2cmp/source/x2cclass/x2cstl.hxx b/xml2cmp/source/x2cclass/x2cstl.hxx
new file mode 100644
index 000000000000..53c5a72a7b6c
--- /dev/null
+++ b/xml2cmp/source/x2cclass/x2cstl.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * $RCSfile: x2cstl.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef UDKSERVICE_X2CSTL_HXX
+#define UDKSERVICE_X2CSTL_HXX
+
+
+#if STLPORT_VERSION < 321
+#include <tools/presys.h>
+#include <vector.h>
+#include <tools/postsys.h>
+#else
+#include <vector>
+#endif // STLPORT_VERSION < 321
+
+#ifdef _USE_NO_NAMERSPACES_
+#define std
+#endif
+
+
+#endif
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cd.hxx b/xml2cmp/source/x2cclass/xml_cd.hxx
new file mode 100644
index 000000000000..3ed8999e34ed
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cd.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * $RCSfile: xml_cd.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef UDKSERVICE_XML_CD_HXX
+#define UDKSERVICE_XML_CD_HXX
+
+
+#include <tools/string.hxx>
+#include "x2cstl.hxx"
+
+
+
+/** Represents one Component description from an XML file.
+ DatumOf() is used for tags with only one value.
+ DataOf() is used, if the tag has multiple values or if
+ you don't know.
+**/
+class ComponentDescription
+{
+ public:
+ /** @ATTENTION
+ Because the enum values are used as array indices:
+ tag_None must be the first and have the value "0".
+ tag_MAX must be the last.
+ The enum values must not be assigned numbers.
+ **/
+ enum E_Tag
+ {
+ tag_None = 0,
+ tag_Name,
+ tag_Description,
+ tag_ModuleName,
+ tag_LoaderName,
+ tag_SupportedService,
+ tag_ProjectBuildDependency,
+ tag_RuntimeModuleDependency,
+ tag_ServiceDependency,
+ tag_Language,
+ tag_Status,
+ tag_Type,
+ tag_MAX
+ };
+
+ virtual ~ComponentDescription() {}
+
+ /// @return All values of this tag. An empty vector for wrong indices.
+ virtual const std::vector< ByteString > &
+ DataOf(
+ ComponentDescription::E_Tag
+ i_eTag ) const = 0;
+
+ /// @return The only or the first value of this tag. An empty string for wrong indices.
+ virtual ByteString DatumOf(
+ ComponentDescription::E_Tag
+ i_eTag ) const = 0;
+};
+
+
+#endif
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cdff.cxx b/xml2cmp/source/x2cclass/xml_cdff.cxx
new file mode 100644
index 000000000000..deb74d566126
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cdff.cxx
@@ -0,0 +1,265 @@
+/*************************************************************************
+ *
+ * $RCSfile: xml_cdff.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "xml_cdff.hxx"
+
+#include <string.h>
+#include <tools/stream.hxx>
+#include "xml_cdim.hxx"
+#include <ctype.h>
+
+
+typedef ComponentDescriptionImpl::ValueList CdiValueList;
+
+class dyn_buffer
+{
+ public:
+ dyn_buffer() : s(0) {}
+ ~dyn_buffer() { if (s) delete [] s; }
+ operator const char *() const { return s; }
+ char * operator->() { return s; }
+ char & operator[](
+ INT32 ix ) { return s[ix]; }
+ void SetSize(
+ INT32 i_size ) { if (s) delete [] s; s = new char [i_size]; }
+ private:
+ char * s;
+};
+
+
+inline BOOL
+LoadXmlFile( dyn_buffer & o_rBuffer,
+ const UniString & i_sXmlFilePath )
+{
+ BOOL ret = TRUE;
+ SvFileStream aXmlFile;
+
+ aXmlFile.Open(i_sXmlFilePath, STREAM_READ);
+ if (aXmlFile.GetErrorCode() != FSYS_ERR_OK)
+ ret = FALSE;
+ if (ret)
+ {
+ aXmlFile.Seek(STREAM_SEEK_TO_END);
+ INT32 nBufferSize = aXmlFile.Tell();
+ o_rBuffer.SetSize(nBufferSize + 1);
+ o_rBuffer[nBufferSize] = '\0';
+ aXmlFile.Seek(0);
+ if (aXmlFile.Read(o_rBuffer.operator->(), nBufferSize) == 0)
+ ret = FALSE;
+ }
+
+ aXmlFile.Close();
+ return ret;
+}
+
+
+
+CompDescrsFromAnXmlFile::CompDescrsFromAnXmlFile()
+ : dpDescriptions(new std::vector< ComponentDescriptionImpl* >),
+ eStatus(not_yet_parsed)
+{
+ dpDescriptions->reserve(3);
+}
+
+CompDescrsFromAnXmlFile::~CompDescrsFromAnXmlFile()
+{
+ Empty();
+ delete dpDescriptions;
+}
+
+
+BOOL
+CompDescrsFromAnXmlFile::Parse( const UniString & i_sXmlFilePath )
+{
+ dyn_buffer dpBuffer;
+
+ if (! LoadXmlFile(dpBuffer,i_sXmlFilePath) )
+ {
+ eStatus = cant_read_file;
+ return FALSE;
+ }
+
+ const char * pTokenStart = 0;
+ const char * pBufferPosition = dpBuffer;
+ INT32 nTokenLength = 0;
+ BOOL bWithinElement = FALSE;
+
+ CdiValueList * pCurTagData = 0;
+ ByteString sStatusValue; // Used only if a <Status ...> tag is found.
+
+
+ for ( ComponentDescriptionImpl::ParseUntilStartOfDescription(pBufferPosition);
+ pBufferPosition != 0;
+ ComponentDescriptionImpl::ParseUntilStartOfDescription(pBufferPosition) )
+ {
+ ComponentDescriptionImpl * pCurCD = 0;
+ pCurCD = new ComponentDescriptionImpl;
+ dpDescriptions->push_back(pCurCD);
+
+ for ( ; *pBufferPosition != '\0' && pCurCD != 0; )
+ {
+ switch (*pBufferPosition)
+ {
+ case '<' :
+ if (! bWithinElement)
+ {
+ pCurTagData = pCurCD->GetBeginTag(sStatusValue, pBufferPosition);
+ if (pCurTagData != 0)
+ {
+ if (sStatusValue.Len () == 0)
+ {
+ // Start new token:
+ pTokenStart = pBufferPosition;
+ nTokenLength = 0;
+ bWithinElement = TRUE;;
+ }
+ else
+ {
+ // Status tag is already parsed:
+ pCurTagData->push_back(sStatusValue);
+ } // endif (sStatusValue.Length () == 0)
+ }
+ else if ( ComponentDescriptionImpl::CheckEndOfDescription(pBufferPosition) )
+ {
+ pBufferPosition += ComponentDescriptionImpl::DescriptionEndTagSize();
+ pCurCD = 0;
+ }
+ else
+ {
+ eStatus = inconsistent_file;
+ return FALSE;
+ } // endif (pCurTagData != 0) elseif() else
+ }
+ else if ( pCurTagData->MatchesEndTag(pBufferPosition) )
+ {
+ // Finish token:
+ pBufferPosition += pCurTagData->EndTagLength();
+ bWithinElement = FALSE;
+
+ // Remove leading and trailing spaces:
+ while ( isspace(*pTokenStart) )
+ {
+ pTokenStart++;
+ nTokenLength--;
+ }
+ while ( nTokenLength > 0
+ && isspace(pTokenStart[nTokenLength-1]) )
+ {
+ nTokenLength--;
+ }
+ // Add token to tag values list.
+ pCurTagData->push_back(ByteString(pTokenStart,nTokenLength));
+ }
+ else
+ {
+ nTokenLength++;
+ ++pBufferPosition;
+ } // endif (!bWithinElement) else if () else
+ break;
+ default:
+ if (bWithinElement)
+ {
+ ++nTokenLength;
+ }
+ ++pBufferPosition;
+ } // end switch
+ } // end for
+
+ if (bWithinElement)
+ {
+ eStatus = inconsistent_file;
+ return FALSE;
+ }
+ } // end for
+
+ return TRUE;
+}
+
+INT32
+CompDescrsFromAnXmlFile::NrOfDescriptions() const
+{
+ return dpDescriptions->size();
+}
+
+const ComponentDescription &
+CompDescrsFromAnXmlFile::operator[](INT32 i_nIndex) const
+{
+ static const ComponentDescriptionImpl aNullDescr_;
+ return 0 <= i_nIndex && i_nIndex < dpDescriptions->size()
+ ? *(*dpDescriptions)[i_nIndex]
+ : aNullDescr_;
+}
+
+void
+CompDescrsFromAnXmlFile::Empty()
+{
+ for ( std::vector< ComponentDescriptionImpl* >::iterator aIter = dpDescriptions->begin();
+ aIter != dpDescriptions->end();
+ ++aIter )
+ {
+ delete *aIter;
+ }
+ dpDescriptions->erase( dpDescriptions->begin(),
+ dpDescriptions->end() );
+}
+
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cdff.hxx b/xml2cmp/source/x2cclass/xml_cdff.hxx
new file mode 100644
index 000000000000..bb4a9d8f232d
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cdff.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: xml_cdff.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef UDKSERVICE_XML_CDFF_HXX
+#define UDKSERVICE_XML_CDFF_HXX
+
+
+#include <tools/string.hxx>
+#include "xml_cd.hxx"
+
+class ComponentDescriptionImpl;
+
+
+/** @descr
+ Is able to parse an XML file with Component descriptions. Gives access
+ to the parsed data.
+
+ Use:
+ CompDescrsFromAnXmlFile aCds;
+ UniString aFilepath(...);
+ if (! aCds.Parse(aFilepath) )
+ {
+ // react on:
+ aCds.Status();
+ }
+
+ With operator[] you get access to ComponentDescriptions
+ on indices 0 to NrOfDescriptions()-1 .
+
+ For further handling see class ComponentDescription
+ in xml_cd.hxx .
+
+ It is possible to parse more than one time. Then the old data
+ are discarded.
+**/
+class CompDescrsFromAnXmlFile
+{
+ public:
+ enum E_Status
+ {
+ ok = 0,
+ not_yet_parsed,
+ cant_read_file,
+ inconsistent_file,
+ no_tag_found_in_file
+ };
+
+ // LIFECYCLE
+ CompDescrsFromAnXmlFile();
+ ~CompDescrsFromAnXmlFile();
+
+ // OPERATIONS
+ BOOL Parse(
+ const UniString & i_sXmlFilePath );
+
+ // INQUIRY
+ INT32 NrOfDescriptions() const;
+ const ComponentDescription &
+ operator[]( /// @return an empty description, if index does not exist.
+ INT32 i_nIndex ) const;
+ CompDescrsFromAnXmlFile::E_Status
+ Status() const;
+
+ private:
+ // PRIVATE SERVICES
+ void Empty();
+
+ // DATA
+ std::vector< ComponentDescriptionImpl* > *
+ dpDescriptions;
+ E_Status eStatus;
+};
+
+
+
+
+
+#endif
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cdim.cxx b/xml2cmp/source/x2cclass/xml_cdim.cxx
new file mode 100644
index 000000000000..caf5b99a4ddf
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cdim.cxx
@@ -0,0 +1,217 @@
+/*************************************************************************
+ *
+ * $RCSfile: xml_cdim.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "xml_cdim.hxx"
+
+const char ComponentDescriptionImpl::C_sTagDescription[]
+ = "COMPONENTDESCRIPTION";
+const char ComponentDescriptionImpl::C_sStatus[]
+ = "Status";
+const char * ComponentDescriptionImpl::C_sSubTags[ComponentDescription::tag_MAX]
+ = { "None",
+ "Name",
+ "Description",
+ "ModuleName",
+ "LoaderName",
+ "SupportedService",
+ "ProjectBuildDependency",
+ "RuntimeModuleDependency",
+ "ServiceDependency",
+ "Language",
+ C_sStatus,
+ "Type"
+ };
+
+ComponentDescriptionImpl::ComponentDescriptionImpl()
+// : aTags
+{
+ const int i_max = tag_MAX;
+ aTags.reserve(i_max);
+
+ for (int i = 0; i < i_max; ++i)
+ {
+ aTags.push_back( new ValueList(E_Tag(i)) );
+ } // end for
+}
+
+ComponentDescriptionImpl::~ComponentDescriptionImpl()
+{
+ for ( std::vector< ValueList* >::iterator aIter = aTags.begin();
+ aIter != aTags.end();
+ ++aIter )
+ {
+ delete *aIter;
+ }
+}
+
+inline void
+GetStatusValue( ByteString & o_sValue, const ByteString & i_sStatusTag )
+{
+ // o_sValue is always == "" at the beginning.
+
+ const char * pStatusValue = strchr(i_sStatusTag.GetBuffer(), '"');
+ if (pStatusValue == 0)
+ return;
+ pStatusValue++;
+ const char * pStatusValueEnd = strrchr(pStatusValue,'"');
+ if (pStatusValueEnd == 0 || pStatusValueEnd - pStatusValue < 1)
+ return ;
+
+ ByteString sValue(pStatusValue, pStatusValueEnd - pStatusValue);
+ o_sValue = sValue;
+}
+
+ComponentDescriptionImpl::ValueList *
+ComponentDescriptionImpl::GetBeginTag( ByteString & o_sValue,
+ const char *& io_pStartOfTag ) const
+{
+ o_sValue = "";
+
+ const char * pCurTextEnd = strchr(io_pStartOfTag,'>');
+ if ( 0 == pCurTextEnd )
+ return 0;
+
+ if ( ComponentDescriptionImpl::CheckEndOfDescription(io_pStartOfTag) )
+ return 0;
+
+ ByteString sTag(io_pStartOfTag + 1, pCurTextEnd - io_pStartOfTag - 1);
+ io_pStartOfTag += sTag.Len() + 2;
+
+ // Special case <Status ... >
+ if ( strnicmp(C_sStatus, sTag.GetBuffer(), (sizeof C_sStatus) - 1 ) == 0 )
+ {
+ GetStatusValue(o_sValue,sTag);
+ return aTags[tag_Status];
+ }
+
+ // Regular seeking for matching data list:
+ for ( INT32 i = 0; i < tag_MAX; i++ )
+ {
+ if ( 0 == stricmp(sTag.GetBuffer(), C_sSubTags[i]) )
+ return aTags[i];
+ } // end for
+
+ return 0;
+}
+
+const std::vector< ByteString > &
+ComponentDescriptionImpl::DataOf( ComponentDescriptionImpl::E_Tag i_eTag ) const
+{
+ if (0 < i_eTag && i_eTag < tag_MAX)
+ return *aTags[i_eTag];
+ else
+ return ValueList::Null_();
+}
+
+ByteString
+ComponentDescriptionImpl::DatumOf( ComponentDescriptionImpl::E_Tag i_eTag ) const
+{
+ if (0 < i_eTag && i_eTag < tag_MAX)
+ {
+ ValueList & rValues = *aTags[i_eTag];
+ if (rValues.size() > 0)
+ return rValues[0];
+ }
+ return "";
+}
+
+void
+ComponentDescriptionImpl::ParseUntilStartOfDescription( const char * & io_pBufferPosition )
+{
+ for ( const char * pSearch = strchr(io_pBufferPosition,'<');
+ pSearch != 0;
+ pSearch = strchr(pSearch+1,'<') )
+ {
+ if ( pSearch != io_pBufferPosition
+ && 0 == strnicmp(pSearch+1,C_sTagDescription, strlen(C_sTagDescription))
+ && *(pSearch + strlen(C_sTagDescription) + 1) == '>' )
+ {
+ io_pBufferPosition = pSearch + strlen(C_sTagDescription) + 2;
+ return;
+ }
+ } // end for
+
+ io_pBufferPosition = 0;
+}
+
+BOOL
+ComponentDescriptionImpl::ValueList::MatchesEndTag( const char * i_pTextPosition ) const
+{
+ return strnicmp( i_pTextPosition+2, C_sSubTags[eTag], strlen(C_sSubTags[eTag]) ) == 0
+ && strncmp(i_pTextPosition,"</",2) == 0
+ && *(i_pTextPosition + 2 + strlen(C_sSubTags[eTag]) ) == '>';
+}
+
+INT32
+ComponentDescriptionImpl::ValueList::EndTagLength() const
+{
+ return strlen(C_sSubTags[eTag]) + 3;
+}
+
+
+const ComponentDescriptionImpl::ValueList &
+ComponentDescriptionImpl::ValueList::Null_()
+{
+ static const ValueList aNull_(ComponentDescription::tag_None);
+ return aNull_;
+}
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cdim.hxx b/xml2cmp/source/x2cclass/xml_cdim.hxx
new file mode 100644
index 000000000000..9e354362bce3
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cdim.hxx
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * $RCSfile: xml_cdim.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:00 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef UDKSERVICE_XML_CDIM_HXX
+#define UDKSERVICE_XML_CDIM_HXX
+
+
+#include "xml_cd.hxx"
+#include <tools/string.hxx>
+
+
+
+
+
+/** Represents one of the Component descriptions in an XML file.
+ Implements ComponentDescription and does part of the parsing for class CompDescrsFromAnXmlFile.
+**/
+class ComponentDescriptionImpl : public ComponentDescription
+{
+ public:
+ class ValueList : public std::vector< ByteString >
+ {
+ public:
+ // LIFECYCLE
+ ValueList(
+ E_Tag i_eTag )
+ : eTag(i_eTag) {}
+ // INQUIRY
+ const char * BeginTag() const;
+ BOOL MatchesEndTag(
+ const char * i_pTextPosition ) const;
+ INT32 EndTagLength() const;
+
+ static const ValueList &
+ Null_();
+ private:
+ E_Tag eTag;
+ };
+
+ // LIFECYCLE
+ ComponentDescriptionImpl();
+ virtual ~ComponentDescriptionImpl();
+
+ // OPERATIONS
+ ValueList * GetBeginTag(
+ ByteString & o_sValue,
+ const char * & io_pStartOfTag ) const;
+ static void ParseUntilStartOfDescription(
+ const char * & io_pBufferPosition );
+ static BOOL CheckEndOfDescription(
+ const char * & io_pBufferPosition );
+ // INQUIRY
+ static INT32 DescriptionEndTagSize();
+
+ // INTERFACE ComponentDescription
+ // INQUIRY
+ virtual const std::vector< ByteString > &
+ DataOf( /// @return All values of this tag.
+ ComponentDescription::E_Tag
+ i_eTag ) const;
+ virtual ByteString DatumOf( /// @return The only or the first value of this tag.
+ ComponentDescription::E_Tag
+ i_eTag ) const;
+ private:
+ // DATA
+ static const char C_sTagDescription[];
+ static const char C_sStatus[];
+ static const char * C_sSubTags[ComponentDescription::tag_MAX];
+ friend class ValueList;
+
+ std::vector< ValueList* > // Dynamic allocated pointers.
+ aTags;
+};
+
+
+inline BOOL
+ComponentDescriptionImpl::CheckEndOfDescription( const char * & io_pBufferPosition )
+ { return strnicmp(io_pBufferPosition + 2, C_sTagDescription, strlen(C_sTagDescription)) == 0
+ && strncmp(io_pBufferPosition, "</", 2) == 0
+ && * (io_pBufferPosition + 2 + strlen(C_sTagDescription)) == '>'; }
+
+inline INT32
+ComponentDescriptionImpl::DescriptionEndTagSize()
+ { return strlen(C_sTagDescription) + 3; }
+
+
+#endif
+
+